diff --git a/schemas/schema-ap.json b/schemas/schema-ap.json new file mode 100644 index 0000000..506682e --- /dev/null +++ b/schemas/schema-ap.json @@ -0,0 +1,217 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://smorrone.github.io/test.schema/schemas/ap-model.json#", + + "title": "ap Model Extension", + "description": "STAC Analysis and processing resources (ap) Model Extension for STAC Items.", + "oneOf": [ + { + "$comment": "This is the schema for STAC Items. Remove this object if this extension only applies to Collections.", + "allOf": [ + { + "$ref": "#/definitions/stac_extensions" + }, + { + "type": "object", + "required": [ + "type", + "properties", + "assets" + ], + "properties": { + "type": { + "const": "Feature" + }, + "properties": { + "allOf": [ + { + "$comment": "Require fields here for Item Properties.", + "required": [ + "ml-model:type", + "ml-model:learning_approach", + "ml-model:prediction_type", + "ml-model:architecture" + ] + }, + { + "$ref": "#/definitions/common_fields" + } + ] + }, + "assets": { + "$comment": "This validates the fields in Item Assets, but does not require them.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/common_fields" + } + } + } + } + ] + }, + { + "$comment": "This is the schema for STAC Collections.", + "type": "object", + "allOf": [ + { + "required": [ + "type" + ], + "properties": { + "type": { + "const": "Collection" + } + } + }, + { + "$ref": "#/definitions/stac_extensions" + } + ], + "anyOf": [ + { + "$comment": "This validates the fields in Collection Assets, but does not require them.", + "required": [ + "assets" + ], + "properties": { + "assets": { + "type": "object", + "not": { + "additionalProperties": { + "not": { + "allOf": [ + { + "$ref": "#/definitions/require_any_field" + }, + { + "$ref": "#/definitions/common_fields" + } + ] + } + } + } + } + } + }, + { + "$comment": "This is the schema for the fields in Item Asset Definitions. It doesn't require any fields.", + "required": [ + "item_assets" + ], + "properties": { + "item_assets": { + "type": "object", + "not": { + "additionalProperties": { + "not": { + "allOf": [ + { + "$ref": "#/definitions/require_any_field" + }, + { + "$ref": "#/definitions/common_fields" + } + ] + } + } + } + } + } + }, + { + "$comment": "This is the schema for the fields in Summaries. By default, only checks the existance of the properties, but not the schema of the summaries.", + "required": [ + "summaries" + ], + "properties": { + "summaries": { + "$ref": "#/definitions/require_any_field" + } + } + } + ] + } + ], + "definitions": { + "stac_extensions": { + "type": "object", + "required": [ + "stac_extensions" + ], + "properties": { + "stac_extensions": { + "type": "array", + "contains": { + "const": "https://stac-extensions.github.io/ml-model/v1.0.0/schema.json" + } + } + } + }, + "require_any_field": { + "$comment": "Please list all fields here so that we can force the existance of one of them in other parts of the schemas.", + "anyOf": [ + { + "required": [ + "ml-model:learning_approach" + ] + }, + { + "required": [ + "ml-model:prediction_type" + ] + }, + { + "required": [ + "ml-model:architecture" + ] + }, + { + "required": [ + "ml-model:input_data_used" + ] + }, + { + "required": [ + "ml-model:output_data_obtained" + ] + } + ] + }, + "common_fields": { + "$comment": "Add your new Item fields here. Don't require them here, do that above in the corresponding schema.", + "type": "object", + "properties": { + "ml-model:type": { + "const": "ml-model" + }, + "ml-model:learning_approach": { + "type": "string" + }, + "ml-model:prediction_type": { + "type": "string" + }, + "ml-model:architecture": { + "type": "string" + }, + "ml-model:training-os": { + "type": "string" + }, + "ap-model:input_data_used": { + "type": "string" + }, + "ap-model:output_data_obtained": { + "type": "string" + }, + "ml-model:training-processor-type": { + "type": "string", + "enum": ["cpu", "gpu"] + } + }, + "patternProperties": { + "^(?!ml-model:)": {}, + "^(?!ap-model:)": {} + }, + "additionalProperties": false + } + } +} \ No newline at end of file