openapi-generators / openapi-generators/openapi-python-client
Schema processing fails when "allOf" references to nullable object
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 2k
- 派生
- 293
- 平均合并
- 34 分钟
- 30 天内合并 PR
- 1
描述
Describe the bug
When using a schema that contains an "allOf" reference to a nullable object, the generation fails with the message "Cannot take allOf a non-object".
OpenAPI Spec File
Document to recreate:
openapi: 3.0.1
info:
title: Title
description: Description
version: 1.0.0
servers:
- url: /api
paths:
/item:
get:
operationId: item
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Item'
components:
schemas:
RelatedItemSuper:
type: object
nullable: true
properties:
propertyA:
type: string
RelatedItem:
type: object
allOf:
- $ref: '#/components/schemas/RelatedItemSuper'
- type: object
properties:
propertyB:
type: string
Item:
type: object
nullable: false
properties:
key:
type: string
relatedItem:
$ref: '#/components/schemas/RelatedItem'
A real world example can be found here.
Desktop (please complete the following information):
- OS: Linux
- Python Version: 3.11.2
- openapi-python-client version: 0.21.1
Additional context
Changing "nullable" to "false" on "RelatedItem" in the above example works but does not seem to be a suitable solution as the construct used is legitimate, or is it not?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,针对提供的 OpenAPI 3.0.1 文档运行 openapi-python-client 0.21.1,并跟踪发出 "Cannot take allOf a non-object." 的 schema 处理路径。使用带有 nullable 的 RelatedItemSuper 和 RelatedItem 定义作为回归用例;完成的标准是客户端生成成功,且不需要将 nullable 更改为 false。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- openapi, python
- 领域
- api, tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100