Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature clarification request: multiple schemas #1497

Closed
melissag opened this issue Dec 29, 2023 · 7 comments
Closed

Feature clarification request: multiple schemas #1497

melissag opened this issue Dec 29, 2023 · 7 comments
Labels
docs Requires an update to docs good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project openapi-ts Relevant to the openapi-typescript library PRs welcome PRs are welcome to solve this issue! stale

Comments

@melissag
Copy link

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?

@drwpow
Copy link
Contributor

drwpow commented Jan 19, 2024

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 🙂

@drwpow drwpow added PRs welcome PRs are welcome to solve this issue! good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project docs Requires an update to docs openapi-ts Relevant to the openapi-typescript library labels Jan 19, 2024
@mariusflorescu
Copy link

On the same topic what if we have:

  • reference.json - which contains $defs
  • openapi.yaml file that references the defs from the reference.json file

Is it possible to make it work? I don't see an example of this use case in the docs.

@melissag
Copy link
Author

@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?

@drwpow
Copy link
Contributor

drwpow commented Jan 31, 2024

@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!

@melissag
Copy link
Author

melissag commented Feb 1, 2024

Done, thanks for the guidance! Let me know if I goofed on anything in the PR process, not super familiar.

Copy link
Contributor

github-actions bot commented Aug 6, 2024

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.

@github-actions github-actions bot added the stale label Aug 6, 2024
Copy link
Contributor

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.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Requires an update to docs good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project openapi-ts Relevant to the openapi-typescript library PRs welcome PRs are welcome to solve this issue! stale
Projects
None yet
Development

No branches or pull requests

3 participants