`apispec` ignores `oneOf` from `marshmallow-oneofschema`

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

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

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

  • #1027 @infraAnchor による — マージされずにクローズ
  • #1082 @ansh-rohilla による — マージされずにクローズ

評価

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

調査の方向性

ソースファイルやテストパスは指定されていないため、まず apispec における marshmallow-oneofschema の処理箇所を探し、関連するスキーマ生成テストを読んでください。AerthlingsShopOffer の例を再現し、その後、oneOf と両方の具体的な offer スキーマが出力されることを確認するリグレッションカバレッジを追加してください。

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

説明

I need oneOf in my schema:

class AerthlingsShopOffer(OneOfSchema):
    """Polymorphic offer type discriminated by the 'type' field."""
    type_field = "type"
    type_schemas = {
        "character": AerthlingsCharacterOffer,
        "mutation_point": AerthlingsMpOffer,
    }

Marshmallow doesn't seem to support this. Fortunately, there is an extension, marshmallow-oneofschema. Unfortunately, when presented with the class above, apispec silently ignores it, producing

            "AerthlingsShopOffer": {
                "type": "object",
                "properties": {}
            },

and omitting AerthlingsCharacterOffer and AerthlingsMpOffer entirely.

I have a fix for this, but I think it requires discussion, and I have not yet written a unit test for it. If you think this is worth doing, I can complete the work and submit a PR. If not, that is no problem for me; I can continue to use my forked apispec in my own project.

主要言語
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 を短くまとめたダイジェスト。