dandi / dandi/dandi-schema

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

Open
#75 13 comments 0 reactions 1 assignee Claimed by @candleindark View on GitHub
Dominant language
Python
Stars
7
Forks
15
PR merge metrics
No merged PRs in 30d

Description

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 https://github.com/koumoul-dev/vuetify-jsonschema-form/pull/284#issuecomment-895471591 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.