From d8ef77aa5a5f3a696e5698969ffa0dae46d5b785 Mon Sep 17 00:00:00 2001 From: Nicolas Drebenstedt Date: Mon, 18 Dec 2023 12:42:51 +0100 Subject: [PATCH] feature/mx-1478 more model alignments (#8) - add empty arrays as defaults (`"default": []`) to list fields with no min items - consistently use `anyOf` instead of `oneOf` for union types - allow `"type": "null"` for non-required fields and set `null` as default - put `examples` and `useScheme` on the correct levels for array/union fields - update identifier pattern to match new implementation - bump version to `2.2.0` --- .pre-commit-config.yaml | 7 +- README.md | 8 +- {conceptual-model => docs}/specification.md | 0 mex/__init__.py | 3 + mex/model/__init__.py | 0 .../model}/entities/access-platform.json | 60 +++-- {schema => mex/model}/entities/activity.json | 87 ++++--- .../model}/entities/concept-scheme.json | 6 +- {schema => mex/model}/entities/concept.json | 13 +- .../model}/entities/contact-point.json | 0 .../model}/entities/distribution.json | 131 +++++++--- .../model}/entities/organization.json | 24 +- .../model}/entities/organizational-unit.json | 25 +- {schema => mex/model}/entities/person.json | 52 ++-- .../model}/entities/primary-source.json | 39 ++- {schema => mex/model}/entities/resource.json | 235 ++++++++++++------ .../model}/entities/variable-group.json | 0 {schema => mex/model}/entities/variable.json | 61 +++-- .../model}/extension/definition.json | 0 mex/model/fields/identifier.json | 12 + {schema => mex/model}/fields/link.json | 22 +- {schema => mex/model}/fields/text.json | 10 +- pyproject.toml | 13 + requirements.txt | 2 + schema/fields/identifier.json | 13 - setup.py | 11 - 26 files changed, 543 insertions(+), 291 deletions(-) rename {conceptual-model => docs}/specification.md (100%) create mode 100644 mex/__init__.py create mode 100644 mex/model/__init__.py rename {schema => mex/model}/entities/access-platform.json (74%) rename {schema => mex/model}/entities/activity.json (80%) rename {schema => mex/model}/entities/concept-scheme.json (91%) rename {schema => mex/model}/entities/concept.json (90%) rename {schema => mex/model}/entities/contact-point.json (100%) rename {schema => mex/model}/entities/distribution.json (67%) rename {schema => mex/model}/entities/organization.json (90%) rename {schema => mex/model}/entities/organizational-unit.json (84%) rename {schema => mex/model}/entities/person.json (80%) rename {schema => mex/model}/entities/primary-source.json (80%) rename {schema => mex/model}/entities/resource.json (69%) rename {schema => mex/model}/entities/variable-group.json (100%) rename {schema => mex/model}/entities/variable.json (68%) rename {schema => mex/model}/extension/definition.json (100%) create mode 100644 mex/model/fields/identifier.json rename {schema => mex/model}/fields/link.json (64%) rename {schema => mex/model}/fields/text.json (75%) create mode 100644 pyproject.toml delete mode 100644 schema/fields/identifier.json delete mode 100644 setup.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e60f59f8..62189f33 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,18 @@ fail_fast: false default_language_version: python: python3.11 -files: schema repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: - id: pretty-format-json + name: json args: [--autofix, --no-sort-keys, --indent=4, --no-ensure-ascii] + - id: check-yaml + name: yaml - id: end-of-file-fixer + name: eof - id: trailing-whitespace + name: whitespaces - id: fix-byte-order-marker + name: byte-order diff --git a/README.md b/README.md index 7af9baa4..00f597ff 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,12 @@ data Findable, Accessible, Interoperable and Reusable. ## package -The `mex-model` repository contains two models: +The `mex-model` repository contains the MEx metadata model in two formats. -- the conceptual model, which is mainly used to facilitate interoperability with other metadata schemas and models -- the json schema, which represents the conceptual model in a format that can be used for technical implementation in applications +- `/docs` contains the conceptual model, which is mainly used to facilitate + interoperability with other metadata schemas and models +- `mex/model` holds the JSON schema, which represents the conceptual model in a format + that can be used for technical implementation in applications ## license diff --git a/conceptual-model/specification.md b/docs/specification.md similarity index 100% rename from conceptual-model/specification.md rename to docs/specification.md diff --git a/mex/__init__.py b/mex/__init__.py new file mode 100644 index 00000000..b36383a6 --- /dev/null +++ b/mex/__init__.py @@ -0,0 +1,3 @@ +from pkgutil import extend_path + +__path__ = extend_path(__path__, __name__) diff --git a/mex/model/__init__.py b/mex/model/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/schema/entities/access-platform.json b/mex/model/entities/access-platform.json similarity index 74% rename from schema/entities/access-platform.json rename to mex/model/entities/access-platform.json index 2ac1cfeb..fa61ea81 100644 --- a/schema/entities/access-platform.json +++ b/mex/model/entities/access-platform.json @@ -9,11 +9,12 @@ "sameAs": [ "http://purl.org/dc/terms/alternative" ], - "type": "array" + "type": "array", + "default": [] }, "contact": { "items": { - "oneOf": [ + "anyOf": [ { "$ref": "/schema/entities/organizational-unit#/identifier" }, @@ -28,7 +29,8 @@ "sameAs": [ "http://www.w3.org/ns/dcat#contactPoint" ], - "type": "array" + "type": "array", + "default": [] }, "description": { "items": { @@ -37,26 +39,51 @@ "sameAs": [ "http://purl.org/dc/terms/description" ], - "type": "array" + "type": "array", + "default": [] }, "endpointDescription": { - "$ref": "/schema/fields/link", "sameAs": [ "http://www.w3.org/ns/dcat#endpointDescription" - ] + ], + "anyOf": [ + { + "$ref": "/schema/fields/link" + }, + { + "type": "null" + } + ], + "default": null }, "endpointType": { - "$ref": "/schema/entities/concept#/identifier", + "anyOf": [ + { + "$ref": "/schema/entities/concept#/identifier", + "useScheme": "https://mex.rki.de/item/api-type", + "examples": [ + "https://mex.rki.de/item/api-type-1" + ] + }, + { + "type": "null" + } + ], + "default": null, "subPropertyOf": [ "http://purl.org/dc/terms/type" - ], - "useScheme": "https://mex.rki.de/item/api-type", - "examples": [ - "https://mex.rki.de/item/api-type-1" ] }, "endpointURL": { - "$ref": "/schema/fields/link", + "anyOf": [ + { + "$ref": "/schema/fields/link" + }, + { + "type": "null" + } + ], + "default": null, "sameAs": [ "http://www.w3.org/ns/dcat#endpointURL" ] @@ -89,7 +116,8 @@ "sameAs": [ "http://www.w3.org/ns/dcat#landingPage" ], - "type": "array" + "type": "array", + "default": [] }, "stableTargetId": { "$ref": "/schema/fields/identifier" @@ -111,7 +139,8 @@ "sameAs": [ "http://purl.org/dc/terms/title" ], - "type": "array" + "type": "array", + "default": [] }, "unitInCharge": { "items": { @@ -120,7 +149,8 @@ "sameAs": [ "http://dcat-ap.de/def/dcatde/maintainer" ], - "type": "array" + "type": "array", + "default": [] } }, "required": [ diff --git a/schema/entities/activity.json b/mex/model/entities/activity.json similarity index 80% rename from schema/entities/activity.json rename to mex/model/entities/activity.json index ad6eb342..f145ba3b 100644 --- a/schema/entities/activity.json +++ b/mex/model/entities/activity.json @@ -9,20 +9,22 @@ "sameAs": [ "http://purl.org/dc/terms/description" ], - "type": "array" + "type": "array", + "default": [] }, "activityType": { - "examples": [ - "https://mex.rki.de/item/activity-type-1" - ], "items": { - "$ref": "/schema/entities/concept#/identifier" + "$ref": "/schema/entities/concept#/identifier", + "examples": [ + "https://mex.rki.de/item/activity-type-1" + ], + "useScheme": "https://mex.rki.de/item/activity-type" }, "subPropertyOf": [ "http://purl.org/dc/terms/type" ], "type": "array", - "useScheme": "https://mex.rki.de/item/activity-type" + "default": [] }, "alternativeTitle": { "items": { @@ -31,7 +33,8 @@ "sameAs": [ "http://purl.org/dc/terms/alternative" ], - "type": "array" + "type": "array", + "default": [] }, "contact": { "items": { @@ -60,23 +63,25 @@ "sameAs": [ "http://purl.org/dc/terms/isReferencedBy" ], - "type": "array" + "type": "array", + "default": [] }, "end": { "items": { + "examples": [ + "2024-01-17", + "2024", + "2024-01" + ], "format": "date", "pattern": "^\\d{4}(-\\d{2})?(-\\d{2})?$", "type": "string" }, - "examples": [ - "2024-01-17", - "2024", - "2024-01" - ], "sameAs": [ "http://www.wikidata.org/entity/P582" ], - "type": "array" + "type": "array", + "default": [] }, "externalAssociate": { "items": { @@ -92,20 +97,23 @@ "sameAs": [ "http://purl.org/dc/terms/contributor" ], - "type": "array" + "type": "array", + "default": [] }, "funderOrCommissioner": { "items": { "$ref": "/schema/entities/organization#/identifier" }, "sameAs": "http://www.wikidata.org/entity/P8324", - "type": "array" + "type": "array", + "default": [] }, "fundingProgram": { "items": { "type": "string" }, - "type": "array" + "type": "array", + "default": [] }, "hadPrimarySource": { "$ref": "/schema/entities/primary-source#/identifier", @@ -135,7 +143,8 @@ "sameAs": [ "http://purl.org/dc/terms/contributor" ], - "type": "array" + "type": "array", + "default": [] }, "involvedUnit": { "items": { @@ -144,7 +153,8 @@ "sameAs": [ "http://purl.org/dc/terms/contributor" ], - "type": "array" + "type": "array", + "default": [] }, "isPartOfActivity": { "items": { @@ -154,7 +164,8 @@ "http://purl.org/dc/terms/isPartOf", "http://www.cidoc-crm.org/cidoc-crm/P9i_forms_part_of" ], - "type": "array" + "type": "array", + "default": [] }, "publication": { "items": { @@ -163,7 +174,8 @@ "sameAs": [ "http://purl.org/dc/terms/isReferencedBy" ], - "type": "array" + "type": "array", + "default": [] }, "responsibleUnit": { "items": { @@ -180,26 +192,28 @@ "sameAs": [ "http://www.wikidata.org/entity/P1813" ], - "type": "array" + "type": "array", + "default": [] }, "stableTargetId": { "$ref": "/schema/fields/identifier" }, "start": { "items": { + "examples": [ + "2023-01-16", + "2023", + "2023-02" + ], "format": "date", "pattern": "^\\d{4}(-\\d{2})?(-\\d{2})?$", "type": "string" }, - "examples": [ - "2023-01-16", - "2023", - "2023-02" - ], "sameAs": [ "http://www.wikidata.org/entity/P580" ], - "type": "array" + "type": "array", + "default": [] }, "succeeds": { "items": { @@ -208,20 +222,22 @@ "sameAs": [ "http://www.cidoc-crm.org/cidoc-crm/P173_start_before_or_with_the_end_of" ], - "type": "array" + "type": "array", + "default": [] }, "theme": { - "examples": [ - "https://mex.rki.de/item/theme-1" - ], "items": { - "$ref": "/schema/entities/concept#/identifier" + "examples": [ + "https://mex.rki.de/item/theme-1" + ], + "$ref": "/schema/entities/concept#/identifier", + "useScheme": "https://mex.rki.de/item/theme" }, "sameAs": [ "http://www.w3.org/ns/dcat#theme" ], "type": "array", - "useScheme": "https://mex.rki.de/item/theme" + "default": [] }, "title": { "items": { @@ -241,7 +257,8 @@ "http://www.wikidata.org/entity/P856", "http://xmlns.com/foaf/0.1/homepage" ], - "type": "array" + "type": "array", + "default": [] } }, "required": [ diff --git a/schema/entities/concept-scheme.json b/mex/model/entities/concept-scheme.json similarity index 91% rename from schema/entities/concept-scheme.json rename to mex/model/entities/concept-scheme.json index 676e21ec..6caa0acb 100644 --- a/schema/entities/concept-scheme.json +++ b/mex/model/entities/concept-scheme.json @@ -9,7 +9,8 @@ "sameAs": [ "http://purl.org/dc/elements/1.1/description" ], - "type": "array" + "type": "array", + "default": [] }, "identifier": { "examples": [ @@ -29,7 +30,8 @@ "sameAs": [ "http://www.w3.org/2000/01/rdf-schema#label" ], - "type": "array" + "type": "array", + "default": [] } }, "required": [ diff --git a/schema/entities/concept.json b/mex/model/entities/concept.json similarity index 90% rename from schema/entities/concept.json rename to mex/model/entities/concept.json index 85c8109b..a98a27d9 100644 --- a/schema/entities/concept.json +++ b/mex/model/entities/concept.json @@ -9,7 +9,8 @@ "sameAs": [ "http://www.w3.org/2004/02/skos/core#altLabel" ], - "type": "array" + "type": "array", + "default": [] }, "broader": { "items": { @@ -18,7 +19,8 @@ "sameAs": [ "http://www.w3.org/2004/02/skos/core#broader" ], - "type": "array" + "type": "array", + "default": [] }, "definition": { "items": { @@ -27,7 +29,8 @@ "sameAs": [ "http://www.w3.org/2004/02/skos/core#definition" ], - "type": "array" + "type": "array", + "default": [] }, "exactMatch": { "items": { @@ -37,7 +40,8 @@ "sameAs": [ "http://www.w3.org/2004/02/skos/core#exactMatch" ], - "type": "array" + "type": "array", + "default": [] }, "identifier": { "examples": [ @@ -78,6 +82,7 @@ "required": [ "identifier", "inScheme", + "notation", "prefLabel" ], "sameAs": [ diff --git a/schema/entities/contact-point.json b/mex/model/entities/contact-point.json similarity index 100% rename from schema/entities/contact-point.json rename to mex/model/entities/contact-point.json diff --git a/schema/entities/distribution.json b/mex/model/entities/distribution.json similarity index 67% rename from schema/entities/distribution.json rename to mex/model/entities/distribution.json index 6a1c7d81..6293dda7 100644 --- a/schema/entities/distribution.json +++ b/mex/model/entities/distribution.json @@ -3,7 +3,15 @@ "$schema": "http://json-schema.org/draft/2020-12/schema", "properties": { "accessService": { - "$ref": "/schema/entities/access-platform#/identifier", + "anyOf": [ + { + "$ref": "/schema/entities/access-platform#/identifier" + }, + { + "type": "null" + } + ], + "default": null, "sameAs": [ "http://www.w3.org/ns/dcat#accessService" ] @@ -19,7 +27,15 @@ "useScheme": "https://mex.rki.de/item/access-restriction" }, "accessURL": { - "$ref": "/schema/fields/link", + "anyOf": [ + { + "$ref": "/schema/fields/link" + }, + { + "type": "null" + } + ], + "default": null, "subPropertyOf": [ "http://www.w3.org/ns/dcat#accessURL" ] @@ -31,7 +47,8 @@ "sameAs": [ "http://purl.org/dc/terms/creator" ], - "type": "array" + "type": "array", + "default": [] }, "contactPerson": { "items": { @@ -40,7 +57,8 @@ "sameAs": [ "http://www.w3.org/ns/dcat#contactPoint" ], - "type": "array" + "type": "array", + "default": [] }, "dataCurator": { "items": { @@ -49,7 +67,8 @@ "subPropertyOf": [ "http://purl.org/dc/terms/contributor" ], - "type": "array" + "type": "array", + "default": [] }, "dataManager": { "items": { @@ -58,10 +77,19 @@ "subPropertyOf": [ "http://purl.org/dc/terms/contributor" ], - "type": "array" + "type": "array", + "default": [] }, "downloadURL": { - "$ref": "/schema/fields/link", + "anyOf": [ + { + "$ref": "/schema/fields/link" + }, + { + "type": "null" + } + ], + "default": null, "subPropertyOf": [ "http://www.w3.org/ns/dcat#downloadURL" ] @@ -92,69 +120,92 @@ { "format": "date-time", "pattern": "^[1-9]\\d{3}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$", - "type": "string" + "type": "string", + "examples": [ + "2022-09-30T20:48:35Z" + ] }, { "format": "date", "pattern": "^\\d{4}(-\\d{2})?(-\\d{2})?$", - "type": "string" + "type": "string", + "examples": [ + "2011", + "2019-03", + "2014-08-24" + ] } ], - "examples": [ - "2011", - "2019-03", - "2014-08-24", - "2022-09-30T20:48:35Z" - ], "sameAs": [ "http://purl.org/dc/terms/issued" ], "type": "string" }, "license": { - "$ref": "/schema/entities/concept#/identifier", - "examples": [ - "https://mex.rki.de/item/license-1" + "anyOf": [ + { + "$ref": "/schema/entities/concept#/identifier", + "examples": [ + "https://mex.rki.de/item/license-1" + ], + "useScheme": "https://mex.rki.de/item/license" + }, + { + "type": "null" + } ], + "default": null, "sameAs": [ "http://purl.org/dc/terms/license" - ], - "useScheme": "https://mex.rki.de/item/license" + ] }, "mediaType": { - "$ref": "/schema/entities/concept#/identifier", - "examples": [ - "https://mex.rki.de/item/mime-type-1" + "anyOf": [ + { + "$ref": "/schema/entities/concept#/identifier", + "examples": [ + "https://mex.rki.de/item/mime-type-1" + ], + "useScheme": "https://mex.rki.de/item/mime-type" + }, + { + "type": "null" + } ], + "default": null, "sameAs": [ "http://www.w3.org/ns/dcat#mediaType", "http://purl.org/dc/terms/format" - ], - "useScheme": "https://mex.rki.de/item/mime-type" + ] }, "modified": { "anyOf": [ { "format": "date-time", "pattern": "^[1-9]\\d{3}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$", - "type": "string" + "type": "string", + "examples": [ + "2022-09-30T20:48:35Z" + ] }, { "format": "date", "pattern": "^\\d{4}(-\\d{2})?(-\\d{2})?$", - "type": "string" + "type": "string", + "examples": [ + "2011", + "2019-03", + "2014-08-24" + ] + }, + { + "type": "null" } ], - "examples": [ - "2011", - "2019-03", - "2014-08-24", - "2022-09-30T20:48:35Z" - ], "sameAs": [ "http://purl.org/dc/terms/modified" ], - "type": "string" + "default": null }, "otherContributor": { "items": { @@ -163,7 +214,8 @@ "subPropertyOf": [ "http://purl.org/dc/terms/contributor" ], - "type": "array" + "type": "array", + "default": [] }, "projectLeader": { "items": { @@ -172,7 +224,8 @@ "subPropertyOf": [ "http://purl.org/dc/terms/contributor" ], - "type": "array" + "type": "array", + "default": [] }, "projectManager": { "items": { @@ -181,7 +234,8 @@ "subPropertyOf": [ "http://purl.org/dc/terms/contributor" ], - "type": "array" + "type": "array", + "default": [] }, "publisher": { "items": { @@ -197,7 +251,8 @@ "subPropertyOf": [ "http://purl.org/dc/terms/contributor" ], - "type": "array" + "type": "array", + "default": [] }, "stableTargetId": { "$ref": "/schema/fields/identifier" diff --git a/schema/entities/organization.json b/mex/model/entities/organization.json similarity index 90% rename from schema/entities/organization.json rename to mex/model/entities/organization.json index ef52fe0e..5116bbe5 100644 --- a/schema/entities/organization.json +++ b/mex/model/entities/organization.json @@ -9,7 +9,8 @@ "sameAs": [ "http://purl.org/dc/terms/alternative" ], - "type": "array" + "type": "array", + "default": [] }, "geprisId": { "items": { @@ -23,7 +24,8 @@ "sameAs": [ "http://www.wikidata.org/entity/P4871" ], - "type": "array" + "type": "array", + "default": [] }, "gndId": { "items": { @@ -37,7 +39,8 @@ "sameAs": [ "http://www.wikidata.org/entity/P227" ], - "type": "array" + "type": "array", + "default": [] }, "hadPrimarySource": { "$ref": "/schema/entities/primary-source#/identifier", @@ -72,7 +75,8 @@ "sameAs": [ "http://www.wikidata.org/entity/P213" ], - "type": "array" + "type": "array", + "default": [] }, "officialName": { "items": { @@ -96,7 +100,8 @@ "sameAs": [ "http://www.wikidata.org/entity/P6782" ], - "type": "array" + "type": "array", + "default": [] }, "shortName": { "items": { @@ -105,7 +110,8 @@ "sameAs": [ "http://www.wikidata.org/entity/P1813" ], - "type": "array" + "type": "array", + "default": [] }, "stableTargetId": { "$ref": "/schema/fields/identifier" @@ -122,7 +128,8 @@ "sameAs": [ "http://www.wikidata.org/entity/P214" ], - "type": "array" + "type": "array", + "default": [] }, "wikidataId": { "items": { @@ -133,7 +140,8 @@ "pattern": "^https://www\\.wikidata\\.org/entity/[PQ0-9]{2,64}$", "type": "string" }, - "type": "array" + "type": "array", + "default": [] } }, "required": [ diff --git a/schema/entities/organizational-unit.json b/mex/model/entities/organizational-unit.json similarity index 84% rename from schema/entities/organizational-unit.json rename to mex/model/entities/organizational-unit.json index 646e7576..7c7ee879 100644 --- a/schema/entities/organizational-unit.json +++ b/mex/model/entities/organizational-unit.json @@ -9,7 +9,8 @@ "sameAs": [ "http://purl.org/dc/terms/alternative" ], - "type": "array" + "type": "array", + "default": [] }, "email": { "items": { @@ -24,7 +25,8 @@ "http://www.w3.org/2006/vcard/ns#hasEmail", "https://schema.org/email" ], - "type": "array" + "type": "array", + "default": [] }, "hadPrimarySource": { "$ref": "/schema/entities/primary-source#/identifier", @@ -56,7 +58,15 @@ "type": "array" }, "parentUnit": { - "$ref": "/schema/entities/organizational-unit#/identifier" + "anyOf": [ + { + "$ref": "/schema/entities/organizational-unit#/identifier" + }, + { + "type": "null" + } + ], + "default": null }, "shortName": { "items": { @@ -65,7 +75,8 @@ "sameAs": [ "http://www.wikidata.org/entity/P1813" ], - "type": "array" + "type": "array", + "default": [] }, "stableTargetId": { "$ref": "/schema/fields/identifier" @@ -77,7 +88,8 @@ "sameAs": [ "http://www.w3.org/ns/org#unitOf" ], - "type": "array" + "type": "array", + "default": [] }, "website": { "items": { @@ -88,7 +100,8 @@ "http://www.w3.org/2006/vcard/ns#hasUrl", "http://xmlns.com/foaf/0.1/homepage" ], - "type": "array" + "type": "array", + "default": [] } }, "required": [ diff --git a/schema/entities/person.json b/mex/model/entities/person.json similarity index 80% rename from schema/entities/person.json rename to mex/model/entities/person.json index 765c44b3..811fb61b 100644 --- a/schema/entities/person.json +++ b/mex/model/entities/person.json @@ -10,7 +10,8 @@ "https://schema.org/affiliation", "http://www.wikidata.org/entity/P1416" ], - "type": "array" + "type": "array", + "default": [] }, "email": { "items": { @@ -25,46 +26,50 @@ "http://www.w3.org/2006/vcard/ns#hasEmail", "https://schema.org/email" ], - "type": "array" + "type": "array", + "default": [] }, "familyName": { - "examples": [ - "Patapoutian", - "Skłodowska-Curie", - "Muta Maathai" - ], "items": { + "examples": [ + "Patapoutian", + "Skłodowska-Curie", + "Muta Maathai" + ], "type": "string" }, "sameAs": [ "http://xmlns.com/foaf/0.1/familyName", "https://schema.org/familyName" ], - "type": "array" + "type": "array", + "default": [] }, "fullName": { - "examples": [ - "Juturna Felicitás", - "M. Berhanu", - "Keone Seong-Hyeon" - ], "items": { + "examples": [ + "Juturna Felicitás", + "M. Berhanu", + "Keone Seong-Hyeon" + ], "type": "string" }, "sameAs": [ "http://xmlns.com/foaf/0.1/name" ], - "type": "array" + "type": "array", + "default": [] }, "givenName": { - "examples": [ - "Romāns", - "Marie Salomea", - "May-Britt" - ], "items": { + "examples": [ + "Romāns", + "Marie Salomea", + "May-Britt" + ], "type": "string" }, + "default": [], "sameAs": [ "http://xmlns.com/foaf/0.1/givenName", "https://schema.org/givenName" @@ -104,7 +109,8 @@ "sameAs": [ "http://www.wikidata.org/entity/P213" ], - "type": "array" + "type": "array", + "default": [] }, "memberOf": { "items": { @@ -113,7 +119,8 @@ "sameAs": [ "http://www.cidoc-crm.org/cidoc-crm/P107i_is_current_or_former_member_of" ], - "type": "array" + "type": "array", + "default": [] }, "orcidId": { "items": { @@ -127,7 +134,8 @@ "sameAs": [ "http://www.wikidata.org/entity/P496" ], - "type": "array" + "type": "array", + "default": [] }, "stableTargetId": { "$ref": "/schema/fields/identifier" diff --git a/schema/entities/primary-source.json b/mex/model/entities/primary-source.json similarity index 80% rename from schema/entities/primary-source.json rename to mex/model/entities/primary-source.json index e232c5d6..cf57dd38 100644 --- a/schema/entities/primary-source.json +++ b/mex/model/entities/primary-source.json @@ -9,7 +9,8 @@ "sameAs": [ "http://purl.org/dc/terms/alternative" ], - "type": "array" + "type": "array", + "default": [] }, "contact": { "items": { @@ -28,7 +29,8 @@ "http://www.w3.org/ns/dcat#contactPoint" ] }, - "type": "array" + "type": "array", + "default": [] }, "description": { "items": { @@ -37,7 +39,8 @@ "sameAs": [ "http://purl.org/dc/terms/description" ], - "type": "array" + "type": "array", + "default": [] }, "documentation": { "items": { @@ -46,7 +49,8 @@ "sameAs": [ "http://purl.org/dc/terms/isReferencedBy" ], - "type": "array" + "type": "array", + "default": [] }, "hadPrimarySource": { "$ref": "/schema/entities/primary-source#/identifier", @@ -73,7 +77,8 @@ "items": { "$ref": "/schema/fields/link" }, - "type": "array" + "type": "array", + "default": [] }, "stableTargetId": { "$ref": "/schema/fields/identifier" @@ -85,7 +90,8 @@ "sameAs": [ "http://purl.org/dc/terms/title" ], - "type": "array" + "type": "array", + "default": [] }, "unitInCharge": { "items": { @@ -94,15 +100,24 @@ "sameAs": [ "http://dcat-ap.de/def/dcatde/maintainer" ], - "type": "array" + "type": "array", + "default": [] }, "version": { - "examples": [ - "v1", - "2023-01-16", - "Schema 9" + "anyOf": [ + { + "examples": [ + "v1", + "2023-01-16", + "Schema 9" + ], + "type": "string" + }, + { + "type": "null" + } ], - "type": "string" + "default": null } }, "required": [ diff --git a/schema/entities/resource.json b/mex/model/entities/resource.json similarity index 69% rename from schema/entities/resource.json rename to mex/model/entities/resource.json index 66775017..e86846d0 100644 --- a/schema/entities/resource.json +++ b/mex/model/entities/resource.json @@ -10,7 +10,8 @@ "sameAs": [ "http://www.w3.org/ns/dcat#accessService" ], - "type": "array" + "type": "array", + "default": [] }, "accessRestriction": { "$ref": "/schema/entities/concept#/identifier", @@ -23,13 +24,21 @@ "useScheme": "https://mex.rki.de/item/access-restriction" }, "accrualPeriodicity": { - "$ref": "/schema/entities/concept#/identifier", + "anyOf": [ + { + "$ref": "/schema/entities/concept#/identifier", + "useScheme": "https://mex.rki.de/item/frequency", + "examples": [ + "https://mex.rki.de/item/frequency-1" + ] + }, + { + "type": "null" + } + ], + "default": null, "sameAs": [ "http://purl.org/dc/terms/accrualPeriodicity" - ], - "useScheme": "https://mex.rki.de/item/frequency", - "examples": [ - "https://mex.rki.de/item/frequency-1" ] }, "alternativeTitle": { @@ -39,17 +48,19 @@ "sameAs": [ "http://purl.org/dc/terms/alternative" ], - "type": "array" + "type": "array", + "default": [] }, "anonymizationPseudonymization": { "items": { - "$ref": "/schema/entities/concept#/identifier" + "examples": [ + "https://mex.rki.de/item/anonymization-pseudonymization-1" + ], + "$ref": "/schema/entities/concept#/identifier", + "useScheme": "https://mex.rki.de/item/anonymization-pseudonymization" }, "type": "array", - "examples": [ - "https://mex.rki.de/item/anonymization-pseudonymization-1" - ], - "useScheme": "https://mex.rki.de/item/anonymization-pseudonymization" + "default": [] }, "contact": { "items": { @@ -78,7 +89,8 @@ "subPropertyOf": [ "http://purl.org/dc/terms/contributor" ], - "type": "array" + "type": "array", + "default": [] }, "contributor": { "items": { @@ -87,31 +99,37 @@ "subPropertyOf": [ "http://purl.org/dc/terms/contributor" ], - "type": "array" + "type": "array", + "default": [] }, "created": { "anyOf": [ { "format": "date-time", "pattern": "^[1-9]\\d{3}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$", - "type": "string" + "type": "string", + "examples": [ + "2022-09-30T20:48:35Z" + ] }, { "format": "date", "pattern": "^\\d{4}(-\\d{2})?(-\\d{2})?$", + "examples": [ + "2011", + "2019-03", + "2014-08-24" + ], "type": "string" + }, + { + "type": "null" } ], - "examples": [ - "2011", - "2019-03", - "2014-08-24", - "2022-09-30T20:48:35Z" - ], + "default": null, "sameAs": [ "http://purl.org/dc/terms/created" - ], - "type": "string" + ] }, "creator": { "items": { @@ -120,7 +138,8 @@ "sameAs": [ "http://purl.org/dc/terms/creator" ], - "type": "array" + "type": "array", + "default": [] }, "description": { "items": { @@ -129,13 +148,15 @@ "sameAs": [ "http://purl.org/dc/terms/description" ], - "type": "array" + "type": "array", + "default": [] }, "distribution": { "items": { "$ref": "/schema/entities/distribution#/identifier" }, - "type": "array" + "type": "array", + "default": [] }, "documentation": { "items": { @@ -144,7 +165,8 @@ "sameAs": [ "http://purl.org/dc/terms/isReferencedBy" ], - "type": "array" + "type": "array", + "default": [] }, "externalPartner": { "items": { @@ -153,7 +175,8 @@ "sameAs": [ "http://purl.org/dc/terms/contributor" ], - "type": "array" + "type": "array", + "default": [] }, "hadPrimarySource": { "$ref": "/schema/entities/primary-source#/identifier", @@ -165,7 +188,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "default": [] }, "identifier": { "$ref": "/schema/fields/identifier", @@ -186,7 +210,8 @@ "items": { "$ref": "/schema/fields/text" }, - "type": "array" + "type": "array", + "default": [] }, "isPartOf": { "items": { @@ -195,7 +220,8 @@ "sameAs": [ "http://purl.org/dc/terms/isPartOf" ], - "type": "array" + "type": "array", + "default": [] }, "keyword": { "items": { @@ -204,53 +230,66 @@ "sameAs": [ "http://www.w3.org/ns/dcat#keyword" ], - "type": "array" + "type": "array", + "default": [] }, "language": { "items": { - "$ref": "/schema/entities/concept#/identifier" + "examples": [ + "https://mex.rki.de/item/language-1" + ], + "$ref": "/schema/entities/concept#/identifier", + "useScheme": "https://mex.rki.de/item/language" }, "sameAs": [ "http://purl.org/dc/terms/language" ], "type": "array", - "examples": [ - "https://mex.rki.de/item/language-1" - ], - "useScheme": "https://mex.rki.de/item/language" + "default": [] }, "license": { - "$ref": "/schema/entities/concept#/identifier", - "examples": [ - "https://mex.rki.de/item/license-1" + "anyOf": [ + { + "$ref": "/schema/entities/concept#/identifier", + "examples": [ + "https://mex.rki.de/item/license-1" + ], + "useScheme": "https://mex.rki.de/item/license" + }, + { + "type": "null" + } ], "sameAs": [ "http://purl.org/dc/terms/license" ], - "useScheme": "https://mex.rki.de/item/license" + "default": null }, "loincId": { "items": { "type": "string" }, - "type": "array" + "type": "array", + "default": [] }, "meshId": { - "examples": [ - "http://id.nlm.nih.gov/mesh/D001604" - ], "items": { + "examples": [ + "http://id.nlm.nih.gov/mesh/D001604" + ], "format": "uri", "pattern": "^http://id\\.nlm\\.nih\\.gov/mesh/[A-Z0-9]{2,64}$", "type": "string" }, - "type": "array" + "type": "array", + "default": [] }, "method": { "items": { "$ref": "/schema/fields/text" }, - "type": "array" + "type": "array", + "default": [] }, "methodDescription": { "items": { @@ -259,31 +298,37 @@ "subPropertyOf": [ "http://purl.org/dc/terms/description" ], - "type": "array" + "type": "array", + "default": [] }, "modified": { "anyOf": [ { "format": "date-time", + "examples": [ + "2022-09-30T20:48:35Z" + ], "pattern": "^[1-9]\\d{3}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$", "type": "string" }, { "format": "date", "pattern": "^\\d{4}(-\\d{2})?(-\\d{2})?$", + "examples": [ + "2011", + "2019-03", + "2014-08-24" + ], "type": "string" + }, + { + "type": "null" } ], - "examples": [ - "2011", - "2019-03", - "2014-08-24", - "2022-09-30T20:48:35Z" - ], "sameAs": [ "http://purl.org/dc/terms/modified" ], - "type": "string" + "default": null }, "publication": { "items": { @@ -292,13 +337,15 @@ "sameAs": [ "http://purl.org/dc/terms/isReferencedBy" ], - "type": "array" + "type": "array", + "default": [] }, "publisher": { "items": { "$ref": "/schema/entities/organization#/identifier" }, - "type": "array" + "type": "array", + "default": [] }, "qualityInformation": { "items": { @@ -307,20 +354,22 @@ "sameAs": [ "http://purl.org/dc/terms/description" ], - "type": "array" + "type": "array", + "default": [] }, "resourceTypeGeneral": { "items": { - "$ref": "/schema/entities/concept#/identifier" + "examples": [ + "https://mex.rki.de/item/resource-type-general-1" + ], + "$ref": "/schema/entities/concept#/identifier", + "useScheme": "https://mex.rki.de/item/resource-type-general" }, "subPropertyOf": [ "http://purl.org/dc/terms/type" ], "type": "array", - "examples": [ - "https://mex.rki.de/item/resource-type-general-1" - ], - "useScheme": "https://mex.rki.de/item/resource-type-general" + "default": [] }, "resourceTypeSpecific": { "items": { @@ -329,7 +378,8 @@ "subPropertyOf": [ "http://purl.org/dc/terms/type" ], - "type": "array" + "type": "array", + "default": [] }, "rights": { "items": { @@ -338,10 +388,19 @@ "sameAs": [ "http://purl.org/dc/terms/rights" ], - "type": "array" + "type": "array", + "default": [] }, "sizeOfDataBasis": { - "type": "string" + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null }, "spatial": { "items": { @@ -350,20 +409,22 @@ "sameAs": [ "http://purl.org/dc/terms/spatial" ], - "type": "array" + "type": "array", + "default": [] }, "stableTargetId": { "$ref": "/schema/fields/identifier" }, "stateOfDataProcessing": { "items": { - "$ref": "/schema/entities/concept#/identifier" + "examples": [ + "https://mex.rki.de/item/data-processing-state-1" + ], + "$ref": "/schema/entities/concept#/identifier", + "useScheme": "https://mex.rki.de/item/data-processing-state" }, "type": "array", - "examples": [ - "https://mex.rki.de/item/data-processing-state-1" - ], - "useScheme": "https://mex.rki.de/item/data-processing-state" + "default": [] }, "temporal": { "anyOf": [ @@ -393,25 +454,29 @@ "1998-2008" ], "type": "string" + }, + { + "type": "null" } ], "sameAs": [ "http://purl.org/dc/terms/temporal" - ] + ], + "default": null }, "theme": { "items": { - "$ref": "/schema/entities/concept#/identifier" + "examples": [ + "https://mex.rki.de/item/theme-1" + ], + "$ref": "/schema/entities/concept#/identifier", + "useScheme": "https://mex.rki.de/item/theme" }, "minItems": 1, "sameAs": [ "http://www.w3.org/ns/dcat#theme" ], - "examples": [ - "https://mex.rki.de/item/theme-1" - ], - "type": "array", - "useScheme": "https://mex.rki.de/item/theme" + "type": "array" }, "title": { "items": { @@ -434,8 +499,16 @@ "type": "array" }, "wasGeneratedBy": { - "$ref": "/schema/entities/activity#/identifier", - "sameAs": "http://www.w3.org/ns/prov#wasGeneratedBy" + "anyOf": [ + { + "$ref": "/schema/entities/activity#/identifier" + }, + { + "type": "null" + } + ], + "sameAs": "http://www.w3.org/ns/prov#wasGeneratedBy", + "default": null } }, "required": [ diff --git a/schema/entities/variable-group.json b/mex/model/entities/variable-group.json similarity index 100% rename from schema/entities/variable-group.json rename to mex/model/entities/variable-group.json diff --git a/schema/entities/variable.json b/mex/model/entities/variable.json similarity index 68% rename from schema/entities/variable.json rename to mex/model/entities/variable.json index a44c7519..132b9eab 100644 --- a/schema/entities/variable.json +++ b/mex/model/entities/variable.json @@ -10,26 +10,43 @@ "sameAs": [ "http://purl.org/dc/terms/isPartOf" ], - "type": "array" + "type": "array", + "default": [] }, "codingSystem": { - "examples": [ - "SF-36 Version 1" + "anyOf": [ + { + "examples": [ + "SF-36 Version 1" + ], + "type": "string" + }, + { + "type": "null" + } ], "sameAs": [ "http://purl.org/dc/terms/conformsTo" ], - "type": "string" + "default": null }, "dataType": { - "$ref": "/schema/entities/concept#/identifier", - "examples": [ - "https://mex.rki.de/item/data-type-1" + "anyOf": [ + { + "$ref": "/schema/entities/concept#/identifier", + "examples": [ + "https://mex.rki.de/item/data-type-1" + ], + "useScheme": "https://mex.rki.de/item/data-type" + }, + { + "type": "null" + } ], "subPropertyOf": [ "http://purl.org/dc/terms/type" ], - "useScheme": "https://mex.rki.de/item/data-type" + "default": null }, "description": { "items": { @@ -38,7 +55,8 @@ "sameAs": [ "http://purl.org/dc/terms/description" ], - "type": "array" + "type": "array", + "default": [] }, "hadPrimarySource": { "$ref": "/schema/entities/primary-source#/identifier", @@ -62,13 +80,13 @@ "type": "string" }, "label": { - "examples": [ - { - "language": "de", - "value": "Mehrere Treppenabsätze steigen" - } - ], "items": { + "examples": [ + { + "language": "de", + "value": "Mehrere Treppenabsätze steigen" + } + ], "$ref": "/schema/fields/text" }, "minItems": 1, @@ -91,15 +109,16 @@ "type": "array" }, "valueSet": { - "examples": [ - "Ja, stark eingeschränkt", - "Ja, etwas eingeschränkt", - "Nein, überhaupt nicht eingeschränkt" - ], "items": { + "examples": [ + "Ja, stark eingeschränkt", + "Ja, etwas eingeschränkt", + "Nein, überhaupt nicht eingeschränkt" + ], "type": "string" }, - "type": "array" + "type": "array", + "default": [] } }, "required": [ diff --git a/schema/extension/definition.json b/mex/model/extension/definition.json similarity index 100% rename from schema/extension/definition.json rename to mex/model/extension/definition.json diff --git a/mex/model/fields/identifier.json b/mex/model/fields/identifier.json new file mode 100644 index 00000000..6da049db --- /dev/null +++ b/mex/model/fields/identifier.json @@ -0,0 +1,12 @@ +{ + "$id": "https://mex.rki.de/schema/fields/identifier", + "$schema": "http://json-schema.org/draft/2020-12/schema", + "examples": [ + "dYb6qKqjdpocTAUEPPTTj2", + "fKJE3RzeJ6ntHtqsXOOQR8", + "gglGQVGwZNJtqYDkW4N8jL" + ], + "pattern": "^[a-zA-Z0-9]{14,22}$", + "title": "Identifier", + "type": "string" +} diff --git a/schema/fields/link.json b/mex/model/fields/link.json similarity index 64% rename from schema/fields/link.json rename to mex/model/fields/link.json index 8f19befc..6b52456c 100644 --- a/schema/fields/link.json +++ b/mex/model/fields/link.json @@ -1,18 +1,6 @@ { "$id": "https://mex.rki.de/schema/fields/link", "$schema": "http://json-schema.org/draft/2020-12/schema", - "examples": [ - { - "language": "en", - "title": "hello", - "url": "https://hello-world.org" - }, - { - "language": "de", - "title": "Dateipfad", - "url": "file://S:/OE/MF4/Projekte/MEx" - } - ], "properties": { "language": { "enum": [ @@ -21,11 +9,19 @@ ] }, "title": { - "type": "string" + "type": "string", + "examples": [ + "Titel einer Webseite", + "some link title" + ] }, "url": { "format": "uri", "minLength": 1, + "examples": [ + "https://hello-world.org", + "file://S:/OE/MF4/Projekte/MEx" + ], "pattern": "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?", "type": "string" } diff --git a/schema/fields/text.json b/mex/model/fields/text.json similarity index 75% rename from schema/fields/text.json rename to mex/model/fields/text.json index bcb83282..5463d933 100644 --- a/schema/fields/text.json +++ b/mex/model/fields/text.json @@ -1,14 +1,12 @@ { "$id": "https://mex.rki.de/schema/fields/text", "$schema": "http://json-schema.org/draft/2020-12/schema", - "examples": [ - { - "value": "hello", - "language": "de" - } - ], "properties": { "value": { + "examples": [ + "Dieser Text dient als Beispiel.", + "This is another example text." + ], "minLength": 1, "type": "string" }, diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..9b0e3561 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,13 @@ +[tool.poetry] +name = "mex-model" +version = "2.2.0" +description = "RKI MEx metadata model." +authors = ["RKI MEx Team "] +readme = "README.md" +license = "MIT" +repository = "https://github.com/robert-koch-institut/mex-model" +packages = [{ include = "mex" }] + +[build-system] +requires = ["poetry-core>=1.8.1"] +build-backend = "poetry.core.masonry.api" diff --git a/requirements.txt b/requirements.txt index 5cef2202..b44b5658 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ +poetry==1.7.1 pre-commit==3.6.0 +wheel==0.42.0 diff --git a/schema/fields/identifier.json b/schema/fields/identifier.json deleted file mode 100644 index 51a6867e..00000000 --- a/schema/fields/identifier.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$id": "https://mex.rki.de/schema/fields/identifier", - "$schema": "http://json-schema.org/draft/2020-12/schema", - "examples": [ - "123e4567-e89b-12d3-a456-426655440000#merged", - "c73bcdcc-2669-4bf6-81d3-e4ae73fb11fd", - "C73BCDCC-2669-4Bf6-81d3-E4AE73FB11FD" - ], - "format": "uuid", - "pattern": " ^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}(#merged)?$", - "title": "Identifier", - "type": "string" -} diff --git a/setup.py b/setup.py deleted file mode 100644 index 2cadde93..00000000 --- a/setup.py +++ /dev/null @@ -1,11 +0,0 @@ -from setuptools import setup - -setup( - name="mex-model", - version="2.1.1", - author_email="mex@rki.de", - author="RKI MEx Team", - description="RKI MEx metadata model", - license="MIT", - package_dir={"mex.model": "schema"}, -)