Forum Discussion

kip's avatar
kip
New Contributor
6 years ago
Solved

schema via oneOf with additional common properties

Hey everyone,   I am trying to achieve the following, but with the commented lines uncommented. Uncommented it is not syntactically correct, but semantically I am trying to add BodyCommon's prope...
  • HKosova's avatar
    6 years ago

    You need an "allOf" of BodyCommon and "oneOf":

    components:
      schemas:
        SomeClientPostBody:
          required: true
          content:
            application/json:
              schema:
                allOf:
                  - oneOf:
                      - $ref: "#/components/schemas/BodyTypeA"
                      - $ref: "#/components/schemas/BodyTypeB"
                  - $ref: "#/components/schemas/BodyCommon"