Skip to content

add "unevaluatedProperties": false, (or "additionalProperties": false,) to jsonschema dump #75

Open
@yarikoptic

Description

@yarikoptic

Per my

investigative dump in slack
may be about
            "affiliation": [
                {
                    "name": "Department of Neurosurgery, Cedars-Sinai Medical Center, Los Angeles, CA, USA",
                    "schemaKey": "Affiliation",
                    "includeInCitation": false
                }
            ],
            "includeInCitation": true

Yarik  1 hour ago
we have includeInCitation for Person and Organization, not for Affiliation per se

Yarik  40 minutes ago
and "schemaVersion": "0.4.4", ... but I don't see any immediately relevant change in diff -Naur releases/0.{4.4,5.1}/published-dandiset.json

Yarik  26 minutes ago
my foo in jsonvalidation is weak -- but it seems that at least Python's validator doesn't care about "extra" attributes -- validates just fine...

Yarik  18 minutes ago
the same here (see having first bogus field in the data): https://www.jsonschemavalidator.net/s/pKySmfD1 -- all green.  So I guess we somehow missed producing those extra attributes which aren't described by the model.  But I think it might have been in the past and @satra's migration cleaned it up
dandischema/tests/data/metadata/meta_000004.json-      "name": "initiative, BRAIN",
dandischema/tests/data/metadata/meta_000004.json-      "roleName": [
dandischema/tests/data/metadata/meta_000004.json-        "dcite:Sponsor"
dandischema/tests/data/metadata/meta_000004.json-      ],
dandischema/tests/data/metadata/meta_000004.json:      "includeInCitation": false,
--
dandischema/tests/data/metadata/meta_000004old.json-      "affiliation": [
dandischema/tests/data/metadata/meta_000004old.json-        {
dandischema/tests/data/metadata/meta_000004old.json-          "name": "Department of Neurosurgery, Cedars-Sinai Medical Center, Los Angeles, CA, USA",
dandischema/tests/data/metadata/meta_000004old.json-          "schemaKey": "Organization",
dandischema/tests/data/metadata/meta_000004old.json:          "includeInCitation": false
dandischema/tests/data/metadata/meta_000004old.json-        }
dandischema/tests/data/metadata/meta_000004old.json-      ],
dandischema/tests/data/metadata/meta_000004old.json:      "includeInCitation": true
(git)lena:~/proj/dandi/dandischema[master]
$> grep -A5 '"affiliation' dandischema/tests/data/metadata/meta_000004.json | head
      "affiliation": [
        {
          "schemaKey": "Affiliation",
          "name": "Department of Neurosurgery, Cedars-Sinai Medical Center, Los Angeles, CA, USA"
        }
      ]
...
$> grep schemaVersion dandischema/tests/data/metadata/meta_000004*.json
dandischema/tests/data/metadata/meta_000004.json:  "schemaVersion": "0.4.0",
dandischema/tests/data/metadata/meta_000004old.json:  "schemaVersion": "0.3.0",
so a I  am just a bit  confused why non-old one is just 0.4.0 here

Yarik  16 minutes ago
stopping here with a question: how to make jsonschema to error out on encountering keys which are not in the model?

Yarik  9 minutes ago
HA "additionalProperties": false,  but it seems to be not "inherited", so would need to be defined for every "level" (edited) 

I think the fact that we do not restrict exported jsonschema to not allow extra attributes (fields) is what is behind the koumoul-dev/vuetify-jsonschema-form#284 (comment) and might lead to some data loss (whenever an arbitrary extra attribute is simply not accompanied with corresponding UI ) or just cause inefficiencies or crashes.

I guess we could easily add "unevaluatedProperties": false to every record thus making validation more stringent etc.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions