Skip to content

Commit 9f31549

Browse files
committed
Add multi-file specs and richer help support
1 parent ca67d8d commit 9f31549

2 files changed

Lines changed: 87 additions & 0 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ In practice this improves compatibility with APIs that define inputs outside sim
8888
In practice this improves compatibility with APIs that rely on non-trivial parameter encoding or per-operation server definitions.
8989

9090

91+
### Multi-file specs and richer help
92+
93+
`ocli` now works better with larger, more structured API descriptions:
94+
95+
- external `$ref` resolution across multiple local or remote OpenAPI / Swagger documents
96+
- support for multi-document specs that split paths, parameters, and request bodies into separate files
97+
- richer `--help` output with schema hints such as `enum`, `default`, `nullable`, and `oneOf`
98+
- better handling of composed schemas that use `allOf` for shared request object structure
99+
100+
In practice this improves compatibility with modular specs and makes generated commands easier to use without opening the original OpenAPI document.
101+
91102
### Multi-file specs and richer help
92103

93104
`ocli` now works better with larger, more structured API descriptions:

tests/cli.test.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,82 @@ describe("cli", () => {
948948
expect(config.headers.Cookie).toBe("session_id=cookie-abc");
949949
});
950950

951+
it("shows schema hints in command help output", async () => {
952+
const localDir = `${cwd}/.ocli`;
953+
const profilesPath = `${localDir}/profiles.ini`;
954+
const cachePath = `${localDir}/specs/help-hints-api.json`;
955+
956+
const spec = {
957+
openapi: "3.1.0",
958+
paths: {
959+
"/reports": {
960+
post: {
961+
requestBody: {
962+
required: true,
963+
content: {
964+
"application/json": {
965+
schema: {
966+
type: "object",
967+
properties: {
968+
format: {
969+
type: "string",
970+
enum: ["csv", "json"],
971+
default: "json",
972+
},
973+
note: {
974+
type: "string",
975+
nullable: true,
976+
},
977+
filter: {
978+
oneOf: [
979+
{ type: "string" },
980+
{ type: "integer" },
981+
],
982+
},
983+
},
984+
required: ["format"],
985+
},
986+
},
987+
},
988+
},
989+
},
990+
},
991+
},
992+
};
993+
994+
const iniContent = [
995+
"[help-hints-api]",
996+
"api_base_url = https://api.example.com",
997+
"api_basic_auth = ",
998+
"api_bearer_token = tok",
999+
"openapi_spec_source = /spec.json",
1000+
`openapi_spec_cache = ${cachePath}`,
1001+
"include_endpoints = ",
1002+
"exclude_endpoints = ",
1003+
"",
1004+
].join("\n");
1005+
1006+
const log: string[] = [];
1007+
const { profileStore, openapiLoader } = createCliDeps(cwd, homeDir, {
1008+
[profilesPath]: iniContent,
1009+
[cachePath]: JSON.stringify(spec),
1010+
[`${localDir}/current`]: "help-hints-api",
1011+
});
1012+
1013+
await run(["reports", "--help"], {
1014+
cwd,
1015+
profileStore,
1016+
openapiLoader,
1017+
stdout: (msg: string) => log.push(msg),
1018+
});
1019+
1020+
const out = log.join("");
1021+
expect(out).toContain('enum: "csv", "json"');
1022+
expect(out).toContain('default: "json"');
1023+
expect(out).toContain("nullable");
1024+
expect(out).toContain("oneOf: string | integer");
1025+
});
1026+
9511027
it("serializes query arrays and deepObject parameters from spec metadata", async () => {
9521028
const localDir = `${cwd}/.ocli`;
9531029
const profilesPath = `${localDir}/profiles.ini`;

0 commit comments

Comments
 (0)