`default` property sibling to a `$ref` is ignored
还没有人认领这个 Issue。
评估
调研方向
首先使用报告中的 OpenAPI 3.1 规范重现该问题,并检查生成的 _get_kwargs 输出。跟踪直接 $ref sibling、被引用的 schema 以及 allOf wrapper 的 schema 默认值处理方式。生成的客户端保留全部四个默认值(包括 component_default)即表示完成。
由索引模型根据 Issue 内容生成。
描述
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!
- 主要语言
- Python
- 星标
- 2k
- 派生
- 293
- 平均合并
- 34 分钟
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openapi-generators/openapi-python-client 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 3/5 1-2 天 新手友好度 72/100
openapi-generators/openapi-python-client#1451 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 52/100
-
难度 3/5 1-2 天 新手友好度 64/100
openapi-generators/openapi-python-client#1435 · 1 条评论 ·
查看 openapi-generators/openapi-python-client 的全部 Issue
相似的 Issue
-
triage/confirmed
难度 2/5 1-3 小时 新手友好度 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
难度 1/5 1 小时以内 新手友好度 92/100
NousResearch/hermes-agent#118866 ·
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
-
bug
难度 2/5 1-3 小时 新手友好度 82/100