openapi-generators / openapi-generators/openapi-python-client
`default` property sibling to a `$ref` is ignored
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 2k
- Fork
- 293
- Merge trung bình
- 34 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
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!
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện vấn đề với đặc tả OpenAPI 3.1 trong báo cáo và kiểm tra đầu ra _get_kwargs được tạo. Theo dõi cách các giá trị mặc định của schema được xử lý đối với các sibling $ref trực tiếp, các schema được tham chiếu và các wrapper allOf. Được xem là hoàn tất khi cả bốn giá trị mặc định, bao gồm component_default, đều được giữ lại trong client được tạo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- tooling
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 68/100