[Bug]: Mutual exclusion by use of `additionalProperties: false` across union types
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- python
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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
- 主要語言
- Python
- 星號
- 368
- 分支
- 140
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python-openapi/openapi-core 的其他 Issue
-
kind/bug
難度 2/5 1-3 小時 新手友好度 68/100
python-openapi/openapi-core#1188 · 2 則留言 ·
-
kind/bug
難度 3/5 1-2 天 新手友好度 68/100
python-openapi/openapi-core#1225 · 2 則留言 ·
-
kind/bug
難度 3/5 1-2 天 新手友好度 76/100
python-openapi/openapi-core#1212 ·
-
kind/bug
難度 3/5 1-2 天 新手友好度 68/100
python-openapi/openapi-core#1210 ·
-
kind/bug kind/bug/confirmed
難度 3/5 1-2 天 新手友好度 58/100
python-openapi/openapi-core#1180 · 3 則留言 ·
查看 python-openapi/openapi-core 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 75/100
anthropics/skills#1811 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
speaches-ai/speaches#678 ·
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
datalayer/mcp-compose#42 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
conda-forge/spacy-feedstock#177 ·
-
難度 2/5 1-3 小時 新手友好度 70/100
UKGovernmentBEIS/inspect_evals#2523 ·