redocly-cli
redocly-cli copied to clipboard
Decorator or feature flag to bundle merge "allOf" schemas
Is your feature request related to a problem? Please describe.
Let's say I have these schemas:
schemas:
Car:
allOf:
- $ref: #/components/schemas/Make
- $ref: #/components/schemas/Model
- type: object
properties:
manufacturedAt:
type: string
format: date
color:
type: string
Make:
type: object
properties:
make:
type: string
enum:
- Batmobile
- DeLorean
Model:
type: object
properties:
model:
type: string
And now, I have an application (not Redocly), that needs to consume this schema and operate on it. The application struggles with the allOf
. I wish to have a resulting merged schema like the following to make it easier for third party programs to use:
Car:
type: object
properties:
make: ...
model: ...
manufacturedAt: ...
color: ...
Describe the solution you'd like
- A flag on the bundle command like
--merge-all-of
. - A decorator that can be included in a
redocly.yaml
file likemerge-all-of
.
Describe alternatives you've considered
Requesting third party libs have better allOf
support. 🤣
Additional context
None
this is related to bundling or flattening and is a hot topic in the JSON Schema community. It was undefined behavior for quite a few years and only recently have they officially documented the bundling process for 2020-12.
I believe there are some major behavior differences depending on the draft used in the schema. for example, use of additionalProperties
has long been a hang up with earlier drafts and allOf
schemas
here's a fairly popular package: https://github.com/mokkabonna/json-schema-merge-allof
@relequestual @jdesrosiers @MikeRalphson