Issue with unevaluatedProperties and allOf and arrays

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

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

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

評価

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

調査の方向性

リポジトリのファイル、テスト、エントリポイントについては何も言及されていません。まず、提供されたスキーマとインスタンスデータを validator で実行し、次に allOf 配列の各要素内で unevaluatedProperties がどのように動作するかを切り分けてください。完了条件は、報告された Nestedppty の拒否が想定どおりなのか、validator の不具合なのかを特定することです。不具合である場合は、焦点を絞った回帰テストを追加してください。

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

説明

Needs Simplification

I need to have a schema allowing extra fields only under one specific node (ExtensionProperties).
It works well using "additionalProperties": false with simple schemas:

{
    "$schema": "https://json-schema.org/draft/2019-09/schema#",
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "rootppty": {
            "type": "string"
        },
        "ExtensionProperties": {
            "type": "object"          
        }
    }
}

This data is ok

{
  "rootppty": "ad",
   "ExtensionProperties": {
      "whatever": "you want"
    }
}

and this one fails validation as expected

{
  "rootppty": "ok",
  "other": "fail",
   "ExtensionProperties": {
      "whatever": "you want"
    }
}

But when I have some allOf, I need to use "unevaluatedProperties": false as explained in the documentation
It works well with simple schemas

{
    "$schema": "https://json-schema.org/draft/2019-09/schema#",
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "rootppty": {
            "type": "string"
        },
        "data": {
          "unevaluatedProperties": false,
          "allOf": [{
            "type": "object",
            "title": "IndividualProperties",
            "properties": {
              "Nestedppty": {
                "type": "string"
              }
            }
          }
         ]
        },
        "ExtensionProperties": {
            "type": "object"          
        }
    }
}

This data fails the validation as expected (on rootppty2 and Nestedppty2)

{
  "rootppty": "ok",
  "rootppty2": "fail",
  "data": {
    "Nestedppty": "ok",
    "Nestedppty2": "fail"
  },
   "ExtensionProperties": {
      "whatever": "you want"
    }
}

But when I am adding array in the allOf part I am facing issues
This schema does not fail validation on additional fields in the array

{
    "$schema": "https://json-schema.org/draft/2019-09/schema#",
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "rootppty": {
            "type": "string"
        },
        "data": {
            "unevaluatedProperties": false,
            "allOf": [{
                    "type": "object",
                    "title": "IndividualProperties",
                    "properties": {
                        "Nestedppty": {
                            "type": "string"
                        },
                        "Nestedarray": {
                            "type": "array",
                            "items": {
                                "unevaluatedProperties": false,
                                "type": "object",
                                "properties": {
                                    "additionalProperties": false,
                                    "nestedarrayInternalpty": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                }
            ]
        },
        "ExtensionProperties": {
            "type": "object"
        }
    }
}

for example this data should fail validation on nestedarrayInternalpty2

{
  "rootppty": "ok",
  "data": {
    "Nestedppty": "ok",
    "Nestedarray": [
      {"nestedarrayInternalpty": "ok"},
      {"nestedarrayInternalpty2": "should fail"}
    ]
  },
   "ExtensionProperties": {
      "whatever": "you want"
    }
}

but it fails also on Nestedppty, which should be ok
Am I doing something wrong or is there an issue when several "unevaluatedProperties": false are nested ?

主要言語
Python
スター
5k
フォーク
741
平均マージ
4日 17時間
マージ済み PR(30日)
6

環境構築

はじめの一歩

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

python-jsonschema/jsonschema のほかの issue

python-jsonschema/jsonschema の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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