Referenced schema with internal fields not detected as identical when bundling
See original GitHub issueThis one is edge casey, so forgive me for the less than clear title.
Let’s say we have spec C, referencing a schema from an external spec called spec A:
properties:
items:
type: array
items:
$ref: 'https://a-service.io/openapi.yaml#/components/schemas/Order'
The Order schema has a single internal field (x-internal: true).
At the same time, spec C itself also has the identical Order schema with the single internal field, further down. Why? Because spec C was created by merging spec A and spec B, one of which has the original Order schema, and the other referencing the original Order schema.
What happens while bundling is that we end up with a schema called “schemas-Order”, produced by the bundle.ts getComponentName(), which did not detect that the incoming schema is identical to the one already in the file. My hunch is that this is because one of the schemas at that point already has the internal field stripped out, while the other one doesn’t.
This does not happen when using my original plugin written according to the docs (separate decorators for stripping internal operations, properties, parameters, components).
It also doesn’t happen if I dereference spec B prior to merging it into the final spec (by running “openapi bundle” on it, then merging). This is an acceptable workaround, but since we also store specs A and B prior to merging, it means we store a larger file than necessary.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Apologies for the delay on my side, I’ll try to produce a repo demonstrating this bug tomorrow.
Let’s close this for now. @bojanz if you have a reproduction, please re-open it.
Also, we’ve made some changes recently to our configuration file format.
https://github.com/redocly-demo/demo-remove-x-internal
If you can make or share a reproduction of the issue, feel free to take from there and add to the level of complexity you need to reproduce the issue.