Skip to content

oneOf with discriminator on path #52

Open
@LienM

Description

@LienM

As all different types of request bodies should be processed by the same function, I was hoping to do something the following minimal example:

  /api/{item_type}:
    post:
      parameters:
        - in: path
          name: item_type
          required: true
          schema:
            type: string  
      requestBody:
        $ref: '#/components/requestBodies/object'
        required: true
      responses:
        '201':
          description: Item created
components:
  requestBodies:
    object:
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/Movie'
              - $ref: '#/components/schemas/Program'
            discriminator:
              propertyName: item_type
  schemas:
    Movie:
      type: object
    Program:
      type: object

Essentially, I want one function, to parse all item_types, but still ensure validation based on item_type in the path. However, I can create a Movie with the properties of Program.
Is this not the intended use? Or is there no discriminator validation on parameters specified in the path?

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions