openapi-generators / openapi-generators/openapi-python-client
Schema processing fails when "allOf" references to nullable object
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 2k
- フォーク
- 293
- 平均マージ
- 34分
- マージ済み PR(30日)
- 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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された OpenAPI 3.0.1 ドキュメントに対して openapi-python-client 0.21.1 を実行し、"Cannot take allOf a non-object." を出力するスキーマ処理経路を追跡します。nullable な RelatedItemSuper と RelatedItem の定義を回帰ケースとして使用します。nullable を false に変更する必要なくクライアント生成が成功すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- openapi, python
- 領域
- api, tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100