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

Incorrectly handling of "discriminatedOneOf" case when referencing classes with "allOf" #244

Open
triorph opened this issue Oct 2, 2023 · 0 comments

Comments

@triorph
Copy link

triorph commented Oct 2, 2023

If the discriminator is in the same location as oneOf, and the oneOf references a component that has an allOf, then the system complains that the component is does not contain the required property, as it doesn't directly have it, but gains it indirectly via inheritance.

I took a quick look at writing a test case for this:

openapi: 3.0.0
info:
paths:
components:
  schemas:
    SomeObj:
      type: object
      required:
        - state
      properties:
        state:
          $ref: '#/components/schemas/State'
    State:
      oneOf:
        - $ref: '#/components/schemas/StateA'
        - $ref: '#/components/schemas/StateB'
      discriminator:
        propertyName: status
        mapping:
          a: '#/components/schemas/StateA'
          b: '#/components/schemas/StateB'
    Status:
      type: string
      enum:
        - a
        - b
    ParentState:
      type: object
      required:
        - status:
      properties:
        status:
          $ref: '#/components/schemas/Status'
    StateA:
      allOf:
        - $ref: '#/components/schemas/ParentState'
        - type: object
          properties:
            otherA: 
              type: string
    StateB:
      allOf:
        - $ref: '#/components/schemas/ParentState'
        - type: object
          properties:
            otherB: 
              type: string

based on the discriminatedOneOf test, but wasn't able to get a working solution in the actual code.

Also a question: is the discriminatedOneOf models.kt output correct? It seems like the public object StateA: State is just an interface and doesn't contain the Status enum anywhere.

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

No branches or pull requests

1 participant