Skip to content

BUG : allOf does not validate in version 0.13.6 #294

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
sjiekak opened this issue Feb 15, 2021 · 1 comment · Fixed by #295
Closed

BUG : allOf does not validate in version 0.13.6 #294

sjiekak opened this issue Feb 15, 2021 · 1 comment · Fixed by #295
Labels
area/unmarshalling Indicates an issue on unmarshalling area. kind/bug/confirmed

Comments

@sjiekak
Copy link

sjiekak commented Feb 15, 2021

If a component contains allOf, then there is no validation against it. It seems there is a regression introduced in version 0.13.6.

Sample

import json

from openapi_core.testing import MockRequest
from openapi_core.validation.request.validators import RequestValidator
from openapi_spec_validator.schemas import read_yaml_file
from openapi_core.shortcuts import create_spec

def test_openapi_core():
    data = json.dumps({
            'a': 15,
            'b': 30
        })

    request = MockRequest("http://localhost:8090", "post", "/validate", data=data)

    spec = create_spec(read_yaml_file("./open_api_0136_bug.yml"))

    validator = RequestValidator(spec)
    result = validator.validate(request)

    assert result.errors, f"{result.errors}"

Contents of open_api_0136_bug .yml

openapi: 3.0.1
info:
  title: all-of bug 0.1.36
  version: 2.0.0
  description:
    Sample to demonstrate all of bug in version 0.1.36

paths:
  /validate:
    post:
      summary: "test"
      description:
        just for the validation
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FooBar'
        required: true
      responses:
        200:
          description: schema is valid
        400:
          description: schema is invalid
components:
  schemas:
    ### REQUESTS ###

    FooBar:
      allOf:
        - $ref: '#/components/schemas/Foo'
        - $ref: '#/components/schemas/Bar'
      description:
        all of foo and bar
    Foo:
      required:
        - a
      type: object
      properties:
        a:
          $ref: '#/components/schemas/age'
        b:
          $ref: '#/components/schemas/age'
    Bar:
      required:
        - x
      type: object
      properties:
        x:
          $ref: '#/components/schemas/age'
    age:
      minimum: 18
      exclusiveMinimum: false
      type: integer
      description: age. Must be an adult
@p1c2u p1c2u added area/unmarshalling Indicates an issue on unmarshalling area. kind/bug/confirmed labels Feb 15, 2021
@p1c2u
Copy link
Collaborator

p1c2u commented Feb 15, 2021

@sjiekak thanks for the report.
Indeed I forgot to make one change for any type unmarshaller. That should be easy to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/unmarshalling Indicates an issue on unmarshalling area. kind/bug/confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants