openapi-generators / openapi-generators/openapi-python-client

`anyOf` in responses generates invalid body parser

オープン
#1,263 コメント 0 件 リアクション 5 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
2k
フォーク
293
平均マージ
34分
マージ済み PR(30日)
1

説明

Describe the bug
When a response media type has an anyOf schema, the generated code does not parse it properly/is not valid. (see add'l context)
OpenAPI Spec File
https://gist.github.com/nkrishnaswami/8c4a2068d8ac59cab153136a6069b44d

Desktop (please complete the following information):

  • OS: macOS 15.6
  • Python Version: 3.12.8
  • openapi-python-client version: git revision 13bf2e8

Additional context

        def _parse_response_200(data: object) -> Union["Response200", Literal["Why have a fixed response? I dunno"]]:
            response_200_type_0 = cast(Literal["Why have a fixed response? I dunno"], data)
            if response_200_type_0 != "Why have a fixed response? I dunno":
                raise ValueError(
                    f"response_200_type_0 must match const 'Why have a fixed response? I dunno', got '{response_200_type_0}'"
                )
            return response_200_type_0
            if not isinstance(data, dict):
                raise TypeError()
            response_200_type_1 = Response200.from_dict(data)

            return response_200_type_1

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Issue にリンクされている OpenAPI Spec File から始め、anyOf を使用するレスポンススキーマについて、生成された parse_response_200 の例を再現します。生成された parser の分岐を比較し、出力が有効で、fixed-value と Response200 の両方の選択肢をパースできることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
openapi, python
領域
api, tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。