Parameter-level descriptions are ignored in Python SDK generation; only schema descriptions are used

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

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

評価

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

調査の方向性

issue にはソースファイルもテストも記載されていません。まず、提供された OpenAPI 3.1 の repro から Python クライアントを生成し、生成されたメソッドの引数ドキュメントを確認します。parameter.description が引数のドキュメントに使用され、スキーマの説明は型または値の形式の詳細に引き続き利用できれば完了です。

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

説明

Describe the bug
When generating a Python client, parameter documentation is taken from the parameter schema’s description, while the parameter object’s top-level description is ignored or not preferred.

OpenAPI defines description on the Parameter Object (“A brief description of the parameter…”) and separately allows description on schemas via the Schema Object / JSON Schema annotation model. These fields describe different layers of the API, but the current Python generation appears to only use the schema-level description for parameter docs. 

OpenAPI Spec File

openapi: 3.1.0
info:
  title: Description precedence repro
  version: 1.0.0

paths:
  /tasks/export:
    get:
      operationId: export_tasks
      summary: Export tasks
      parameters:
        - in: query
          name: since
          required: false
          description: Only include tasks changed after this timestamp.
          schema:
            type: integer
            format: int64
            description: Unix timestamp in milliseconds.
      responses:
        "200":
          description: OK

Desktop (please complete the following information):

  • OS: macOS Tahoe 26.3
  • Python Version: 3.10
  • openapi-python-client version: 0.28.2

Additional context
Expected behavior:

For simple parameters, generated method argument docs should prefer parameter.description, optionally appending schema.description as secondary value-format detail.

Example desired output:

def export_tasks(self, since: int | None = None) -> Response:
    """
    Args:
        since: Only include tasks changed after this timestamp.
               Unix timestamp in milliseconds.
    """

For reusable rich schemas, the split should be:

  • method argument docs from parameter.description
  • model/type docs from schema.description
  • field docs from property description

This would preserve the distinction OpenAPI makes between operation-level parameter semantics and reusable type semantics. This seems to be true for response bodies too.

Happy to work on this myself!

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

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

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

はじめの一歩

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

openapi-generators/openapi-python-client のほかの issue

openapi-generators/openapi-python-client の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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