-
-
Notifications
You must be signed in to change notification settings - Fork 537
broken local $ref #715
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
Comments
How are your types broken? I’d need to see the following:
That all seems correct, actually. But in order for that local |
I have a problem with local ref too. Though I'm using the openapi generator the first time, so maybe I'm doing something wrong. The case is as follows: Simplified openapi scheme snippet:
Notice the reference in
Now if we look at the generated code, it tries to use the same reference path as in the scheme:
But that does not exist in the generated TS file. It only existed in the scheme:
Looks like a bug to me. |
Reading official swagger documentation that suggests that common type definitions should be placed under "components". However it is not clear to me if it's a recommendation or a mandatory rule: Often, multiple API operations have some common parameters or return the same response structure. To avoid code duplication, you can place the common definitions in the global components section and reference them using $ref. In the example below, duplicate definitions of a User object are replaced with a single component and references to that component. |
Using $ref somehow breaks generated types. I'm new with openapi and with the library so my apologies if fault is mine but following setup will produce wrong types 🤔
https://gitpod.io#snapshot/50d6481d-7417-4c11-97dd-b84e84f71af5
run
yarn generate
and check
schema.ts
I spent hours on the and schema looks ok. Whats strange to me is following output
where the
components
interface accessing non existing pathThe text was updated successfully, but these errors were encountered: