[Bug]: Mutual exclusion by use of `additionalProperties: false` across union types
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- python
- Domaine
- api, backend-api-design
Piste de recherche
Start by reproducing validation of {"foo": "-", "bar": "-"} with the OpenAPI specification in the issue using the pydantic integration. Trace the validation path for allOf schemas with additionalProperties: false, then determine whether combined validation should succeed or the schema should be rejected and add coverage for the selected behavior.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Actual Behavior
If additionalProperties: false is declared in components and being combined into one by allOf, validation unconditionally fails.
Let's say we have following OpenAPI spec:
---
openapi: 3.0.0
info:
title: Test API
description: Test
version: 0.0.1
servers:
- url: https://www.example.com
paths:
/test:
post:
summary: test
description: test
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Derived'
required: true
responses:
"200":
description: Success
components:
schemas:
Base:
required:
- foo
type: object
properties:
foo:
type: string
nullable: false
additionalProperties: false
Derived:
type: object
allOf:
- $ref: '#/components/schemas/Base'
- type: object
required:
- bar
properties:
bar:
type: string
nullable: false
additionalProperties: false
This spec compiles without any problem. But when validating actual request with this spec, validator fails with following error message:
RequestValidationResult(errors=[InvalidSchemaValue(value={'bar': '2',
'foo': '1'},
type='object',
schema_errors=(<ValidationError: "Additional properties are not allowed ('bar' was unexpected)">,
<ValidationError: "Additional properties are not allowed ('foo' was unexpected)">))],
body=None,
parameters=Parameters(query={},
header={},
cookie={},
path={}),
security={})
Expected Behavior
I think openapi-core should behave one of following:
- Validation should be successful
- Or forbid use of
additionalProperties: falsein 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
- Langage dominant
- Python
- Étoiles
- 368
- Forks
- 140
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python-openapi/openapi-core
-
kind/bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
python-openapi/openapi-core#1188 · 2 commentaires ·
-
kind/bug
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
python-openapi/openapi-core#1225 · 2 commentaires ·
-
kind/bug
Difficulté 3/5 1-2 jours Accessibilité débutants 76/100
python-openapi/openapi-core#1212 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value Ouvertekind/bug
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
python-openapi/openapi-core#1210 ·
-
kind/bug kind/bug/confirmed
Difficulté 3/5 1-2 jours Accessibilité débutants 58/100
python-openapi/openapi-core#1180 · 3 commentaires ·
Toutes les issues de python-openapi/openapi-core
Issues similaires
-
documentation help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 90/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 90/100
simonw/sqlite-utils#872 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100