openapi: 3.0.0
info:
  title: one-of Models
  version: 1.0.0
  description: Spec containing model composition using one-of. Checkout the model
    definition under the RESPONSE section
paths:
  /one-of/employee:
    get:
      tags:
        - One Of Schema Model
      summary: Schema defined using one-of
      operationId: empDetails
      responses:
        "200":
          description: Checkout the model tab to view object schemas defined using one-of
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/employee"
  /one-of/schema:
    get:
      tags:
        - One Of Schema Model
      summary: ONE-OF schema example generation test
      operationId: empDetails
      responses:
        "200":
          description: Should generate 2 examples one with each option and the properties
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      option1_PropA:
                        type: string
                      option1_PropB:
                        type: string
                  - type: object
                    properties:
                      option2_PropX:
                        type: string
                properties:
                  prop1:
                    type: string
                  prop2:
                    type: string
                    minLength: 10

tags:
  - name: Employee Details
    description: Employee Details
components:
  schemas:
    employee:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          description: Employee ID
        employee:
          description: Employee Details (Worker or Manager)
          oneOf:
            - $ref: "#/components/schemas/manager"
            - $ref: "#/components/schemas/worker"
    manager:
      title: Manager
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          description: Name of employee
        directReports:
          type: integer
          description: Count of direct reports
        managePower:
          oneOf:
            - $ref: "#/components/schemas/peopleManager"
            - $ref: "#/components/schemas/costManager"
    worker:
      title: Worker
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          description: Name of employee
        managerName:
          type: string
          description: Name of manager
    peopleManager:
      title: People Manager
      type: object
      additionalProperties: false
      properties:
        level:
          type: integer
        maxDirectReportsAllowed:
          type: string
          description: No of people the level can manage
    costManager:
      title: Cost Manager
      type: object
      additionalProperties: false
      properties:
        level:
          type: integer
        canAuthorizeMaxAmount:
          type: number
          description: Maximum amount that this level can authorize