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