Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vyakoviv-vs opened this issue Mar 7, 2019 · 0 comments
Labels
area/schema Indicates an issue on schema area

Comments

@vyakoviv-vs
Copy link

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
@p1c2u p1c2u added the area/schema Indicates an issue on schema area label Sep 5, 2019
@p1c2u p1c2u closed this as completed Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/schema Indicates an issue on schema area
Projects
None yet
Development

No branches or pull requests

2 participants