Closed
Description
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