openapi-typescript
openapi-typescript copied to clipboard
Feature clarification request: multiple schemas
Hoping to clarify the documentation at https://openapi-ts.pages.dev/cli#multiple-schemas; the example provided in the section specifies the output for both apis to be ./openapi/openapi.ts, which implies to me that both api schemas would be merged into a single file. However, when I try this with my own api schemas, the output file is overwritten by each subsequent api declaration - the api which is alphabetically last will "win" the output file. Is this the expected behavior? If so, should the documentation be corrected to have distinct output paths?
Ah if you’re looking to bundle schemas, then you should use the Redocly CLI bundle command. That needs to be run before openapi-typescript.
I’d welcome an addition to the docs that clarifies this (perhaps something like a tip added):
::: tip
This will preserve schemas 1:1 input:output. To bundle multiple schemas into one, use Redocly’s [bundle command](https://redocly.com/docs/resources/multi-file-definitions/#bundle)
:::
Feel free to adjust the wording 🙂
On the same topic what if we have:
reference.json- which contains$defsopenapi.yamlfile that references the defs from thereference.jsonfile
Is it possible to make it work? I don't see an example of this use case in the docs.
@drwpow Thanks for your response. In particular your call out that This will preserve schemas 1:1 input:output suggests to me that the existing documentation example should be updated in the following way:
Current
apis:
core@v2:
root: ./openapi/openapi.yaml
x-openapi-ts:
output: ./openapi/openapi.ts
external@v1:
root: ./openapi/external.yaml
x-openapi-ts:
output: ./openapi/openapi.ts
Updated
apis:
core@v2:
root: ./openapi/openapi.yaml
x-openapi-ts:
output: ./openapi/openapi.ts
external@v1:
root: ./openapi/external.yaml
x-openapi-ts:
output: ./openapi/external.ts # note updated name
Does this make sense to you, or am I still confused on how this is meant to work?
@melissag yes! Apologies for not even noticing the typo in the docs. Yes that’s confusing, and your proposal is exactly how it should work. Would welcome a PR if you have time!
Done, thanks for the guidance! Let me know if I goofed on anything in the PR process, not super familiar.
This issue is stale because it has been open for 90 days with no activity. If there is no activity in the next 7 days, the issue will be closed.
This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.