Open segfault87 opened 4 months ago
Hi @segfault87 thanks for the report.
Mutual exclusion is not something that should be checked by validation tool. Validation tools just make sure your requirements are met. Is up to user how he design his requirements. Tools shouldn't forbid to make mutual exclusion requirement like interest > 10 and < 1
What you need is probably unevaluatedProperties which part of OpenAPI 3.1
components:
schemas:
Base:
required:
- foo
type: object
properties:
foo:
type: string
nullable: false
Derived:
type: object
unevaluatedProperties: false
allOf:
- $ref: '#/components/schemas/Base'
- type: object
required:
- bar
properties:
bar:
type: string
nullable: false
Actual Behavior
If
additionalProperties: false
is declared in components and being combined into one byallOf
, validation unconditionally fails.Let's say we have following OpenAPI spec:
This spec compiles without any problem. But when validating actual request with this spec, validator fails with following error message:
Expected Behavior
I think openapi-core should behave one of following:
additionalProperties: false
in context of union types (allOf
) at schema lvel.Steps to Reproduce
Validate
{"foo": "-", "bar": "-"}
with spec supplied above.OpenAPI Core Version
0.19.0
OpenAPI Core Integration
pydantic
Affected Area(s)
validation
References
No response
Anything else we need to know?
No response
Would you like to implement a fix?
Yes