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