Skip to content

Support anyOf from schema definition #18

@Szer

Description

@Szer

anyOf could be encoded via tupling options

    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
            hunts:
              type: boolean
          required: 
            - pet_type

could be encoded like

type PetByAge =
  { age: int
    nickname: string }

type PetByType = 
  { pet_type: string
    hunts: bool }

type ``PetByAge or PetByType`` =
  { PetByAge: PetByAge option
    PetByType: PetByType option }

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