oneOf fails in post parameter

Open
#46 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
openapi, python

Research direction

Start by reproducing the failure with the Swagger oneOf example and the YAML source spec included in the issue. Trace validation of the OpenAPI 3 requestBody and its nested schema oneOf, then verify that this valid specification is accepted without the reported oneOf error.

Written by the indexing model from the issue text.

Description

Try validating against the schema from https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/

Got error of

Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^/']['properties']['patch']['properties']['requestBody']:
    {'oneOf': [{'$ref': '#/definitions/requestBody'},
               {'$ref': '#/definitions/reference'}]}

Source spec file

paths:
  /pets:
    patch:
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/Cat'
                - $ref: '#/components/schemas/Dog'
      responses:
        '200':
          description: Updated
components:
  schemas:
    Dog:
      type: object
      properties:
        bark:
          type: boolean
        breed:
          type: string
          enum: [Dingo, Husky, Retriever, Shepherd]
    Cat:
      type: object
      properties:
        hunts:
          type: boolean
        age:
          type: integer
Dominant language
Python
Stars
409
Forks
73
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-openapi/openapi-spec-validator

All issues in python-openapi/openapi-spec-validator

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.