Issue with unevaluatedProperties and allOf and arrays

Aperta
#1,026 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 6 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

Non vengono menzionati file del repository, test o punti di ingresso. Inizia eseguendo gli schemi e i dati di istanza forniti tramite il validator, quindi isola il comportamento di unevaluatedProperties all’interno degli elementi dell’array allOf. Il lavoro è completo quando viene determinato se il rifiuto segnalato di Nestedppty è previsto o se si tratta di un difetto del validator, con un test di regressione mirato se si tratta di un difetto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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 ?

Lingua principale
Python
Stelle
5k
Fork
741
Merge medio
4g 17h
PR unite (30g)
6

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-jsonschema/jsonschema

Tutte le issue di python-jsonschema/jsonschema

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.