Skip to content

Response validation does not work in case response is an array of oneOf objects #115

Closed
@vyakoviv-vs

Description

@vyakoviv-vs

Hi. I am trying to validate a response which is an array of objects and this case does not work properly.

spec:

paths:
  /one_of:
    get:
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cont'

components:
  schemas:
    Cont:
      type: array
      items:
        oneOf:
        - $ref: '#/components/schemas/Obj1'
        - $ref: '#/components/schemas/Obj2'

    Obj1:
      type: object
      properties:
        a:
          type: string

    Obj2:
      type: object
      properties:
        b:
          type: string

If response is [{'a': '1'}, {'c': '2'}] - validator does not raise SchemaValidationError.
Expecting that {'c': '2'} is rejected.

openapi_core-0.7.1
openapi_spec_validator-0.2.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/schemaIndicates an issue on schema area

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions