Marshmallow’s Nested fields with a restricted schema steal the full schema’s registry spot

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

メンテナーはふだん 1 日以内に返信

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

評価

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

調査の方向性

src/apispec/ext/marshmallow/openapi.py の108行目付近から始め、制限された Nested フィールドを使った FooSchema の例で問題を再現してください。FooSchema を登録しても、制限されたフィールドだけで BarSchema が予約されないこと、また後続の登録で完全なスキーマが保持されることを確認してください。

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

説明

If we e.g. have a marshmallow Schema like this:

from marshmallow_sqlalchemy import fields, SQLAlchemyAutoSchema

class FooSchema(SQLAlchemyAutoSchema):
	parent = fields.Nested("BarSchema", only=("id", "name"))

and call spec.components.schema('Foo', schema=FooSchema), then “BarSchema” gets registered as having only the fields id and name, and subsequent tries to register the real thing fail.

The problem lies here:

https://github.com/marshmallow-code/apispec/blob/d418e3efa27f799ae3dabbdbb00ccd07eb10ce07/src/apispec/ext/marshmallow/openapi.py#L108

As that function somehow doesn’t give us something useful. Also it should first modify names for schemas where schema.only is not None before it modifies schemas where schema.only is None.

主要言語
Python
スター
1.2k
フォーク
210
平均マージ
2日 1時間
マージ済み PR(30日)
4

環境構築

はじめの一歩

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

marshmallow-code/apispec のほかの issue

marshmallow-code/apispec の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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