Failures in oneOf, anyOf, etc, are actually in the referenced schema
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- docker, openapi, python
- 領域
- api, testing-qa
調査の方向性
Reproduce the issue with the provided OpenAPI YAML and the shown Docker command, then trace how validation handles oneOf and anyOf references. The fix is done when an invalid referenced Dog schema produces an error at components.schemas.Dog rather than at the containing oneOf or requestBody.
索引モデルが issue の本文から書いたものです。
説明
If a schema is invalid, it will cause a oneOf to fail instead of failing on its own. I discovered this while thinking optional was a valid thing.
The below is valid except I've added optional to Dog. The failure is now On instance['paths']['/pets']['patch']['requestBody'] instead of the expected ['components']['schemas']['Dog'].
paths:
/pets:
patch:
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
responses:
'200':
description: Updated
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
components:
schemas:
Dog:
type: object
optional: [ "bark" ]
properties:
bark:
type: boolean
breed:
type: string
enum: [Dingo, Husky, Retriever, Shepherd]
Cat:
type: object
properties:
hunts:
type: boolean
age:
type: integer
$ docker run -v $PWD/simple.yaml:/openapi.yaml --rm p1c2u/openapi-spec-validator /openapi.yaml
{'content': {'application/json': {'schema': {'oneOf': [{'$ref': '#/components/schemas/Cat', 'x-scope': ['file:///openapi.yaml']}, {'$ref':'#/components/schemas/Dog', 'x-scope': ['file:///openapi.yaml']}]}}}} is not valid under any of the given schemas
Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^\\/']['patternProperties']['^(get|put|post|delete|options|head|patch|trace)$']['properties']['requestBody']:
{'oneOf': [{'$ref': '#/definitions/RequestBody'},
{'$ref': '#/definitions/Reference'}]}
On instance['paths']['/pets']['patch']['requestBody']:
{'content': {'application/json': {'schema': {'oneOf': [{'$ref': '#/components/schemas/Cat',
'x-scope': ['file:///openapi.yaml']},
{'$ref': '#/components/schemas/Dog',
'x-scope': ['file:///openapi.yaml']}]}}}}
- 主要言語
- Python
- スター
- 409
- フォーク
- 73
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-openapi/openapi-spec-validator のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 30/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
python-openapi/openapi-spec-validator#400 · コメント 1 件 ·
-
kind/bug/confirmed
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
python-openapi/openapi-spec-validator#373 · コメント 1 件 ·
python-openapi/openapi-spec-validator の 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