Bundling leads to self-referencing component schemas
See original GitHub issueDescribe the bug
When using the bundle
command, the schemas in components.schemas reference themselves, instead of being dereferenced.
Example from output:
components:
schemas:
User:
$ref: '#/components/schemas/User'
Country:
$ref: '#/components/schemas/Country'
Game:
$ref: '#/components/schemas/Game'
To Reproduce
I don’t have a small reproduction, as our API is large (28k lines when bundled using another tool).
I can send the spec on request, via a private channel.
Expected behavior
I expected the component schemas to be dereferenced.
Logs
n/a
OpenAPI definition
(see above)
openapi-cli
Version(s)
1.0.0-beta.44
Node.js
Version(s)
14.16.1
Additional context
n/a
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:6 (3 by maintainers)
Top Results From Across the Web
JSON Schema Bundling Finally Formalised
Existing tooling developers have created their own approaches to bundling JSON Schema and OpenAPI documents, but that can lead to errors.
Read more >Unify reference and bundling behavior with JSON Schema #649
An alternative to the first point could be to only port the bundling behavior from JSON Schema and skip referencing one.
Read more >Only You Can Bring Modern OpenAPI Bundling to JavaScript
Seeing as OpenAPI v3. 1 and JSON Schema are now entirely compatible, this means OpenAPI has inherited that standardized bundling method. All ...
Read more >Structuring a complex schema — Understanding JSON ...
Let's assume a schema is referenced using the URI https://example.com/schemas/address and the following schema is retrieved. { "type": "object", "properties" ...
Read more >Bundle - FHIR v5.0.0-cibuild
"$ref": "Meta.schema.json#/definitions/Meta" }, "implicitRules": { "description": "A reference to a set of rules that were followed when the resource was ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mauris I think the issue is with the invalid way to split the YAML file:
See this issue for more details: #658
I had the same issue. We currently try different ways to split and structure our YAML file.
In our case the problem was that we referenced a file with a list of definitions that also contains references. For example in the main yaml the
parameters
section contains a reference to the file _index.yaml.Snippet of main yaml
The _index.yaml contains the list to all parameters with references to the respective parameter definition. In the path definitions we reference to the parameter file e.g. /query-parameters.yaml#/modelId
Snippet of parameters/_index.yaml
Maybe this helps.