openapi-generators / openapi-generators/openapi-python-client
Model Composition with ‘allOf’ Is Missing Fields
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 2k
- 分支
- 293
- 平均合併
- 34 分鐘
- 30 天內合併 PR
- 1
描述
Describe the bug
Using a composition model (https://spec.openapis.org/oas/v3.0.4.html#models-with-composition) does not generate the target type but only the underlying type. For a type A which consists of the fields of B and some additional fields, only B is generated. Furthermore, A is replaced by B.
The spec below generates the following function:
def sync_detailed(
*,
client: AuthenticatedClient | Client,
body: Base,
) -> Response[Any]: ...
I would expect that the model Network is generated and used instead of Base. The Network model should include the field of Base and the field non_base_field.
OpenAPI Spec File
openapi: 3.0.0
info:
title: Service
version: 0.0.0
paths:
/widgets:
get:
responses:
"200":
description: The request has succeeded.
content:
application/json:
schema:
nullable: true
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Network"
components:
schemas:
Base:
type: object
required:
- base_field
properties:
base_field:
type: string
Network:
type: object
required:
- non_base_field
properties:
non_base_field:
type: string
allOf:
- $ref: "#/components/schemas/Base"
Desktop (please complete the following information):
- OS: Linux
- Python Version: 3.13.11
- openapi-python-client version: 0.28.1
Additional context
Add any other context about the problem here.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先執行提供的 OpenAPI 規格,並比較產生的 Network 和 Base 模型以及 sync_detailed 簽章。追蹤模型和端點產生過程中如何處理 allOf schema。完成標準是:產生的 Network 包含兩個欄位,端點使用 Network 而不是 Base,並且有一個回歸測試涵蓋此組合。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- openapi, python
- 領域
- api, tooling
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100