[Bug]: Mutual exclusion by use of `additionalProperties: false` across union types
まだ誰も着手していません。
評価
- 難易度
- 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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value オープン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
-
documentation help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
simonw/sqlite-utils#872 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100