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

Model Composition with ‘allOf’ Is Missing Fields

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

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

主要言語
Python
スター
2k
フォーク
293
平均マージ
34分
マージ済み PR(30日)
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.

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

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

はじめの一歩

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

調査の方向性

まず、提供されている OpenAPI spec を実行し、生成された Network モデルと Base モデル、および sync_detailed のシグネチャを比較します。モデルとエンドポイントの生成時に allOf スキーマがどのように処理されるかを追跡します。Network が両方のフィールド付きで生成され、エンドポイントが Base ではなく Network を使用し、この構成を対象とする回帰テストが追加されれば完了です。

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

評価

技術スタック
openapi, python
領域
api, tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

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

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