openapi-generators / openapi-generators/openapi-python-client
`default` property sibling to a `$ref` is ignored
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 2k
- フォーク
- 293
- 平均マージ
- 34分
- マージ済み PR(30日)
- 1
説明
Describe the bug
default property sibling to a $ref is ignored. OAS 3.1.X relies on JSON Schema 2020-12 which does not include the requirement that sibling properties to $ref should be ignored.
OpenAPI Spec File
{
"openapi": "3.1.0",
"info": {
"title": "title",
"summary": "summary",
"description": "description",
"version": "0.0.1"
},
"paths": {
"/": {
"get": {
"parameters": [
{
"name": "default_lost1",
"required": false,
"schema": {
"$ref": "#/components/schemas/String",
"default": "lost"
}
},
{
"name": "default_lost2",
"required": false,
"schema": {
"$ref": "#/components/schemas/DefaultString"
}
},
{
"name": "default_lost3",
"schema": {
"allOf": [
{
"$ref": "#/components/schemas/DefaultString"
}
]
}
},
{
"name": "default_kept",
"schema": {
"allOf": [
{
"$ref": "#/components/schemas/String"
}
],
"default": "kept"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {}
}
}
}
}
},
"components": {
"schemas": {
"String": {
"type": "string"
},
"DefaultString": {
"type": "string",
"default": "component_default"
}
}
}
}
Desktop (please complete the following information):
- OS: macOS 26.4.1
- Python Version: 3.11.13
- openapi-python-client version: 0.28.3
Additional context
The previous schema generates code like this:
def _get_kwargs(
*,
body: Object,
default_lost1: str | Unset = UNSET,
default_lost2: str | Unset = UNSET,
default_lost3: str | Unset = UNSET,
default_kept: str | Unset = 'kept',
) -> dict[str, Any]:
I would expect all defaults to be kept.
If anything else is needed I will be more than happy to provide it. Thank you for your time!
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、報告にある OpenAPI 3.1 仕様で問題を再現し、生成された _get_kwargs の出力を確認します。直接の $ref sibling、参照されるスキーマ、allOf ラッパーについて、スキーマのデフォルト値がどのように処理されるかを追跡します。生成されたクライアントで component_default を含む 4 つすべてのデフォルト値が保持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 68/100