Skip to content

Support for schema anyOf #101

@yujinyuz

Description

@yujinyuz

Based on the specs here:

https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/

Given

paths:
  /pets:
    patch:
      requestBody:
        content:
          application/json:
            schema:
              anyOf:
                - $ref: '#/components/schemas/PetByAge'
                - $ref: '#/components/schemas/PetByType'
      responses:
        '200':
          description: Updated
components:
  schemas:
    PetByAge:
      type: object
      properties: 
        age: 
          type: integer
        nickname: 
          type: string
      required:
        - age
          
    PetByType:
      type: object
      properties:
        pet_type:
          type: string
          enum: [Cat, Dog]
        hunts:
          type: boolean
      required: 
        - pet_type

The following JSON response should be valid:

{
  "pet_type": "Cat",
  "hunts": true
}
{
  "nickname": "Fido",
  "pet_type": "Dog",
  "age": 4
}

@Dorthu would this be hard to implement? I'm trying to dive in to the code base. What do I need to do to in order to make this work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions