# Test the mainline function of OpenAPI v3 specification.
#
# This includes the XML part of the OpenAPI specification, as found at
# https://swagger.io/docs/specification/data-models/representing-xml/
#
# Specifically, these tests are intended to include:
#   - namespaces
#   - arrays
#     - as the whole response body
#     - within another object
#     - wrapping and renaming to and from camelCase and snake_case
#   - objects
#     - renaming to and from camelCase and snake_case
#   - UUIDs
#   - Octet Streams

openapi: 3.0.1
info:
  title: My title
  description: API under test
  version: 1.0.7
paths:
  /xml:
    post:
      summary: Post an array
      description: ''
      requestBody:
        content:
          application/xml:
            schema:
              $ref: '#/components/schemas/xml_array'
      responses:
        '201':
          description: 'OK'
        '400':
          description: Bad Request
    put:
      requestBody:
        content:
          application/xml:
            schema:
              $ref: '#/components/schemas/xml_object'
      responses:
        '201':
          description: 'OK'
        '400':
          description: Bad Request
  /paramget:
    get:
      summary: Get some stuff with parameters.
      parameters:
      - description: The stuff to get
        explode: false
        in: query
        name: uuid
        required: false
        schema:
          $ref: "#/components/schemas/UuidObject"
        style: form
      - description: Some object to pass as query parameter
        explode: false
        in: query
        name: someObject
        required: false
        schema:
          $ref: "#/components/schemas/ObjectParam"
        style: form
      - description: Some list to pass as query parameter
        explode: false
        in: query
        name: someList
        required: false
        schema:
          $ref: "#/components/schemas/MyIDList"
        style: form
      responses:
        200:
          description: JSON rsp
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/anotherXmlObject"
  /multiget:
    get:
      summary: Get some stuff.
      responses:
        200:
          description: JSON rsp
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/anotherXmlObject"
        201:
          description: XML rsp
          content:
            application/xml:
              schema:
                type: object
                properties:
                  foo:
                    type: string
        202:
          description: octet rsp
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        203:
          description: string rsp
          content:
            text/plain:
              schema:
                type: string
        204:
          description: Duplicate Response long text. One.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/anotherXmlObject"
        205:
          description: Duplicate Response long text. Two.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/anotherXmlObject"
        206:
          description: Duplicate Response long text. Three.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/anotherXmlObject"
  /xml_other:
    post:
      requestBody:
        content:
          text/xml:
            schema:
              $ref: '#/components/schemas/anotherXmlObject'
      responses:
        '201':
          description: 'OK'
          content:
            text/xml:
              schema:
                $ref: "#/components/schemas/anotherXmlObject"
        '400':
          description: Bad Request
    put:
      requestBody:
        content:
          application/xml:
            schema:
              $ref: '#/components/schemas/anotherXmlArray'
      responses:
        '201':
          description: 'OK'
        '400':
          description: Bad Request
  /xml_extra:
    post:
      requestBody:
        content:
          application/xml:
            schema:
              $ref: '#/components/schemas/duplicate_xml_object'
      responses:
        '201':
          description: 'OK'
        '400':
          description: Bad Request
  /uuid:
    get:
      responses:
        200:
          description: Duplicate Response long text. One.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UuidObject"
  /required_octet_stream:
    put:
      requestBody:
        required: true
        content:
          application/octet-stream:
            schema:
              type: string
              format: byte
      responses:
        '200':
          description: 'OK'
  /readonly_auth_scheme:
    get:
      security:
        - authScheme: ["test.read"]
      responses:
        200:
          description: Check that limiting to a single required auth scheme works
  /multiple_auth_scheme:
    get:
      security:
        - authScheme: ["test.read", "test.write"]
      responses:
        200:
          description: Check that limiting to multiple required auth schemes works
  /untyped_property:
    get:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ObjectUntypedProps'
      responses:
        200:
          description: Check that untyped properties works
  /responses_with_headers:
    get:
      responses:
        '200':
          description: 'Success'
          content:
            'application/json':
              schema:
                type: String
          headers:
            Success-Info:
              schema:
                type: String
              required: true
            Bool-Header:
              schema:
                type: bool
            Object-Header:
              schema:
                $ref: "#/components/schemas/ObjectHeader"
        '412':
          description: Precondition Failed
          headers:
            Further-Info:
              schema:
                type: String
            Failure-Info:
              schema:
                type: String
  /mandatory-request-header:
    get:
      parameters:
        - name: X-Header
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Success
  /register-callback:
    post:
      parameters:
        - name: url
          in: query
          required: true
          schema:
            type: string
            format: uri
      callbacks:
        callback:
          '{$request.query.url}/callback':
            post:
              responses:
                '204':
                  description: OK
      responses:
        '204':
          description: OK
  /callback-with-header:
    post:
      parameters:
        - name: url
          in: query
          required: true
          schema:
            type: string
            format: uri
      callbacks:
        callback:
          '{$request.query.url}/callback-with-header':
            post:
              parameters:
                - name: Information
                  in: header
                  schema:
                    type: string
              responses:
                '204':
                  description: OK
      responses:
        '204':
          description: OK
  /rfc7807:
    get:
      responses:
        '204':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObjectWithArrayOfObjects'
        '404':
          description: NotFound
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ObjectWithArrayOfObjects'
        '406':
          description: NotAcceptable
          content:
            application/problem+xml:
              schema:
                $ref: '#/components/schemas/ObjectWithArrayOfObjects'
  /merge-patch-json:
    get:
      responses:
        200:
          description: merge-patch+json-encoded response
          content:
            application/merge-patch+json:
              schema:
                $ref: "#/components/schemas/anotherXmlObject"
  /enum_in_path/{path_param}:
    get:
      parameters:
        - name: path_param
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/StringEnum'
      responses:
        '200':
          description: Success
  /override-server:
    get:
      servers:
        - "url": "/override"
      responses:
        "204":
          description: Success.
  /complex-query-param:
    get:
      parameters:
        - name: list-of-strings
          in: query
          schema:
            type: array
            items:
              $ref: '#/components/schemas/StringObject'
      responses:
        '200':
          description: Success
  /repos/{repoId}:
    parameters:
      - in: path
        name: repoId
        schema:
          type: string
        required: true
    get:
      tags: [repo, Info]
      operationId: GetRepoInfo
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StringObject"
  /repos:
    post:
      tags: [Repo]
      operationId: CreateRepo
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ObjectParam"
            example:
              # Properties of a referenced object
              requiredParam: true
      responses:
        '200':
          description: Success
  /one-of:
    get:
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                oneOf:
                  - type: integer
                  - type: array
                    items:
                      type: string
  /any-of:
    get:
      parameters:
        - name: any-of
          in: query
          description: list of any of objects
          schema:
            type: array
            items:
              $ref: '#/components/schemas/AnyOfObject'
            minItems: 1
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AnyOfObject"
        '201':
          description: AlternateSuccess
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/12345AnyOfObject"
        '202':
          description: AnyOfSuccess
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: "#/components/schemas/StringObject"
                  - $ref: "#/components/schemas/UuidObject"
  /json-complex-query-param:
    get:
      parameters:
        - name: list-of-strings
          in: query
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/StringObject'
      responses:
        '200':
          description: Success

components:
  securitySchemes:
    authScheme:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: 'http://example.org'
          tokenUrl: 'http://example.org'
          scopes:
            test.read: Allowed to read state.
            test.write: Allowed to change state.
  schemas:
    AnyOfProperty:
      description: Test containing an anyOf object
      properties:
        requiredAnyOf:
          $ref: '#/components/schemas/AnyOfObject'
        optionalAnyOf:
          $ref: '#/components/schemas/12345AnyOfObject'
      required:
      - requiredAnyOf
    AnyOfObject:
      description: Test a model containing an anyOf
      anyOf:
      - type: string
        enum:
        - FOO
        - BAR
      - type: string
        description: Alternate option
    12345AnyOfObject:
      description: Test a model containing an anyOf that starts with a number
      anyOf:
      - type: string
        enum:
        - FOO
        - BAR
        - "*"
      - type: string
        description: Alternate option
    EnumWithStarObject:
      description: Test a model containing a special character in the enum
      type: string
      enum:
      - FOO
      - BAR
      - "*"
    UuidObject:
      description: Test a model containing a UUID
      type: string
      format: uuid
    xml_array:
      xml:
        name: CamelXmlArray
        wrapped: true
      type: array
      items:
        $ref: '#/components/schemas/xml_inner'
    xml_inner:
      type: string
      xml:
        name: camelXmlInner
    xml_object:
      title: an XML object
      description: An XML object
      type: object
      properties:
        innerString:
          type: string
        other_inner_rename:
          type: integer
      xml:
        name: camelXmlObject
        namespace: http://foo.bar
    duplicate_xml_object:
      description: An XML object
      type: object
      required:
        - inner_array
      properties:
        inner_string:
          type: string
        inner_array:
          $ref: '#/components/schemas/xml_array'
      xml:
        name: camelDuplicateXmlObject
        namespace: http://different.bar
    anotherXmlArray:
      type: array
      xml:
        wrapped: true
        name: snake_another_xml_array
      items:
        $ref: '#/components/schemas/anotherXmlInner'
    anotherXmlInner:
      type: string
      xml:
        name: snake_another_xml_inner
    anotherXmlObject:
      description: An XML object
      type: object
      properties:
        inner_string:
          type: string
      xml:
        name: snake_another_xml_object
        namespace: http://foo.bar
    ObjectWithArrayOfObjects:
      type: object
      properties:
       objectArray:
         type: array
         items:
           $ref: '#/components/schemas/StringObject'
    StringObject:
      type: string
    MyIDList:
      type:  array
      items:
        $ref: '#/components/schemas/MyID'
    MyID:
      type: integer
    ObjectUntypedProps:
      properties:
        required_untyped:
          nullable: false
        required_untyped_nullable:
          nullable: true
        not_required_untyped:
          nullable: false
        not_required_untyped_nullable:
          nullable: false
      required:
      - required_untyped
      - required_untyped_nullable
      type: object
    ObjectParam:
      type: object
      required:
        - requiredParam
      properties:
        requiredParam:
          type: boolean
        optionalParam:
          type: integer
    ObjectHeader:
      type: object
      required:
        - requiredObjectHeader
      properties:
        requiredObjectHeader:
          $ref: '#/components/schemas/RequiredObjectHeader'
        optionalObjectHeader:
          $ref: '#/components/schemas/OptionalObjectHeader'
    RequiredObjectHeader:
      type: boolean
    OptionalObjectHeader:
      type: integer
    AdditionalPropertiesWithList:
      type: object
      maxProperties: 1
      additionalProperties:
        type: list
        items:
          type: string
    NullableTest:
      type: object
      required:
      - nullable
      properties:
        nullable:
          type: string
          nullable: true
        nullableWithNullDefault:
          type: string
          nullable: true
          default: null
        nullableWithPresentDefault:
          type: string
          nullable: true
          default: "default"
        nullableWithNoDefault:
          type: string
          nullable: true
        nullableArray:
          type: array
          items:
            type: string
          nullable: true
    StringEnum:
      type: string
      enum:
        - FOO
        - BAR
    Ok:
      type: string
    Error:
      type: string
    Err:
      type: string
    Result:
      type: string
