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

Support anyOf from schema definition #18

Open
Szer opened this issue Apr 3, 2020 · 0 comments
Open

Support anyOf from schema definition #18

Szer opened this issue Apr 3, 2020 · 0 comments

Comments

@Szer
Copy link
Owner

Szer commented Apr 3, 2020

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 }
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