Skip to content

Instantly share code, notes, and snippets.

@4lm
Created October 23, 2019 13:52
Show Gist options
  • Save 4lm/7c9b8688136be9c44b36c8a6c7a90d91 to your computer and use it in GitHub Desktop.
Save 4lm/7c9b8688136be9c44b36c8a6c7a90d91 to your computer and use it in GitHub Desktop.
DRAFT: METADATA_v1_3_SCHEMA and METADATA_v1_4_SCHEMA
"""
JSON schemas used to validate the OEP metadata input as json file.
Usage:
import jsonschema
jsonschema.validate(metadata_json, METADATA_v1_3_SCHEMA)
jsonschema.validate(metadata_json, METADATA_v1_4_SCHEMA)
"""
METADATA_v1_4_SCHEMA = {
"type": "object",
"properties": {
"name": {"type": "string"},
"title": {"type": "string"},
"id": {"type": "string"},
"description": {"type": "string"},
"language": {
"type": "array",
"items": {
"language": {"type": "string"},
},
},
"keywords": {
"type": "array",
"items": {
"keywords": {"type": "string"},
},
},
"publicationDate": {"type": "string"},
"context": {
"type": "object",
"properties": {
"homepage": {"type": "string"},
"documentation": {"type": "string"},
"sourceCode": {"type": "string"},
"contact": {"type": "string"},
"grantNo": {"type": "string"},
"fundingAgency": {"type": "string"},
"fundingAgencyLogo": {"type": "string"},
"publisherLogo": {"type": "string"},
},
},
"spatial": {
"type": "object",
"properties": {
"location": {"type": "string"},
"extent": {"type": "string"},
"resolution": {"type": "string"},
},
},
"temporal": {
"type": "object",
"properties": {
"referenceDate": {"type": "string"},
"timeseries": {
"type": "object",
"properties": {
"start": {"type": "string"},
"end": {"type": "string"},
"resolution": {"type": "string"},
"alignment": {"type": "string"},
"aggregationType": {"type": "string"},
},
},
},
},
"sources": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {"type": "string"},
"description": {"type": "string"},
"path": {"type": "string"},
"licenses": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"title": {"type": "string"},
"path": {"type": "string"},
"instruction": {"type": "string"},
"attribution": {"type": "string"},
},
},
},
},
},
},
"licenses": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"title": {"type": "string"},
"path": {"type": "string"},
"instruction": {"type": "string"},
"attribution": {"type": "string"},
},
},
},
"contributors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {"type": "string"},
"email": {"type": "string"},
"date": {"type": "string"},
"object": {"type": "string"},
"comment": {"type": "string"},
},
},
},
"resources": {
"type": "array",
"items": {
"type": "object",
"properties": {
"profile": {"type": "string"},
"name": {"type": "string"},
"path": {"type": "string"},
"format": {"type": "string"},
"encoding": {"type": "string"},
"schema": {
"type": "object",
"properties": {
"fields": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type":
"string"},
"type": {"type": "string"},
"unit": {"type": "string"},
},
},
},
"primaryKey": {
"type": "array",
"items": {
"primaryKey": {"type": "string"},
},
},
"foreignKeys": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fields": {
"type": "array",
"items": {
"fields": {"type":
"string"},
},
},
"reference": {
"type": "object",
"properties": {
"resource": {"type":
"string"},
"fields": {
"type": "array",
"items": {
"fields":
{"type": "string"},
},
},
},
},
},
},
},
},
},
"dialect": {
"type": "object",
"properties": {
"delimiter": {"type": "string"},
"decimalSeparator": {"type": "string"},
},
},
},
},
},
"review": {
"type": "object",
"properties": {
"path": {"type": "string"},
"badge": {"type": "string"},
},
},
"metaMetadata": {
"type": "object",
"properties": {
"metadataVersion": {"type": "string"},
"metadataLicense": {
"type": "object",
"properties": {
"name": {"type": "string"},
"title": {"type": "string"},
"path": {"type": "string"},
},
},
},
},
"_comment": {
"type": "object",
"properties": {
"metadata": {"type": "string"},
"dates": {"type": "string"},
"units": {"type": "string"},
"languages": {"type": "string"},
"licenses": {"type": "string"},
"review": {"type": "string"},
"null": {"type": "string"},
},
},
}
}
METADATA_v1_3_SCHEMA = {
"type": "object",
"properties": {
"title": {"type": "string"},
"description": {"type": "string"},
"language": {
"type": "array",
"items": {
"language": {"type": "string"},
},
},
"spatial": {
"type": "object",
"properties": {
"location": {"type": "string"},
"extent": {"type": "string"},
"resolution": {"type": "string"},
},
},
"temporal": {
"type": "object",
"properties": {
"reference_date": {"type": "string"},
"start": {"type": "string"},
"end": {"type": "string"},
"resolution": {"type": "string"},
},
},
"sources": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
"url": {"type": "string"},
"license": {"type": "string"},
"copyright": {"type": "string"},
},
},
},
"license": {
"type": "object",
"properties": {
"id": {"type": "string"},
"name": {"type": "string"},
"version": {"type": "string"},
"url": {"type": "string"},
"instruction": {"type": "string"},
"copyright": {"type": "string"},
},
},
"contributors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"email": {"type": "string"},
"date": {"type": "string"},
"comment": {"type": "string"},
},
},
},
"resources": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"format": {"type": "string"},
"fields": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
"unit": {"type": "string"},
},
},
},
},
},
},
"metadata_version": {"type": "string"},
"_comment": {
"type": "object",
"properties": {
"_url": {"type": "string"},
"_copyright": {"type": "string"},
"_metadata_license": {"type": "string"},
"_metadata_license_url": {"type": "string"},
"_contains": {"type": "string"},
"_additional_information": {
"type": "object",
"properties": {
"_dates": {"type": "string"},
"_units": {"type": "string"},
"_none": {"type": "string"},
},
},
},
},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment