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

Decorator or feature flag to bundle merge "allOf" schemas #1236

Open
adamaltman opened this issue Aug 17, 2023 · 1 comment
Open

Decorator or feature flag to bundle merge "allOf" schemas #1236

adamaltman opened this issue Aug 17, 2023 · 1 comment

Comments

@adamaltman
Copy link
Member

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

  1. A flag on the bundle command like --merge-all-of.
  2. A decorator that can be included in a redocly.yaml file like merge-all-of.

Describe alternatives you've considered

Requesting third party libs have better allOf support. 🤣

Additional context

None

@jeremyfiel
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants