From 33e39fdefe1582b6f1e3afc62072fcd99f8b8cd6 Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Tue, 6 Dec 2022 22:45:54 +0000 Subject: [PATCH 1/2] Initial implementation of recursive JSONSchema-based property definitions --- openapi/index_openapi.json | 20 +- openapi/openapi.json | 1223 +++++++++++++++++++++++++----- optimade/models/entries.py | 299 +++++++- optimade/models/optimade_json.py | 11 + optimade/models/utils.py | 7 + 5 files changed, 1353 insertions(+), 207 deletions(-) diff --git a/openapi/index_openapi.json b/openapi/index_openapi.json index 38b883057..0965fff7d 100644 --- a/openapi/index_openapi.json +++ b/openapi/index_openapi.json @@ -509,15 +509,15 @@ "title": "Id", "type": "string", "description": "An entry's ID as defined in section Definition of Terms.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: MUST be supported by all implementations, MUST NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response.\n\n- **Examples**:\n - `\"db/1234567\"`\n - `\"cod/2000000\"`\n - `\"cod/2000000@1234567\"`\n - `\"nomad/L1234567890\"`\n - `\"42\"`", - "x-optimade-queryable": "must", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "must" }, "type": { "title": "Type", "type": "string", "description": "The name of the type of an entry.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: MUST be supported by all implementations, MUST NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response.\n - MUST be an existing entry type.\n - The entry of type `` and ID `` MUST be returned in response to a request for `//` under the versioned base URL.\n\n- **Example**: `\"structures\"`", - "x-optimade-queryable": "must", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "must" }, "links": { "title": "Links", @@ -569,16 +569,16 @@ "title": "Immutable Id", "type": "string", "description": "The entry's immutable ID (e.g., an UUID). This is important for databases having preferred IDs that point to \"the latest version\" of a record, but still offer access to older variants. This ID maps to the version-specific record, in case it changes in the future.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: OPTIONAL support in implementations, i.e., MAY be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n\n- **Examples**:\n - `\"8bd3e750-b477-41a0-9b11-3a799f21b44f\"`\n - `\"fjeiwoj,54;@=%<>#32\"` (Strings that are not URL-safe are allowed.)", - "x-optimade-queryable": "must", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "must" }, "last_modified": { "title": "Last Modified", "type": "string", "description": "Date and time representing when the entry was last modified.\n\n- **Type**: timestamp.\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response unless the query parameter `response_fields` is present and does not include this property.\n\n- **Example**:\n - As part of JSON response format: `\"2007-04-05T14:30:20Z\"` (i.e., encoded as an [RFC 3339 Internet Date/Time Format](https://tools.ietf.org/html/rfc3339#section-5.6) string.)", "format": "date-time", - "x-optimade-queryable": "must", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "must" } }, "description": "Contains key-value pairs representing the entry's properties." @@ -1118,8 +1118,8 @@ "title": "Id", "type": "string", "description": "An entry's ID as defined in section Definition of Terms.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: MUST be supported by all implementations, MUST NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response.\n\n- **Examples**:\n - `\"db/1234567\"`\n - `\"cod/2000000\"`\n - `\"cod/2000000@1234567\"`\n - `\"nomad/L1234567890\"`\n - `\"42\"`", - "x-optimade-queryable": "must", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "must" }, "type": { "title": "Type", diff --git a/openapi/openapi.json b/openapi/openapi.json index 918a2965c..bd901e538 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -1335,6 +1335,18 @@ ], "description": "Enumeration of aggregate values" }, + "AllowedJSONSchemaDataType": { + "title": "AllowedJSONSchemaDataType", + "enum": [ + "boolean", + "object", + "array", + "number", + "string", + "integer" + ], + "description": "The allowed values for `type` in the Property Definition restricted JSON Schema syntax." + }, "Assembly": { "title": "Assembly", "required": [ @@ -1353,8 +1365,8 @@ } }, "description": "Index of the sites (0-based) that belong to each group for each assembly.\n\n- **Examples**:\n - `[[1], [2]]`: two groups, one with the second site, one with the third.\n - `[[1,2], [3]]`: one group with the second and third site, one with the fourth.", - "x-optimade-queryable": "optional", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "optional" }, "group_probabilities": { "title": "Group Probabilities", @@ -1363,8 +1375,8 @@ "type": "number" }, "description": "Statistical probability of each group. It MUST have the same length as `sites_in_groups`.\nIt SHOULD sum to one.\nSee below for examples of how to specify the probability of the occurrence of a vacancy.\nThe possible reasons for the values not to sum to one are the same as already specified above for the `concentration` of each `species`.", - "x-optimade-queryable": "optional", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "optional" } }, "description": "A description of groups of sites that are statistically correlated.\n\n- **Examples** (for each entry of the assemblies list):\n - `{\"sites_in_groups\": [[0], [1]], \"group_probabilities: [0.3, 0.7]}`: the first site and the second site never occur at the same time in the unit cell.\n Statistically, 30 % of the times the first site is present, while 70 % of the times the second site is present.\n - `{\"sites_in_groups\": [[1,2], [3]], \"group_probabilities: [0.3, 0.7]}`: the second and third site are either present together or not present; they form the first group of atoms for this assembly.\n The second group is formed by the fourth site. Sites of the first group (the second and the third) are never present at the same time as the fourth site.\n 30 % of times sites 1 and 2 are present (and site 3 is absent); 70 % of times site 3 is present (and sites 1 and 2 are absent)." @@ -1573,50 +1585,640 @@ }, "description": "Minimum requirements to represent a relationship resource" }, - "DataType": { - "title": "DataType", - "enum": [ - "string", - "integer", - "float", - "boolean", - "timestamp", - "list", - "dictionary", - "unknown" - ], - "description": "Optimade Data Types\n\n See the section \"Data types\" in the OPTIMADE API specification for more information.\n " - }, "EntryInfoProperty": { "title": "EntryInfoProperty", "required": [ - "description" + "title", + "description", + "x-optimade-property", + "x-optimade-implementation", + "x-optimade-requirements", + "deprecated", + "enum", + "examples" ], "type": "object", "properties": { + "title": { + "title": "Title", + "type": "string", + "description": "A short single-line human-readable explanation of the defined property appropriate to show as part of a user interface." + }, "description": { "title": "Description", "type": "string", - "description": "A human-readable description of the entry property" + "description": "A human-readable multi-line description that explains the purpose, requirements, and conventions of the defined property.\n\nThe format SHOULD be a one-line description, followed by a new paragraph (two newlines), followed by a more detailed description of all the requirements and conventions of the defined property.\nFormatting in the text SHOULD use Markdown in the CommonMark v0.3 format." + }, + "x-optimade-property": { + "title": "X-Optimade-Property", + "allOf": [ + { + "$ref": "#/components/schemas/OptimadePropertyDefinition" + } + ], + "description": "Additional information to define the property that is not covered by fields in the JSON Schema standard." }, - "unit": { - "title": "Unit", + "x-optimade-unit": { + "title": "X-Optimade-Unit", "type": "string", - "description": "The physical unit of the entry property.\nThis MUST be a valid representation of units according to version 2.1 of [The Unified Code for Units of Measure](https://unitsofmeasure.org/ucum.html).\nIt is RECOMMENDED that non-standard (non-SI) units are described in the description for the property." + "description": "A (compound) symbol for the physical unit in which the value of the defined property is given or one of the strings `dimensionless` or `inapplicable`." }, - "sortable": { - "title": "Sortable", + "x-optimade-implementation": { + "title": "X-Optimade-Implementation", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyImplementationInfo" + } + ], + "description": "A dictionary describing the level of OPTIMADE API functionality provided by the present implementation.\nIf an implementation omits this field in its response, a client interacting with that implementation SHOULD NOT make any assumptions about the availability of these features." + }, + "x-optimade-requirements": { + "title": "X-Optimade-Requirements", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyRequirementsInfo" + } + ], + "description": "A dictionary describing the level of OPTIMADE API functionality required by all implementations of this property.\nOmitting this field means the corresponding functionality is OPTIONAL." + }, + "type": { + "title": "Type", + "anyOf": [ + { + "$ref": "#/components/schemas/AllowedJSONSchemaDataType" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/AllowedJSONSchemaDataType" + } + } + ], + "description": "A string or list that specifies the type of the defined property.\nIt MUST be one of:\n\n- One of the strings `\"boolean\"`, `\"object\"` (refers to an OPTIMADE dictionary), `\"array\"` (refers to an OPTIMADE list), `\"number\"` (refers to an OPTIMADE float), `\"string\"`, or `\"integer\"`.\n- A list where the first item MUST be one of the strings above, and the second item MUST be the string `\"null\"`." + }, + "deprecated": { + "title": "Deprecated", + "type": "boolean", + "description": " If `TRUE`, implementations SHOULD not use the defined property, and it MAY be removed in the future.\nIf `FALSE`, the defined property is not deprecated.\nThe field not being present means `FALSE`." + }, + "enum": { + "title": "Enum", + "type": "array", + "items": {}, + "description": "The defined property MUST take one of the values given in the provided list.\nThe items in the list MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description.\nIf this key is given, for `null` to be a valid value of the defined property, the list MUST contain a `null` value and the `type` MUST be a list where the second value is the string `\"null\"`." + }, + "examples": { + "title": "Examples", + "type": "array", + "items": {}, + "description": "A list of example values that the defined property can have.\nThese examples MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description." + } + } + }, + "EntryInfoPropertyArray": { + "title": "EntryInfoPropertyArray", + "required": [ + "items", + "title", + "description", + "x-optimade-property", + "x-optimade-implementation", + "x-optimade-requirements", + "deprecated", + "enum", + "examples" + ], + "type": "object", + "properties": { + "items": { + "$ref": "#/components/schemas/EntryInfoProperty" + }, + "maxItems": { + "title": "Maxitems", + "type": "integer" + }, + "minItems": { + "title": "Minitems", + "type": "integer" + }, + "uniqueItems": { + "title": "Uniqueitems", + "type": "boolean" + }, + "title": { + "title": "Title", + "type": "string", + "description": "A short single-line human-readable explanation of the defined property appropriate to show as part of a user interface." + }, + "description": { + "title": "Description", + "type": "string", + "description": "A human-readable multi-line description that explains the purpose, requirements, and conventions of the defined property.\n\nThe format SHOULD be a one-line description, followed by a new paragraph (two newlines), followed by a more detailed description of all the requirements and conventions of the defined property.\nFormatting in the text SHOULD use Markdown in the CommonMark v0.3 format." + }, + "x-optimade-property": { + "title": "X-Optimade-Property", + "allOf": [ + { + "$ref": "#/components/schemas/OptimadePropertyDefinition" + } + ], + "description": "Additional information to define the property that is not covered by fields in the JSON Schema standard." + }, + "x-optimade-unit": { + "title": "X-Optimade-Unit", + "type": "string", + "description": "A (compound) symbol for the physical unit in which the value of the defined property is given or one of the strings `dimensionless` or `inapplicable`." + }, + "x-optimade-implementation": { + "title": "X-Optimade-Implementation", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyImplementationInfo" + } + ], + "description": "A dictionary describing the level of OPTIMADE API functionality provided by the present implementation.\nIf an implementation omits this field in its response, a client interacting with that implementation SHOULD NOT make any assumptions about the availability of these features." + }, + "x-optimade-requirements": { + "title": "X-Optimade-Requirements", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyRequirementsInfo" + } + ], + "description": "A dictionary describing the level of OPTIMADE API functionality required by all implementations of this property.\nOmitting this field means the corresponding functionality is OPTIONAL." + }, + "type": { + "title": "Type", + "anyOf": [ + { + "$ref": "#/components/schemas/AllowedJSONSchemaDataType" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/AllowedJSONSchemaDataType" + } + } + ], + "description": "A string or list that specifies the type of the defined property.\nIt MUST be one of:\n\n- One of the strings `\"boolean\"`, `\"object\"` (refers to an OPTIMADE dictionary), `\"array\"` (refers to an OPTIMADE list), `\"number\"` (refers to an OPTIMADE float), `\"string\"`, or `\"integer\"`.\n- A list where the first item MUST be one of the strings above, and the second item MUST be the string `\"null\"`." + }, + "deprecated": { + "title": "Deprecated", + "type": "boolean", + "description": " If `TRUE`, implementations SHOULD not use the defined property, and it MAY be removed in the future.\nIf `FALSE`, the defined property is not deprecated.\nThe field not being present means `FALSE`." + }, + "enum": { + "title": "Enum", + "type": "array", + "items": {}, + "description": "The defined property MUST take one of the values given in the provided list.\nThe items in the list MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description.\nIf this key is given, for `null` to be a valid value of the defined property, the list MUST contain a `null` value and the `type` MUST be a list where the second value is the string `\"null\"`." + }, + "examples": { + "title": "Examples", + "type": "array", + "items": {}, + "description": "A list of example values that the defined property can have.\nThese examples MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description." + } + } + }, + "EntryInfoPropertyInteger": { + "title": "EntryInfoPropertyInteger", + "required": [ + "title", + "description", + "x-optimade-property", + "x-optimade-implementation", + "x-optimade-requirements", + "deprecated", + "enum", + "examples" + ], + "type": "object", + "properties": { + "multipleOf": { + "title": "Multipleof", + "type": "integer" + }, + "maximum": { + "title": "Maximum", + "type": "integer" + }, + "exclusiveMaximum": { + "title": "Exclusivemaximum", + "type": "integer" + }, + "minimum": { + "title": "Minimum", + "type": "integer" + }, + "exclusiveMinimum": { + "title": "Exclusiveminimum", + "type": "integer" + }, + "title": { + "title": "Title", + "type": "string", + "description": "A short single-line human-readable explanation of the defined property appropriate to show as part of a user interface." + }, + "description": { + "title": "Description", + "type": "string", + "description": "A human-readable multi-line description that explains the purpose, requirements, and conventions of the defined property.\n\nThe format SHOULD be a one-line description, followed by a new paragraph (two newlines), followed by a more detailed description of all the requirements and conventions of the defined property.\nFormatting in the text SHOULD use Markdown in the CommonMark v0.3 format." + }, + "x-optimade-property": { + "title": "X-Optimade-Property", + "allOf": [ + { + "$ref": "#/components/schemas/OptimadePropertyDefinition" + } + ], + "description": "Additional information to define the property that is not covered by fields in the JSON Schema standard." + }, + "x-optimade-unit": { + "title": "X-Optimade-Unit", + "type": "string", + "description": "A (compound) symbol for the physical unit in which the value of the defined property is given or one of the strings `dimensionless` or `inapplicable`." + }, + "x-optimade-implementation": { + "title": "X-Optimade-Implementation", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyImplementationInfo" + } + ], + "description": "A dictionary describing the level of OPTIMADE API functionality provided by the present implementation.\nIf an implementation omits this field in its response, a client interacting with that implementation SHOULD NOT make any assumptions about the availability of these features." + }, + "x-optimade-requirements": { + "title": "X-Optimade-Requirements", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyRequirementsInfo" + } + ], + "description": "A dictionary describing the level of OPTIMADE API functionality required by all implementations of this property.\nOmitting this field means the corresponding functionality is OPTIONAL." + }, + "type": { + "title": "Type", + "anyOf": [ + { + "$ref": "#/components/schemas/AllowedJSONSchemaDataType" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/AllowedJSONSchemaDataType" + } + } + ], + "description": "A string or list that specifies the type of the defined property.\nIt MUST be one of:\n\n- One of the strings `\"boolean\"`, `\"object\"` (refers to an OPTIMADE dictionary), `\"array\"` (refers to an OPTIMADE list), `\"number\"` (refers to an OPTIMADE float), `\"string\"`, or `\"integer\"`.\n- A list where the first item MUST be one of the strings above, and the second item MUST be the string `\"null\"`." + }, + "deprecated": { + "title": "Deprecated", + "type": "boolean", + "description": " If `TRUE`, implementations SHOULD not use the defined property, and it MAY be removed in the future.\nIf `FALSE`, the defined property is not deprecated.\nThe field not being present means `FALSE`." + }, + "enum": { + "title": "Enum", + "type": "array", + "items": {}, + "description": "The defined property MUST take one of the values given in the provided list.\nThe items in the list MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description.\nIf this key is given, for `null` to be a valid value of the defined property, the list MUST contain a `null` value and the `type` MUST be a list where the second value is the string `\"null\"`." + }, + "examples": { + "title": "Examples", + "type": "array", + "items": {}, + "description": "A list of example values that the defined property can have.\nThese examples MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description." + } + } + }, + "EntryInfoPropertyNumber": { + "title": "EntryInfoPropertyNumber", + "required": [ + "title", + "description", + "x-optimade-property", + "x-optimade-implementation", + "x-optimade-requirements", + "deprecated", + "enum", + "examples" + ], + "type": "object", + "properties": { + "multipleOf": { + "title": "Multipleof", + "type": "integer" + }, + "maximum": { + "title": "Maximum", + "type": "integer" + }, + "exclusiveMaximum": { + "title": "Exclusivemaximum", + "type": "integer" + }, + "minimum": { + "title": "Minimum", + "type": "integer" + }, + "exclusiveMinimum": { + "title": "Exclusiveminimum", + "type": "integer" + }, + "title": { + "title": "Title", + "type": "string", + "description": "A short single-line human-readable explanation of the defined property appropriate to show as part of a user interface." + }, + "description": { + "title": "Description", + "type": "string", + "description": "A human-readable multi-line description that explains the purpose, requirements, and conventions of the defined property.\n\nThe format SHOULD be a one-line description, followed by a new paragraph (two newlines), followed by a more detailed description of all the requirements and conventions of the defined property.\nFormatting in the text SHOULD use Markdown in the CommonMark v0.3 format." + }, + "x-optimade-property": { + "title": "X-Optimade-Property", + "allOf": [ + { + "$ref": "#/components/schemas/OptimadePropertyDefinition" + } + ], + "description": "Additional information to define the property that is not covered by fields in the JSON Schema standard." + }, + "x-optimade-unit": { + "title": "X-Optimade-Unit", + "type": "string", + "description": "A (compound) symbol for the physical unit in which the value of the defined property is given or one of the strings `dimensionless` or `inapplicable`." + }, + "x-optimade-implementation": { + "title": "X-Optimade-Implementation", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyImplementationInfo" + } + ], + "description": "A dictionary describing the level of OPTIMADE API functionality provided by the present implementation.\nIf an implementation omits this field in its response, a client interacting with that implementation SHOULD NOT make any assumptions about the availability of these features." + }, + "x-optimade-requirements": { + "title": "X-Optimade-Requirements", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyRequirementsInfo" + } + ], + "description": "A dictionary describing the level of OPTIMADE API functionality required by all implementations of this property.\nOmitting this field means the corresponding functionality is OPTIONAL." + }, + "type": { + "title": "Type", + "anyOf": [ + { + "$ref": "#/components/schemas/AllowedJSONSchemaDataType" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/AllowedJSONSchemaDataType" + } + } + ], + "description": "A string or list that specifies the type of the defined property.\nIt MUST be one of:\n\n- One of the strings `\"boolean\"`, `\"object\"` (refers to an OPTIMADE dictionary), `\"array\"` (refers to an OPTIMADE list), `\"number\"` (refers to an OPTIMADE float), `\"string\"`, or `\"integer\"`.\n- A list where the first item MUST be one of the strings above, and the second item MUST be the string `\"null\"`." + }, + "deprecated": { + "title": "Deprecated", "type": "boolean", - "description": "Defines whether the entry property can be used for sorting with the \"sort\" parameter.\nIf the entry listing endpoint supports sorting, this key MUST be present for sortable properties with value `true`." + "description": " If `TRUE`, implementations SHOULD not use the defined property, and it MAY be removed in the future.\nIf `FALSE`, the defined property is not deprecated.\nThe field not being present means `FALSE`." + }, + "enum": { + "title": "Enum", + "type": "array", + "items": {}, + "description": "The defined property MUST take one of the values given in the provided list.\nThe items in the list MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description.\nIf this key is given, for `null` to be a valid value of the defined property, the list MUST contain a `null` value and the `type` MUST be a list where the second value is the string `\"null\"`." + }, + "examples": { + "title": "Examples", + "type": "array", + "items": {}, + "description": "A list of example values that the defined property can have.\nThese examples MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description." + } + } + }, + "EntryInfoPropertyObject": { + "title": "EntryInfoPropertyObject", + "required": [ + "properties", + "required", + "title", + "description", + "x-optimade-property", + "x-optimade-implementation", + "x-optimade-requirements", + "deprecated", + "enum", + "examples" + ], + "type": "object", + "properties": { + "properties": { + "title": "Properties", + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/EntryInfoProperty" + }, + "description": "Gives key-value pairs where each value is an inner Property Definition.\nThe defined property is a dictionary that can only contain keys present in this dictionary, and, if so, the corresponding value is described by the respective inner Property Definition.\n(Or, if the `type` field is the list \"object\" and \"null\", it can also be `null`.)" + }, + "required": { + "title": "Required", + "type": "array", + "items": { + "type": "string" + }, + "description": "The list MUST only contain strings.\n\nThe defined property MUST have keys that match all the strings in this list.\nOther keys present in the `properties` field are OPTIONAL in the defined property.\nIf not present or empty, all keys in `properties` are regarded as OPTIONAL." + }, + "maxProperties": { + "title": "Maxproperties", + "type": "integer" + }, + "minProperties": { + "title": "Minproperties", + "type": "integer" + }, + "dependentRequired": { + "title": "Dependentrequired", + "type": "object" + }, + "title": { + "title": "Title", + "type": "string", + "description": "A short single-line human-readable explanation of the defined property appropriate to show as part of a user interface." + }, + "description": { + "title": "Description", + "type": "string", + "description": "A human-readable multi-line description that explains the purpose, requirements, and conventions of the defined property.\n\nThe format SHOULD be a one-line description, followed by a new paragraph (two newlines), followed by a more detailed description of all the requirements and conventions of the defined property.\nFormatting in the text SHOULD use Markdown in the CommonMark v0.3 format." + }, + "x-optimade-property": { + "title": "X-Optimade-Property", + "allOf": [ + { + "$ref": "#/components/schemas/OptimadePropertyDefinition" + } + ], + "description": "Additional information to define the property that is not covered by fields in the JSON Schema standard." + }, + "x-optimade-unit": { + "title": "X-Optimade-Unit", + "type": "string", + "description": "A (compound) symbol for the physical unit in which the value of the defined property is given or one of the strings `dimensionless` or `inapplicable`." + }, + "x-optimade-implementation": { + "title": "X-Optimade-Implementation", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyImplementationInfo" + } + ], + "description": "A dictionary describing the level of OPTIMADE API functionality provided by the present implementation.\nIf an implementation omits this field in its response, a client interacting with that implementation SHOULD NOT make any assumptions about the availability of these features." + }, + "x-optimade-requirements": { + "title": "X-Optimade-Requirements", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyRequirementsInfo" + } + ], + "description": "A dictionary describing the level of OPTIMADE API functionality required by all implementations of this property.\nOmitting this field means the corresponding functionality is OPTIONAL." }, "type": { "title": "Type", + "anyOf": [ + { + "$ref": "#/components/schemas/AllowedJSONSchemaDataType" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/AllowedJSONSchemaDataType" + } + } + ], + "description": "A string or list that specifies the type of the defined property.\nIt MUST be one of:\n\n- One of the strings `\"boolean\"`, `\"object\"` (refers to an OPTIMADE dictionary), `\"array\"` (refers to an OPTIMADE list), `\"number\"` (refers to an OPTIMADE float), `\"string\"`, or `\"integer\"`.\n- A list where the first item MUST be one of the strings above, and the second item MUST be the string `\"null\"`." + }, + "deprecated": { + "title": "Deprecated", + "type": "boolean", + "description": " If `TRUE`, implementations SHOULD not use the defined property, and it MAY be removed in the future.\nIf `FALSE`, the defined property is not deprecated.\nThe field not being present means `FALSE`." + }, + "enum": { + "title": "Enum", + "type": "array", + "items": {}, + "description": "The defined property MUST take one of the values given in the provided list.\nThe items in the list MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description.\nIf this key is given, for `null` to be a valid value of the defined property, the list MUST contain a `null` value and the `type` MUST be a list where the second value is the string `\"null\"`." + }, + "examples": { + "title": "Examples", + "type": "array", + "items": {}, + "description": "A list of example values that the defined property can have.\nThese examples MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description." + } + } + }, + "EntryInfoPropertyString": { + "title": "EntryInfoPropertyString", + "required": [ + "title", + "description", + "x-optimade-property", + "x-optimade-implementation", + "x-optimade-requirements", + "deprecated", + "enum", + "examples" + ], + "type": "object", + "properties": { + "maxLength": { + "title": "Maxlength", + "type": "integer" + }, + "minLength": { + "title": "Minlength", + "type": "integer" + }, + "format": { + "$ref": "#/components/schemas/JSONSchemaStringFormat" + }, + "title": { + "title": "Title", + "type": "string", + "description": "A short single-line human-readable explanation of the defined property appropriate to show as part of a user interface." + }, + "description": { + "title": "Description", + "type": "string", + "description": "A human-readable multi-line description that explains the purpose, requirements, and conventions of the defined property.\n\nThe format SHOULD be a one-line description, followed by a new paragraph (two newlines), followed by a more detailed description of all the requirements and conventions of the defined property.\nFormatting in the text SHOULD use Markdown in the CommonMark v0.3 format." + }, + "x-optimade-property": { + "title": "X-Optimade-Property", + "allOf": [ + { + "$ref": "#/components/schemas/OptimadePropertyDefinition" + } + ], + "description": "Additional information to define the property that is not covered by fields in the JSON Schema standard." + }, + "x-optimade-unit": { + "title": "X-Optimade-Unit", + "type": "string", + "description": "A (compound) symbol for the physical unit in which the value of the defined property is given or one of the strings `dimensionless` or `inapplicable`." + }, + "x-optimade-implementation": { + "title": "X-Optimade-Implementation", "allOf": [ { - "$ref": "#/components/schemas/DataType" + "$ref": "#/components/schemas/PropertyImplementationInfo" } ], - "description": "The type of the property's value.\nThis MUST be any of the types defined in the Data types section.\nFor the purpose of compatibility with future versions of this specification, a client MUST accept values that are not `string` values specifying any of the OPTIMADE Data types, but MUST then also disregard the `type` field.\nNote, if the value is a nested type, only the outermost type should be reported.\nE.g., for the entry resource `structures`, the `species` property is defined as a list of dictionaries, hence its `type` value would be `list`." + "description": "A dictionary describing the level of OPTIMADE API functionality provided by the present implementation.\nIf an implementation omits this field in its response, a client interacting with that implementation SHOULD NOT make any assumptions about the availability of these features." + }, + "x-optimade-requirements": { + "title": "X-Optimade-Requirements", + "allOf": [ + { + "$ref": "#/components/schemas/PropertyRequirementsInfo" + } + ], + "description": "A dictionary describing the level of OPTIMADE API functionality required by all implementations of this property.\nOmitting this field means the corresponding functionality is OPTIONAL." + }, + "type": { + "title": "Type", + "anyOf": [ + { + "$ref": "#/components/schemas/AllowedJSONSchemaDataType" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/AllowedJSONSchemaDataType" + } + } + ], + "description": "A string or list that specifies the type of the defined property.\nIt MUST be one of:\n\n- One of the strings `\"boolean\"`, `\"object\"` (refers to an OPTIMADE dictionary), `\"array\"` (refers to an OPTIMADE list), `\"number\"` (refers to an OPTIMADE float), `\"string\"`, or `\"integer\"`.\n- A list where the first item MUST be one of the strings above, and the second item MUST be the string `\"null\"`." + }, + "deprecated": { + "title": "Deprecated", + "type": "boolean", + "description": " If `TRUE`, implementations SHOULD not use the defined property, and it MAY be removed in the future.\nIf `FALSE`, the defined property is not deprecated.\nThe field not being present means `FALSE`." + }, + "enum": { + "title": "Enum", + "type": "array", + "items": {}, + "description": "The defined property MUST take one of the values given in the provided list.\nThe items in the list MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description.\nIf this key is given, for `null` to be a valid value of the defined property, the list MUST contain a `null` value and the `type` MUST be a list where the second value is the string `\"null\"`." + }, + "examples": { + "title": "Examples", + "type": "array", + "items": {}, + "description": "A list of example values that the defined property can have.\nThese examples MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description." } } }, @@ -1647,7 +2249,26 @@ "title": "Properties", "type": "object", "additionalProperties": { - "$ref": "#/components/schemas/EntryInfoProperty" + "anyOf": [ + { + "$ref": "#/components/schemas/EntryInfoProperty" + }, + { + "$ref": "#/components/schemas/EntryInfoPropertyArray" + }, + { + "$ref": "#/components/schemas/EntryInfoPropertyInteger" + }, + { + "$ref": "#/components/schemas/EntryInfoPropertyNumber" + }, + { + "$ref": "#/components/schemas/EntryInfoPropertyObject" + }, + { + "$ref": "#/components/schemas/EntryInfoPropertyString" + } + ] }, "description": "A dictionary describing queryable properties for this entry type, where each key is a property name." }, @@ -1767,15 +2388,15 @@ "title": "Id", "type": "string", "description": "An entry's ID as defined in section Definition of Terms.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: MUST be supported by all implementations, MUST NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response.\n\n- **Examples**:\n - `\"db/1234567\"`\n - `\"cod/2000000\"`\n - `\"cod/2000000@1234567\"`\n - `\"nomad/L1234567890\"`\n - `\"42\"`", - "x-optimade-queryable": "must", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "must" }, "type": { "title": "Type", "type": "string", "description": "The name of the type of an entry.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: MUST be supported by all implementations, MUST NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response.\n - MUST be an existing entry type.\n - The entry of type `` and ID `` MUST be returned in response to a request for `//` under the versioned base URL.\n\n- **Example**: `\"structures\"`", - "x-optimade-queryable": "must", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "must" }, "links": { "title": "Links", @@ -1827,16 +2448,16 @@ "title": "Immutable Id", "type": "string", "description": "The entry's immutable ID (e.g., an UUID). This is important for databases having preferred IDs that point to \"the latest version\" of a record, but still offer access to older variants. This ID maps to the version-specific record, in case it changes in the future.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: OPTIONAL support in implementations, i.e., MAY be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n\n- **Examples**:\n - `\"8bd3e750-b477-41a0-9b11-3a799f21b44f\"`\n - `\"fjeiwoj,54;@=%<>#32\"` (Strings that are not URL-safe are allowed.)", - "x-optimade-queryable": "must", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "must" }, "last_modified": { "title": "Last Modified", "type": "string", "description": "Date and time representing when the entry was last modified.\n\n- **Type**: timestamp.\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response unless the query parameter `response_fields` is present and does not include this property.\n\n- **Example**:\n - As part of JSON response format: `\"2007-04-05T14:30:20Z\"` (i.e., encoded as an [RFC 3339 Internet Date/Time Format](https://tools.ietf.org/html/rfc3339#section-5.6) string.)", "format": "date-time", - "x-optimade-queryable": "must", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "must" } }, "description": "Contains key-value pairs representing the entry's properties." @@ -2163,6 +2784,18 @@ }, "description": "errors are not allowed" }, + "JSONSchemaStringFormat": { + "title": "JSONSchemaStringFormat", + "enum": [ + "date-time", + "date", + "time", + "duration", + "email", + "uri" + ], + "description": "An enumeration." + }, "JsonApi": { "title": "JsonApi", "type": "object", @@ -2235,8 +2868,8 @@ "title": "Id", "type": "string", "description": "An entry's ID as defined in section Definition of Terms.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: MUST be supported by all implementations, MUST NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response.\n\n- **Examples**:\n - `\"db/1234567\"`\n - `\"cod/2000000\"`\n - `\"cod/2000000@1234567\"`\n - `\"nomad/L1234567890\"`\n - `\"42\"`", - "x-optimade-queryable": "must", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "must" }, "type": { "title": "Type", @@ -2452,6 +3085,15 @@ "properties": {}, "description": "Non-standard meta-information that can not be represented as an attribute or relationship." }, + "OptimadeAllowedUnitStandard": { + "title": "OptimadeAllowedUnitStandard", + "enum": [ + "gnu units", + "ucum", + "qudt" + ], + "description": "An enumeration." + }, "OptimadeError": { "title": "OptimadeError", "required": [ @@ -2485,34 +3127,129 @@ }, "title": { "title": "Title", - "type": "string", - "description": "A short, human-readable summary of the problem. It **SHOULD NOT** change from occurrence to occurrence of the problem, except for purposes of localization." + "type": "string", + "description": "A short, human-readable summary of the problem. It **SHOULD NOT** change from occurrence to occurrence of the problem, except for purposes of localization." + }, + "detail": { + "title": "Detail", + "type": "string", + "description": "A human-readable explanation specific to this occurrence of the problem." + }, + "source": { + "title": "Source", + "allOf": [ + { + "$ref": "#/components/schemas/ErrorSource" + } + ], + "description": "An object containing references to the source of the error" + }, + "meta": { + "title": "Meta", + "allOf": [ + { + "$ref": "#/components/schemas/Meta" + } + ], + "description": "a meta object containing non-standard meta-information about the error." + } + }, + "description": "detail MUST be present" + }, + "OptimadePropertyDefinition": { + "title": "OptimadePropertyDefinition", + "required": [ + "property-uri", + "version", + "unit-definitions", + "resource-uris" + ], + "type": "object", + "properties": { + "property-uri": { + "title": "Property-Uri", + "type": "string", + "description": "A static URI identifier that is a URN or URL representing the specific version of the property.\nIt SHOULD NOT be changed as long as the property definition remains the same, and SHOULD be changed when the property definition changes.\n(If it is a URL, clients SHOULD NOT assign any interpretation to the response when resolving that URL.)" + }, + "version": { + "title": "Version", + "type": "string", + "description": "This string indicates the version of the property definition.\nThe string SHOULD be in the format described by the [semantic versioning v2](https://semver.org/spec/v2.0.0.html) standard." + }, + "unit-definitions": { + "title": "Unit-Definitions", + "type": "array", + "items": { + "$ref": "#/components/schemas/OptimadeUnitDefinition" + }, + "description": "A list of definitions of the symbols used in the Property Definition (including its nested levels) for physical units given as values of the `x-optimade-unit` field.\nThis field MUST be included if the defined property, at any level, includes an `x-optimade-unit` with a value that is not `dimensionless` or `inapplicable`." + }, + "resource-uris": { + "title": "Resource-Uris", + "type": "array", + "items": { + "$ref": "#/components/schemas/PropertyRemoteResource" + }, + "description": "A list of dictionaries that references remote resources that describe the property." + } + } + }, + "OptimadeUnitDefinition": { + "title": "OptimadeUnitDefinition", + "required": [ + "symbol", + "title", + "description", + "standard", + "resource-uris" + ], + "type": "object", + "properties": { + "symbol": { + "title": "Symbol", + "type": "string" + }, + "title": { + "title": "Title", + "type": "string" }, - "detail": { - "title": "Detail", - "type": "string", - "description": "A human-readable explanation specific to this occurrence of the problem." + "description": { + "title": "Description", + "type": "string" }, - "source": { - "title": "Source", - "allOf": [ - { - "$ref": "#/components/schemas/ErrorSource" - } - ], - "description": "An object containing references to the source of the error" + "standard": { + "$ref": "#/components/schemas/OptimadeUnitStandard" }, - "meta": { - "title": "Meta", - "allOf": [ - { - "$ref": "#/components/schemas/Meta" - } - ], - "description": "a meta object containing non-standard meta-information about the error." + "resource-uris": { + "title": "Resource-Uris", + "type": "array", + "items": { + "$ref": "#/components/schemas/UnitResourceURIs" + } } - }, - "description": "detail MUST be present" + } + }, + "OptimadeUnitStandard": { + "title": "OptimadeUnitStandard", + "required": [ + "name", + "version", + "symbol" + ], + "type": "object", + "properties": { + "name": { + "$ref": "#/components/schemas/OptimadeAllowedUnitStandard" + }, + "version": { + "title": "Version", + "type": "string" + }, + "symbol": { + "title": "Symbol", + "type": "string" + } + } }, "Periodicity": { "title": "Periodicity", @@ -2534,26 +3271,119 @@ "title": "Name", "type": "string", "description": "Full name of the person, REQUIRED.", - "x-optimade-queryable": "optional", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "optional" }, "firstname": { "title": "Firstname", "type": "string", "description": "First name of the person.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "lastname": { "title": "Lastname", "type": "string", "description": "Last name of the person.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" } }, "description": "A person, i.e., an author, editor or other." }, + "PropertyImplementationInfo": { + "title": "PropertyImplementationInfo", + "required": [ + "sortable", + "query-support", + "query-support-operators" + ], + "type": "object", + "properties": { + "sortable": { + "title": "Sortable", + "type": "boolean", + "description": "If `TRUE`, specifies that results can be sorted on this property.\n If `FALSE`, specifies that results cannot be sorted on this property.\n Omitting the field is equivalent to `FALSE`." + }, + "query-support": { + "allOf": [ + { + "$ref": "#/components/schemas/QuerySupport" + } + ], + "description": "Defines a required level of support in formulating queries on this field.\n\n The string MUST be one of the following:\n\n - `all mandatory`: the defined property MUST be queryable using the OPTIMADE filter language with support for all mandatory filter features.\n - `equality only`: the defined property MUST be queryable using the OPTIMADE filter language equality and inequality operators. Other filter language features do not need to be available.\n - `partial`: the defined property MUST be queryable with support for a subset of the filter language operators as specified by the field `query-support-operators`.\n - `none`: the defined property does not need to be queryable with any features of the filter language." + }, + "query-support-operators": { + "title": "Query-Support-Operators", + "type": "array", + "items": { + "type": "string" + }, + "description": "Defines the filter language features supported on this property.\n\nEach string in the list MUST be one of `<`, `<=`, `>`, `>=`, `=`, `!=`, `CONTAINS`, `STARTS WITH`, `ENDS WITH`:, `HAS`, `HAS ALL`, `HAS ANY`, `HAS ONLY`, `IS KNOWN`, `IS UNKNOWN` with the following meanings:\n\n- `<`, `<=`, `>`, `>=`, `=`, `!=`: indicating support for filtering this property using the respective operator.\n If the property is of Boolean type, support for `=` also designates support for boolean comparisons with the property being true that omit \":filter-fragment:`= TRUE`\", e.g., specifying that filtering for \"`is_yellow = TRUE`\" is supported also implies support for \"`is_yellow`\" (which means the same thing).\n Support for \"`NOT is_yellow`\" also follows.\n\n- `CONTAINS`, `STARTS WITH`, `ENDS WITH`: indicating support for substring filtering of this property using the respective operator. MUST NOT appear if the property is not of type String.\n\n- `HAS`, `HAS ALL`, `HAS ANY`: indicating support of the MANDATORY features for list property comparison using the respective operator. MUST NOT appear if the property is not of type List.\n\n- `HAS ONLY`: indicating support for list property comparison with all or a subset of the OPTIONAL constructs using this operator. MUST NOT appear if the property is not of type List.\n\n- `IS KNOWN`, `IS UNKNOWN`: indicating support for filtering this property on unknown values using the respective operator." + } + } + }, + "PropertyRemoteResource": { + "title": "PropertyRemoteResource", + "required": [ + "relation", + "uri" + ], + "type": "object", + "properties": { + "relation": { + "title": "Relation", + "type": "string", + "description": "A human-readable description of the relationship between the property and the remote resource, e.g., a 'natural language description'." + }, + "uri": { + "title": "Uri", + "type": "string", + "description": "A URI of the external resource (which MAY be a resolvable URL)." + } + } + }, + "PropertyRequirementsInfo": { + "title": "PropertyRequirementsInfo", + "required": [ + "sortable", + "query-support", + "query-support-operators", + "support" + ], + "type": "object", + "properties": { + "sortable": { + "title": "Sortable", + "type": "boolean", + "description": "If `TRUE`, specifies that results can be sorted on this property.\n If `FALSE`, specifies that results cannot be sorted on this property.\n Omitting the field is equivalent to `FALSE`." + }, + "query-support": { + "allOf": [ + { + "$ref": "#/components/schemas/QuerySupport" + } + ], + "description": "Defines a required level of support in formulating queries on this field.\n\n The string MUST be one of the following:\n\n - `all mandatory`: the defined property MUST be queryable using the OPTIMADE filter language with support for all mandatory filter features.\n - `equality only`: the defined property MUST be queryable using the OPTIMADE filter language equality and inequality operators. Other filter language features do not need to be available.\n - `partial`: the defined property MUST be queryable with support for a subset of the filter language operators as specified by the field `query-support-operators`.\n - `none`: the defined property does not need to be queryable with any features of the filter language." + }, + "query-support-operators": { + "title": "Query-Support-Operators", + "type": "array", + "items": { + "type": "string" + }, + "description": "Defines the filter language features supported on this property.\n\nEach string in the list MUST be one of `<`, `<=`, `>`, `>=`, `=`, `!=`, `CONTAINS`, `STARTS WITH`, `ENDS WITH`:, `HAS`, `HAS ALL`, `HAS ANY`, `HAS ONLY`, `IS KNOWN`, `IS UNKNOWN` with the following meanings:\n\n- `<`, `<=`, `>`, `>=`, `=`, `!=`: indicating support for filtering this property using the respective operator.\n If the property is of Boolean type, support for `=` also designates support for boolean comparisons with the property being true that omit \":filter-fragment:`= TRUE`\", e.g., specifying that filtering for \"`is_yellow = TRUE`\" is supported also implies support for \"`is_yellow`\" (which means the same thing).\n Support for \"`NOT is_yellow`\" also follows.\n\n- `CONTAINS`, `STARTS WITH`, `ENDS WITH`: indicating support for substring filtering of this property using the respective operator. MUST NOT appear if the property is not of type String.\n\n- `HAS`, `HAS ALL`, `HAS ANY`: indicating support of the MANDATORY features for list property comparison using the respective operator. MUST NOT appear if the property is not of type List.\n\n- `HAS ONLY`: indicating support for list property comparison with all or a subset of the OPTIONAL constructs using this operator. MUST NOT appear if the property is not of type List.\n\n- `IS KNOWN`, `IS UNKNOWN`: indicating support for filtering this property on unknown values using the respective operator." + }, + "support": { + "allOf": [ + { + "$ref": "#/components/schemas/SupportLevel" + } + ], + "description": "Describes the minimal required level of support for the Property by an implementation.\n\n This field SHOULD only appear in a `x-optimade-requirements` that is at the outermost level of a Property Definition, as the meaning of its inclusion on other levels is not defined.\n The string MUST be one of the following:\n\n - `must`: the defined property MUST be recognized by the implementation (e.g., in filter strings) and MUST NOT be `null`.\n - `should`: the defined property MUST be recognized by the implementation (e.g., in filter strings) and SHOULD NOT be `null`.\n - `may`: it is OPTIONAL for the implementation to recognize the defined property and it MAY be equal to `null`." + } + } + }, "Provider": { "title": "Provider", "required": [ @@ -2597,6 +3427,16 @@ }, "description": "Information on the database provider of the implementation." }, + "QuerySupport": { + "title": "QuerySupport", + "enum": [ + "all mandatory", + "equality only", + "partial", + "none" + ], + "description": "An enumeration." + }, "ReferenceRelationship": { "title": "ReferenceRelationship", "type": "object", @@ -2651,8 +3491,8 @@ "title": "Id", "type": "string", "description": "An entry's ID as defined in section Definition of Terms.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: MUST be supported by all implementations, MUST NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response.\n\n- **Examples**:\n - `\"db/1234567\"`\n - `\"cod/2000000\"`\n - `\"cod/2000000@1234567\"`\n - `\"nomad/L1234567890\"`\n - `\"42\"`", - "x-optimade-queryable": "must", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "must" }, "type": { "title": "Type", @@ -2660,8 +3500,8 @@ "type": "string", "description": "The name of the type of an entry.\n- **Type**: string.\n- **Requirements/Conventions**:\n - **Support**: MUST be supported by all implementations, MUST NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response.\n - MUST be an existing entry type.\n - The entry of type and ID MUST be returned in response to a request for `//` under the versioned base URL.\n- **Example**: `\"structures\"`", "default": "references", - "x-optimade-queryable": "must", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "must" }, "links": { "title": "Links", @@ -2707,16 +3547,16 @@ "title": "Immutable Id", "type": "string", "description": "The entry's immutable ID (e.g., an UUID). This is important for databases having preferred IDs that point to \"the latest version\" of a record, but still offer access to older variants. This ID maps to the version-specific record, in case it changes in the future.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: OPTIONAL support in implementations, i.e., MAY be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n\n- **Examples**:\n - `\"8bd3e750-b477-41a0-9b11-3a799f21b44f\"`\n - `\"fjeiwoj,54;@=%<>#32\"` (Strings that are not URL-safe are allowed.)", - "x-optimade-queryable": "must", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "must" }, "last_modified": { "title": "Last Modified", "type": "string", "description": "Date and time representing when the entry was last modified.\n\n- **Type**: timestamp.\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response unless the query parameter `response_fields` is present and does not include this property.\n\n- **Example**:\n - As part of JSON response format: `\"2007-04-05T14:30:20Z\"` (i.e., encoded as an [RFC 3339 Internet Date/Time Format](https://tools.ietf.org/html/rfc3339#section-5.6) string.)", "format": "date-time", - "x-optimade-queryable": "must", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "must" }, "authors": { "title": "Authors", @@ -2725,8 +3565,8 @@ "$ref": "#/components/schemas/Person" }, "description": "List of person objects containing the authors of the reference.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "editors": { "title": "Editors", @@ -2735,15 +3575,15 @@ "$ref": "#/components/schemas/Person" }, "description": "List of person objects containing the editors of the reference.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "doi": { "title": "Doi", "type": "string", "description": "The digital object identifier of the reference.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "url": { "title": "Url", @@ -2759,155 +3599,155 @@ "title": "Address", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "annote": { "title": "Annote", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "booktitle": { "title": "Booktitle", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "chapter": { "title": "Chapter", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "crossref": { "title": "Crossref", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "edition": { "title": "Edition", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "howpublished": { "title": "Howpublished", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "institution": { "title": "Institution", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "journal": { "title": "Journal", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "key": { "title": "Key", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "month": { "title": "Month", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "note": { "title": "Note", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "number": { "title": "Number", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "organization": { "title": "Organization", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "pages": { "title": "Pages", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "publisher": { "title": "Publisher", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "school": { "title": "School", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "series": { "title": "Series", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "title": { "title": "Title", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "bib_type": { "title": "Bib Type", "type": "string", "description": "Type of the reference, corresponding to the **type** property in the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "volume": { "title": "Volume", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "year": { "title": "Year", "type": "string", "description": "Meaning of property matches the BiBTeX specification.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" } }, "description": "Model that stores the attributes of a reference.\n\nMany properties match the meaning described in the\n[BibTeX specification](http://bibtexml.sourceforge.net/btxdoc.pdf)." @@ -3329,8 +4169,8 @@ "title": "Name", "type": "string", "description": "Gives the name of the species; the **name** value MUST be unique in the `species` list.", - "x-optimade-queryable": "optional", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "optional" }, "chemical_symbols": { "title": "Chemical Symbols", @@ -3339,8 +4179,8 @@ "type": "string" }, "description": "MUST be a list of strings of all chemical elements composing this species. Each item of the list MUST be one of the following:\n\n- a valid chemical-element symbol, or\n- the special value `\"X\"` to represent a non-chemical element, or\n- the special value `\"vacancy\"` to represent that this site has a non-zero probability of having a vacancy (the respective probability is indicated in the `concentration` list, see below).\n\nIf any one entry in the `species` list has a `chemical_symbols` list that is longer than 1 element, the correct flag MUST be set in the list `structure_features`.", - "x-optimade-queryable": "optional", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "optional" }, "concentration": { "title": "Concentration", @@ -3349,8 +4189,8 @@ "type": "number" }, "description": "MUST be a list of floats, with same length as `chemical_symbols`. The numbers represent the relative concentration of the corresponding chemical symbol in this species. The numbers SHOULD sum to one. Cases in which the numbers do not sum to one typically fall only in the following two categories:\n\n- Numerical errors when representing float numbers in fixed precision, e.g. for two chemical symbols with concentrations `1/3` and `2/3`, the concentration might look something like `[0.33333333333, 0.66666666666]`. If the client is aware that the sum is not one because of numerical precision, it can renormalize the values so that the sum is exactly one.\n- Experimental errors in the data present in the database. In this case, it is the responsibility of the client to decide how to process the data.\n\nNote that concentrations are uncorrelated between different site (even of the same species).", - "x-optimade-queryable": "optional", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "optional" }, "mass": { "title": "Mass", @@ -3359,16 +4199,16 @@ "type": "number" }, "description": "If present MUST be a list of floats expressed in a.m.u.\nElements denoting vacancies MUST have masses equal to 0.", - "x-optimade-queryable": "optional", "x-optimade-support": "optional", + "x-optimade-queryable": "optional", "x-optimade-unit": "a.m.u." }, "original_name": { "title": "Original Name", "type": "string", "description": "Can be any valid Unicode string, and SHOULD contain (if specified) the name of the species that is used internally in the source database.\n\nNote: With regards to \"source database\", we refer to the immediate source being queried via the OPTIMADE API implementation.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "attached": { "title": "Attached", @@ -3377,8 +4217,8 @@ "type": "string" }, "description": "If provided MUST be a list of length 1 or more of strings of chemical symbols for the elements attached to this site, or \"X\" for a non-chemical element.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "nattached": { "title": "Nattached", @@ -3387,8 +4227,8 @@ "type": "integer" }, "description": "If provided MUST be a list of length 1 or more of integers indicating the number of attached atoms of the kind specified in the value of the :field:`attached` key.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" } }, "description": "A list describing the species of the sites of this structure.\n\nSpecies can represent pure chemical elements, virtual-crystal atoms representing a\nstatistical occupation of a given site by multiple chemical elements, and/or a\nlocation to which there are attached atoms, i.e., atoms whose precise location are\nunknown beyond that they are attached to that position (frequently used to indicate\nhydrogen atoms attached to another element, e.g., a carbon with three attached\nhydrogens might represent a methyl group, -CH3).\n\n- **Examples**:\n - `[ {\"name\": \"Ti\", \"chemical_symbols\": [\"Ti\"], \"concentration\": [1.0]} ]`: any site with this species is occupied by a Ti atom.\n - `[ {\"name\": \"Ti\", \"chemical_symbols\": [\"Ti\", \"vacancy\"], \"concentration\": [0.9, 0.1]} ]`: any site with this species is occupied by a Ti atom with 90 % probability, and has a vacancy with 10 % probability.\n - `[ {\"name\": \"BaCa\", \"chemical_symbols\": [\"vacancy\", \"Ba\", \"Ca\"], \"concentration\": [0.05, 0.45, 0.5], \"mass\": [0.0, 137.327, 40.078]} ]`: any site with this species is occupied by a Ba atom with 45 % probability, a Ca atom with 50 % probability, and by a vacancy with 5 % probability. The mass of this site is (on average) 88.5 a.m.u.\n - `[ {\"name\": \"C12\", \"chemical_symbols\": [\"C\"], \"concentration\": [1.0], \"mass\": [12.0]} ]`: any site with this species is occupied by a carbon isotope with mass 12.\n - `[ {\"name\": \"C13\", \"chemical_symbols\": [\"C\"], \"concentration\": [1.0], \"mass\": [13.0]} ]`: any site with this species is occupied by a carbon isotope with mass 13.\n - `[ {\"name\": \"CH3\", \"chemical_symbols\": [\"C\"], \"concentration\": [1.0], \"attached\": [\"H\"], \"nattached\": [3]} ]`: any site with this species is occupied by a methyl group, -CH3, which is represented without specifying precise positions of the hydrogen atoms." @@ -3457,8 +4297,8 @@ "title": "Id", "type": "string", "description": "An entry's ID as defined in section Definition of Terms.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: MUST be supported by all implementations, MUST NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response.\n\n- **Examples**:\n - `\"db/1234567\"`\n - `\"cod/2000000\"`\n - `\"cod/2000000@1234567\"`\n - `\"nomad/L1234567890\"`\n - `\"42\"`", - "x-optimade-queryable": "must", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "must" }, "type": { "title": "Type", @@ -3466,8 +4306,8 @@ "type": "string", "description": "The name of the type of an entry.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: MUST be supported by all implementations, MUST NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response.\n - MUST be an existing entry type.\n - The entry of type `` and ID `` MUST be returned in response to a request for `//` under the versioned base URL.\n\n- **Examples**:\n - `\"structures\"`", "default": "structures", - "x-optimade-queryable": "must", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "must" }, "links": { "title": "Links", @@ -3527,8 +4367,8 @@ "title": "Immutable Id", "type": "string", "description": "The entry's immutable ID (e.g., an UUID). This is important for databases having preferred IDs that point to \"the latest version\" of a record, but still offer access to older variants. This ID maps to the version-specific record, in case it changes in the future.\n\n- **Type**: string.\n\n- **Requirements/Conventions**:\n - **Support**: OPTIONAL support in implementations, i.e., MAY be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n\n- **Examples**:\n - `\"8bd3e750-b477-41a0-9b11-3a799f21b44f\"`\n - `\"fjeiwoj,54;@=%<>#32\"` (Strings that are not URL-safe are allowed.)", - "x-optimade-queryable": "must", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "must" }, "last_modified": { "title": "Last Modified", @@ -3536,8 +4376,8 @@ "description": "Date and time representing when the entry was last modified.\n\n- **Type**: timestamp.\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - **Response**: REQUIRED in the response unless the query parameter `response_fields` is present and does not include this property.\n\n- **Example**:\n - As part of JSON response format: `\"2007-04-05T14:30:20Z\"` (i.e., encoded as an [RFC 3339 Internet Date/Time Format](https://tools.ietf.org/html/rfc3339#section-5.6) string.)", "format": "date-time", "nullable": true, - "x-optimade-queryable": "must", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "must" }, "elements": { "title": "Elements", @@ -3547,16 +4387,16 @@ }, "description": "The chemical symbols of the different elements present in the structure.\n\n- **Type**: list of strings.\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - The strings are the chemical symbols, i.e., either a single uppercase letter or an uppercase letter followed by a number of lowercase letters.\n - The order MUST be alphabetical.\n - MUST refer to the same elements in the same order, and therefore be of the same length, as `elements_ratios`, if the latter is provided.\n - Note: This property SHOULD NOT contain the string \"X\" to indicate non-chemical elements or \"vacancy\" to indicate vacancies (in contrast to the field `chemical_symbols` for the `species` property).\n\n- **Examples**:\n - `[\"Si\"]`\n - `[\"Al\",\"O\",\"Si\"]`\n\n- **Query examples**:\n - A filter that matches all records of structures that contain Si, Al **and** O, and possibly other elements: `elements HAS ALL \"Si\", \"Al\", \"O\"`.\n - To match structures with exactly these three elements, use `elements HAS ALL \"Si\", \"Al\", \"O\" AND elements LENGTH 3`.\n - Note: length queries on this property can be equivalently formulated by filtering on the `nelements`_ property directly.", "nullable": true, - "x-optimade-queryable": "must", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "must" }, "nelements": { "title": "Nelements", "type": "integer", "description": "Number of different elements in the structure as an integer.\n\n- **Type**: integer\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - MUST be equal to the lengths of the list properties `elements` and `elements_ratios`, if they are provided.\n\n- **Examples**:\n - `3`\n\n- **Querying**:\n - Note: queries on this property can equivalently be formulated using `elements LENGTH`.\n - A filter that matches structures that have exactly 4 elements: `nelements=4`.\n - A filter that matches structures that have between 2 and 7 elements: `nelements>=2 AND nelements<=7`.", "nullable": true, - "x-optimade-queryable": "must", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "must" }, "elements_ratios": { "title": "Elements Ratios", @@ -3566,16 +4406,16 @@ }, "description": "Relative proportions of different elements in the structure.\n\n- **Type**: list of floats\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - Composed by the proportions of elements in the structure as a list of floating point numbers.\n - The sum of the numbers MUST be 1.0 (within floating point accuracy)\n - MUST refer to the same elements in the same order, and therefore be of the same length, as `elements`, if the latter is provided.\n\n- **Examples**:\n - `[1.0]`\n - `[0.3333333333333333, 0.2222222222222222, 0.4444444444444444]`\n\n- **Query examples**:\n - Note: Useful filters can be formulated using the set operator syntax for correlated values.\n However, since the values are floating point values, the use of equality comparisons is generally inadvisable.\n - OPTIONAL: a filter that matches structures where approximately 1/3 of the atoms in the structure are the element Al is: `elements:elements_ratios HAS ALL \"Al\":>0.3333, \"Al\":<0.3334`.", "nullable": true, - "x-optimade-queryable": "must", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "must" }, "chemical_formula_descriptive": { "title": "Chemical Formula Descriptive", "type": "string", "description": "The chemical formula for a structure as a string in a form chosen by the API implementation.\n\n- **Type**: string\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - The chemical formula is given as a string consisting of properly capitalized element symbols followed by integers or decimal numbers, balanced parentheses, square, and curly brackets `(`,`)`, `[`,`]`, `{`, `}`, commas, the `+`, `-`, `:` and `=` symbols. The parentheses are allowed to be followed by a number. Spaces are allowed anywhere except within chemical symbols. The order of elements and any groupings indicated by parentheses or brackets are chosen freely by the API implementation.\n - The string SHOULD be arithmetically consistent with the element ratios in the `chemical_formula_reduced` property.\n - It is RECOMMENDED, but not mandatory, that symbols, parentheses and brackets, if used, are used with the meanings prescribed by [IUPAC's Nomenclature of Organic Chemistry](https://www.qmul.ac.uk/sbcs/iupac/bibliog/blue.html).\n\n- **Examples**:\n - `\"(H2O)2 Na\"`\n - `\"NaCl\"`\n - `\"CaCO3\"`\n - `\"CCaO3\"`\n - `\"(CH3)3N+ - [CH2]2-OH = Me3N+ - CH2 - CH2OH\"`\n\n- **Query examples**:\n - Note: the free-form nature of this property is likely to make queries on it across different databases inconsistent.\n - A filter that matches an exactly given formula: `chemical_formula_descriptive=\"(H2O)2 Na\"`.\n - A filter that does a partial match: `chemical_formula_descriptive CONTAINS \"H2O\"`.", "nullable": true, - "x-optimade-queryable": "must", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "must" }, "chemical_formula_reduced": { "title": "Chemical Formula Reduced", @@ -3583,16 +4423,16 @@ "type": "string", "description": "The reduced chemical formula for a structure as a string with element symbols and integer chemical proportion numbers.\nThe proportion number MUST be omitted if it is 1.\n\n- **Type**: string\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: MUST be a queryable property.\n However, support for filters using partial string matching with this property is OPTIONAL (i.e., BEGINS WITH, ENDS WITH, and CONTAINS).\n Intricate queries on formula components are instead suggested to be formulated using set-type filter operators on the multi valued `elements` and `elements_ratios` properties.\n - Element symbols MUST have proper capitalization (e.g., `\"Si\"`, not `\"SI\"` for \"silicon\").\n - Elements MUST be placed in alphabetical order, followed by their integer chemical proportion number.\n - For structures with no partial occupation, the chemical proportion numbers are the smallest integers for which the chemical proportion is exactly correct.\n - For structures with partial occupation, the chemical proportion numbers are integers that within reasonable approximation indicate the correct chemical proportions. The precise details of how to perform the rounding is chosen by the API implementation.\n - No spaces or separators are allowed.\n\n- **Examples**:\n - `\"H2NaO\"`\n - `\"ClNa\"`\n - `\"CCaO3\"`\n\n- **Query examples**:\n - A filter that matches an exactly given formula is `chemical_formula_reduced=\"H2NaO\"`.", "nullable": true, - "x-optimade-queryable": "must", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "must" }, "chemical_formula_hill": { "title": "Chemical Formula Hill", "pattern": "^([A-Z][a-z]?([2-9]|[1-9]\\d+)?)+$", "type": "string", "description": "The chemical formula for a structure in [Hill form](https://dx.doi.org/10.1021/ja02046a005) with element symbols followed by integer chemical proportion numbers. The proportion number MUST be omitted if it is 1.\n\n- **Type**: string\n\n- **Requirements/Conventions**:\n - **Support**: OPTIONAL support in implementations, i.e., MAY be `null`.\n - **Query**: Support for queries on this property is OPTIONAL.\n If supported, only a subset of the filter features MAY be supported.\n - The overall scale factor of the chemical proportions is chosen such that the resulting values are integers that indicate the most chemically relevant unit of which the system is composed.\n For example, if the structure is a repeating unit cell with four hydrogens and four oxygens that represents two hydroperoxide molecules, `chemical_formula_hill` is `\"H2O2\"` (i.e., not `\"HO\"`, nor `\"H4O4\"`).\n - If the chemical insight needed to ascribe a Hill formula to the system is not present, the property MUST be handled as unset.\n - Element symbols MUST have proper capitalization (e.g., `\"Si\"`, not `\"SI\"` for \"silicon\").\n - Elements MUST be placed in [Hill order](https://dx.doi.org/10.1021/ja02046a005), followed by their integer chemical proportion number.\n Hill order means: if carbon is present, it is placed first, and if also present, hydrogen is placed second.\n After that, all other elements are ordered alphabetically.\n If carbon is not present, all elements are ordered alphabetically.\n - If the system has sites with partial occupation and the total occupations of each element do not all sum up to integers, then the Hill formula SHOULD be handled as unset.\n - No spaces or separators are allowed.\n\n- **Examples**:\n - `\"H2O2\"`\n\n- **Query examples**:\n - A filter that matches an exactly given formula is `chemical_formula_hill=\"H2O2\"`.", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "chemical_formula_anonymous": { "title": "Chemical Formula Anonymous", @@ -3600,8 +4440,8 @@ "type": "string", "description": "The anonymous formula is the `chemical_formula_reduced`, but where the elements are instead first ordered by their chemical proportion number, and then, in order left to right, replaced by anonymous symbols A, B, C, ..., Z, Aa, Ba, ..., Za, Ab, Bb, ... and so on.\n\n- **Type**: string\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: MUST be a queryable property.\n However, support for filters using partial string matching with this property is OPTIONAL (i.e., BEGINS WITH, ENDS WITH, and CONTAINS).\n\n- **Examples**:\n - `\"A2B\"`\n - `\"A42B42C16D12E10F9G5\"`\n\n- **Querying**:\n - A filter that matches an exactly given formula is `chemical_formula_anonymous=\"A2B\"`.", "nullable": true, - "x-optimade-queryable": "must", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "must" }, "dimension_types": { "title": "Dimension Types", @@ -3621,8 +4461,8 @@ "type": "integer", "description": "An integer specifying the number of periodic dimensions in the structure, equivalent to the number of non-zero entries in `dimension_types`.\n\n- **Type**: integer\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n - The integer value MUST be between 0 and 3 inclusive and MUST be equal to the sum of the items in the `dimension_types` property.\n - This property only reflects the treatment of the lattice vectors provided for the structure, and not any physical interpretation of the dimensionality of its contents.\n\n- **Examples**:\n - `2` should be indicated in cases where `dimension_types` is any of `[1, 1, 0]`, `[1, 0, 1]`, `[0, 1, 1]`.\n\n- **Query examples**:\n - Match only structures with exactly 3 periodic dimensions: `nperiodic_dimensions=3`\n - Match all structures with 2 or fewer periodic dimensions: `nperiodic_dimensions<=2`", "nullable": true, - "x-optimade-queryable": "must", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "must" }, "lattice_vectors": { "title": "Lattice Vectors", @@ -3640,8 +4480,8 @@ "description": "The three lattice vectors in Cartesian coordinates, in \u00e5ngstr\u00f6m (\u00c5).\n\n- **Type**: list of list of floats or unknown values.\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: Support for queries on this property is OPTIONAL.\n If supported, filters MAY support only a subset of comparison operators.\n - MUST be a list of three vectors *a*, *b*, and *c*, where each of the vectors MUST BE a list of the vector's coordinates along the x, y, and z Cartesian coordinates.\n (Therefore, the first index runs over the three lattice vectors and the second index runs over the x, y, z Cartesian coordinates).\n - For databases that do not define an absolute Cartesian system (e.g., only defining the length and angles between vectors), the first lattice vector SHOULD be set along *x* and the second on the *xy*-plane.\n - MUST always contain three vectors of three coordinates each, independently of the elements of property `dimension_types`.\n The vectors SHOULD by convention be chosen so the determinant of the `lattice_vectors` matrix is different from zero.\n The vectors in the non-periodic directions have no significance beyond fulfilling these requirements.\n - The coordinates of the lattice vectors of non-periodic dimensions (i.e., those dimensions for which `dimension_types` is `0`) MAY be given as a list of all `null` values.\n If a lattice vector contains the value `null`, all coordinates of that lattice vector MUST be `null`.\n\n- **Examples**:\n - `[[4.0,0.0,0.0],[0.0,4.0,0.0],[0.0,1.0,4.0]]` represents a cell, where the first vector is `(4, 0, 0)`, i.e., a vector aligned along the `x` axis of length 4 \u00c5; the second vector is `(0, 4, 0)`; and the third vector is `(0, 1, 4)`.", "nullable": true, "x-optimade-queryable": "optional", - "x-optimade-support": "should", - "x-optimade-unit": "\u00c5" + "x-optimade-unit": "\u00c5", + "x-optimade-support": "should" }, "cartesian_site_positions": { "title": "Cartesian Site Positions", @@ -3657,16 +4497,16 @@ "description": "Cartesian positions of each site in the structure.\nA site is usually used to describe positions of atoms; what atoms can be encountered at a given site is conveyed by the `species_at_sites` property, and the species themselves are described in the `species` property.\n\n- **Type**: list of list of floats\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: Support for queries on this property is OPTIONAL.\n If supported, filters MAY support only a subset of comparison operators.\n - It MUST be a list of length equal to the number of sites in the structure, where every element is a list of the three Cartesian coordinates of a site expressed as float values in the unit angstrom (\u00c5).\n - An entry MAY have multiple sites at the same Cartesian position (for a relevant use of this, see e.g., the property `assemblies`).\n\n- **Examples**:\n - `[[0,0,0],[0,0,2]]` indicates a structure with two sites, one sitting at the origin and one along the (positive) *z*-axis, 2 \u00c5 away from the origin.", "nullable": true, "x-optimade-queryable": "optional", - "x-optimade-support": "should", - "x-optimade-unit": "\u00c5" + "x-optimade-unit": "\u00c5", + "x-optimade-support": "should" }, "nsites": { "title": "Nsites", "type": "integer", "description": "An integer specifying the length of the `cartesian_site_positions` property.\n\n- **Type**: integer\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: MUST be a queryable property with support for all mandatory filter features.\n\n- **Examples**:\n - `42`\n\n- **Query examples**:\n - Match only structures with exactly 4 sites: `nsites=4`\n - Match structures that have between 2 and 7 sites: `nsites>=2 AND nsites<=7`", "nullable": true, - "x-optimade-queryable": "must", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "must" }, "species": { "title": "Species", @@ -3676,8 +4516,8 @@ }, "description": "A list describing the species of the sites of this structure.\nSpecies can represent pure chemical elements, virtual-crystal atoms representing a statistical occupation of a given site by multiple chemical elements, and/or a location to which there are attached atoms, i.e., atoms whose precise location are unknown beyond that they are attached to that position (frequently used to indicate hydrogen atoms attached to another element, e.g., a carbon with three attached hydrogens might represent a methyl group, -CH3).\n\n- **Type**: list of dictionary with keys:\n - `name`: string (REQUIRED)\n - `chemical_symbols`: list of strings (REQUIRED)\n - `concentration`: list of float (REQUIRED)\n - `attached`: list of strings (REQUIRED)\n - `nattached`: list of integers (OPTIONAL)\n - `mass`: list of floats (OPTIONAL)\n - `original_name`: string (OPTIONAL).\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: Support for queries on this property is OPTIONAL.\n If supported, filters MAY support only a subset of comparison operators.\n - Each list member MUST be a dictionary with the following keys:\n - **name**: REQUIRED; gives the name of the species; the **name** value MUST be unique in the `species` list;\n - **chemical_symbols**: REQUIRED; MUST be a list of strings of all chemical elements composing this species.\n Each item of the list MUST be one of the following:\n - a valid chemical-element symbol, or\n - the special value `\"X\"` to represent a non-chemical element, or\n - the special value `\"vacancy\"` to represent that this site has a non-zero probability of having a vacancy (the respective probability is indicated in the `concentration` list, see below).\n\n If any one entry in the `species` list has a `chemical_symbols` list that is longer than 1 element, the correct flag MUST be set in the list `structure_features`.\n\n - **concentration**: REQUIRED; MUST be a list of floats, with same length as `chemical_symbols`.\n The numbers represent the relative concentration of the corresponding chemical symbol in this species.\n The numbers SHOULD sum to one. Cases in which the numbers do not sum to one typically fall only in the following two categories:\n\n - Numerical errors when representing float numbers in fixed precision, e.g. for two chemical symbols with concentrations `1/3` and `2/3`, the concentration might look something like `[0.33333333333, 0.66666666666]`. If the client is aware that the sum is not one because of numerical precision, it can renormalize the values so that the sum is exactly one.\n - Experimental errors in the data present in the database. In this case, it is the responsibility of the client to decide how to process the data.\n\n Note that concentrations are uncorrelated between different sites (even of the same species).\n\n - **attached**: OPTIONAL; if provided MUST be a list of length 1 or more of strings of chemical symbols for the elements attached to this site, or \"X\" for a non-chemical element.\n\n - **nattached**: OPTIONAL; if provided MUST be a list of length 1 or more of integers indicating the number of attached atoms of the kind specified in the value of the `attached` key.\n\n The implementation MUST include either both or none of the `attached` and `nattached` keys, and if they are provided, they MUST be of the same length.\n Furthermore, if they are provided, the `structure_features` property MUST include the string `site_attachments`.\n\n - **mass**: OPTIONAL. If present MUST be a list of floats, with the same length as `chemical_symbols`, providing element masses expressed in a.m.u.\n Elements denoting vacancies MUST have masses equal to 0.\n\n - **original_name**: OPTIONAL. Can be any valid Unicode string, and SHOULD contain (if specified) the name of the species that is used internally in the source database.\n\n Note: With regards to \"source database\", we refer to the immediate source being queried via the OPTIMADE API implementation.\n\n The main use of this field is for source databases that use species names, containing characters that are not allowed (see description of the list property `species_at_sites`).\n\n - For systems that have only species formed by a single chemical symbol, and that have at most one species per chemical symbol, SHOULD use the chemical symbol as species name (e.g., `\"Ti\"` for titanium, `\"O\"` for oxygen, etc.)\n However, note that this is OPTIONAL, and client implementations MUST NOT assume that the key corresponds to a chemical symbol, nor assume that if the species name is a valid chemical symbol, that it represents a species with that chemical symbol.\n This means that a species `{\"name\": \"C\", \"chemical_symbols\": [\"Ti\"], \"concentration\": [1.0]}` is valid and represents a titanium species (and *not* a carbon species).\n - It is NOT RECOMMENDED that a structure includes species that do not have at least one corresponding site.\n\n- **Examples**:\n - `[ {\"name\": \"Ti\", \"chemical_symbols\": [\"Ti\"], \"concentration\": [1.0]} ]`: any site with this species is occupied by a Ti atom.\n - `[ {\"name\": \"Ti\", \"chemical_symbols\": [\"Ti\", \"vacancy\"], \"concentration\": [0.9, 0.1]} ]`: any site with this species is occupied by a Ti atom with 90 % probability, and has a vacancy with 10 % probability.\n - `[ {\"name\": \"BaCa\", \"chemical_symbols\": [\"vacancy\", \"Ba\", \"Ca\"], \"concentration\": [0.05, 0.45, 0.5], \"mass\": [0.0, 137.327, 40.078]} ]`: any site with this species is occupied by a Ba atom with 45 % probability, a Ca atom with 50 % probability, and by a vacancy with 5 % probability. The mass of this site is (on average) 88.5 a.m.u.\n - `[ {\"name\": \"C12\", \"chemical_symbols\": [\"C\"], \"concentration\": [1.0], \"mass\": [12.0]} ]`: any site with this species is occupied by a carbon isotope with mass 12.\n - `[ {\"name\": \"C13\", \"chemical_symbols\": [\"C\"], \"concentration\": [1.0], \"mass\": [13.0]} ]`: any site with this species is occupied by a carbon isotope with mass 13.\n - `[ {\"name\": \"CH3\", \"chemical_symbols\": [\"C\"], \"concentration\": [1.0], \"attached\": [\"H\"], \"nattached\": [3]} ]`: any site with this species is occupied by a methyl group, -CH3, which is represented without specifying precise positions of the hydrogen atoms.", "nullable": true, - "x-optimade-queryable": "optional", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "optional" }, "species_at_sites": { "title": "Species At Sites", @@ -3687,8 +4527,8 @@ }, "description": "Name of the species at each site (where values for sites are specified with the same order of the property `cartesian_site_positions`).\nThe properties of the species are found in the property `species`.\n\n- **Type**: list of strings.\n\n- **Requirements/Conventions**:\n - **Support**: SHOULD be supported by all implementations, i.e., SHOULD NOT be `null`.\n - **Query**: Support for queries on this property is OPTIONAL.\n If supported, filters MAY support only a subset of comparison operators.\n - MUST have length equal to the number of sites in the structure (first dimension of the list property `cartesian_site_positions`).\n - Each species name mentioned in the `species_at_sites` list MUST be described in the list property `species` (i.e. for each value in the `species_at_sites` list there MUST exist exactly one dictionary in the `species` list with the `name` attribute equal to the corresponding `species_at_sites` value).\n - Each site MUST be associated only to a single species.\n **Note**: However, species can represent mixtures of atoms, and multiple species MAY be defined for the same chemical element.\n This latter case is useful when different atoms of the same type need to be grouped or distinguished, for instance in simulation codes to assign different initial spin states.\n\n- **Examples**:\n - `[\"Ti\",\"O2\"]` indicates that the first site is hosting a species labeled `\"Ti\"` and the second a species labeled `\"O2\"`.\n - `[\"Ac\", \"Ac\", \"Ag\", \"Ir\"]` indicating the first two sites contains the `\"Ac\"` species, while the third and fourth sites contain the `\"Ag\"` and `\"Ir\"` species, respectively.", "nullable": true, - "x-optimade-queryable": "optional", - "x-optimade-support": "should" + "x-optimade-support": "should", + "x-optimade-queryable": "optional" }, "assemblies": { "title": "Assemblies", @@ -3697,8 +4537,8 @@ "$ref": "#/components/schemas/Assembly" }, "description": "A description of groups of sites that are statistically correlated.\n\n- **Type**: list of dictionary with keys:\n - `sites_in_groups`: list of list of integers (REQUIRED)\n - `group_probabilities`: list of floats (REQUIRED)\n\n- **Requirements/Conventions**:\n - **Support**: OPTIONAL support in implementations, i.e., MAY be `null`.\n - **Query**: Support for queries on this property is OPTIONAL.\n If supported, filters MAY support only a subset of comparison operators.\n - The property SHOULD be `null` for entries that have no partial occupancies.\n - If present, the correct flag MUST be set in the list `structure_features`.\n - Client implementations MUST check its presence (as its presence changes the interpretation of the structure).\n - If present, it MUST be a list of dictionaries, each of which represents an assembly and MUST have the following two keys:\n - **sites_in_groups**: Index of the sites (0-based) that belong to each group for each assembly.\n\n Example: `[[1], [2]]`: two groups, one with the second site, one with the third.\n Example: `[[1,2], [3]]`: one group with the second and third site, one with the fourth.\n\n - **group_probabilities**: Statistical probability of each group. It MUST have the same length as `sites_in_groups`.\n It SHOULD sum to one.\n See below for examples of how to specify the probability of the occurrence of a vacancy.\n The possible reasons for the values not to sum to one are the same as already specified above for the `concentration` of each `species`.\n\n - If a site is not present in any group, it means that it is present with 100 % probability (as if no assembly was specified).\n - A site MUST NOT appear in more than one group.\n\n- **Examples** (for each entry of the assemblies list):\n - `{\"sites_in_groups\": [[0], [1]], \"group_probabilities: [0.3, 0.7]}`: the first site and the second site never occur at the same time in the unit cell.\n Statistically, 30 % of the times the first site is present, while 70 % of the times the second site is present.\n - `{\"sites_in_groups\": [[1,2], [3]], \"group_probabilities: [0.3, 0.7]}`: the second and third site are either present together or not present; they form the first group of atoms for this assembly.\n The second group is formed by the fourth site.\n Sites of the first group (the second and the third) are never present at the same time as the fourth site.\n 30 % of times sites 1 and 2 are present (and site 3 is absent); 70 % of times site 3 is present (and sites 1 and 2 are absent).\n\n- **Notes**:\n - Assemblies are essential to represent, for instance, the situation where an atom can statistically occupy two different positions (sites).\n\n - By defining groups, it is possible to represent, e.g., the case where a functional molecule (and not just one atom) is either present or absent (or the case where it it is present in two conformations)\n\n - Considerations on virtual alloys and on vacancies: In the special case of a virtual alloy, these specifications allow two different, equivalent ways of specifying them.\n For instance, for a site at the origin with 30 % probability of being occupied by Si, 50 % probability of being occupied by Ge, and 20 % of being a vacancy, the following two representations are possible:\n\n - Using a single species:\n ```json\n {\n \"cartesian_site_positions\": [[0,0,0]],\n \"species_at_sites\": [\"SiGe-vac\"],\n \"species\": [\n {\n \"name\": \"SiGe-vac\",\n \"chemical_symbols\": [\"Si\", \"Ge\", \"vacancy\"],\n \"concentration\": [0.3, 0.5, 0.2]\n }\n ]\n // ...\n }\n ```\n\n - Using multiple species and the assemblies:\n ```json\n {\n \"cartesian_site_positions\": [ [0,0,0], [0,0,0], [0,0,0] ],\n \"species_at_sites\": [\"Si\", \"Ge\", \"vac\"],\n \"species\": [\n { \"name\": \"Si\", \"chemical_symbols\": [\"Si\"], \"concentration\": [1.0] },\n { \"name\": \"Ge\", \"chemical_symbols\": [\"Ge\"], \"concentration\": [1.0] },\n { \"name\": \"vac\", \"chemical_symbols\": [\"vacancy\"], \"concentration\": [1.0] }\n ],\n \"assemblies\": [\n {\n \"sites_in_groups\": [ [0], [1], [2] ],\n \"group_probabilities\": [0.3, 0.5, 0.2]\n }\n ]\n // ...\n }\n ```\n\n - It is up to the database provider to decide which representation to use, typically depending on the internal format in which the structure is stored.\n However, given a structure identified by a unique ID, the API implementation MUST always provide the same representation for it.\n\n - The probabilities of occurrence of different assemblies are uncorrelated.\n So, for instance in the following case with two assemblies:\n ```json\n {\n \"assemblies\": [\n {\n \"sites_in_groups\": [ [0], [1] ],\n \"group_probabilities\": [0.2, 0.8],\n },\n {\n \"sites_in_groups\": [ [2], [3] ],\n \"group_probabilities\": [0.3, 0.7]\n }\n ]\n }\n ```\n\n Site 0 is present with a probability of 20 % and site 1 with a probability of 80 %. These two sites are correlated (either site 0 or 1 is present). Similarly, site 2 is present with a probability of 30 % and site 3 with a probability of 70 %.\n These two sites are correlated (either site 2 or 3 is present).\n However, the presence or absence of sites 0 and 1 is not correlated with the presence or absence of sites 2 and 3 (in the specific example, the pair of sites (0, 2) can occur with 0.2*0.3 = 6 % probability; the pair (0, 3) with 0.2*0.7 = 14 % probability; the pair (1, 2) with 0.8*0.3 = 24 % probability; and the pair (1, 3) with 0.8*0.7 = 56 % probability).", - "x-optimade-queryable": "optional", - "x-optimade-support": "optional" + "x-optimade-support": "optional", + "x-optimade-queryable": "optional" }, "structure_features": { "title": "Structure Features", @@ -3707,8 +4547,8 @@ "$ref": "#/components/schemas/StructureFeatures" }, "description": "A list of strings that flag which special features are used by the structure.\n\n- **Type**: list of strings\n\n- **Requirements/Conventions**:\n - **Support**: MUST be supported by all implementations, MUST NOT be `null`.\n - **Query**: MUST be a queryable property.\n Filters on the list MUST support all mandatory HAS-type queries.\n Filter operators for comparisons on the string components MUST support equality, support for other comparison operators are OPTIONAL.\n - MUST be an empty list if no special features are used.\n - MUST be sorted alphabetically.\n - If a special feature listed below is used, the list MUST contain the corresponding string.\n - If a special feature listed below is not used, the list MUST NOT contain the corresponding string.\n - **List of strings used to indicate special structure features**:\n - `disorder`: this flag MUST be present if any one entry in the `species` list has a `chemical_symbols` list that is longer than 1 element.\n - `implicit_atoms`: this flag MUST be present if the structure contains atoms that are not assigned to sites via the property `species_at_sites` (e.g., because their positions are unknown).\n When this flag is present, the properties related to the chemical formula will likely not match the type and count of atoms represented by the `species_at_sites`, `species` and `assemblies` properties.\n - `site_attachments`: this flag MUST be present if any one entry in the `species` list includes `attached` and `nattached`.\n - `assemblies`: this flag MUST be present if the property `assemblies` is present.\n\n- **Examples**: A structure having implicit atoms and using assemblies: `[\"assemblies\", \"implicit_atoms\"]`", - "x-optimade-queryable": "must", - "x-optimade-support": "must" + "x-optimade-support": "must", + "x-optimade-queryable": "must" } }, "description": "This class contains the Field for the attributes used to represent a structure, e.g. unit cell, atoms, positions." @@ -3874,6 +4714,15 @@ }, "description": "errors are not allowed" }, + "SupportLevel": { + "title": "SupportLevel", + "enum": [ + "must", + "should", + "optional" + ], + "description": "OPTIMADE property/field support levels" + }, "ToplevelLinks": { "title": "ToplevelLinks", "type": "object", @@ -3971,6 +4820,24 @@ }, "description": "A set of Links objects, possibly including pagination" }, + "UnitResourceURIs": { + "title": "UnitResourceURIs", + "required": [ + "relation", + "uri" + ], + "type": "object", + "properties": { + "relation": { + "title": "Relation", + "type": "string" + }, + "uri": { + "title": "Uri", + "type": "string" + } + } + }, "Warnings": { "title": "Warnings", "required": [ diff --git a/optimade/models/entries.py b/optimade/models/entries.py index 6a0fc6867..b5388e5df 100644 --- a/optimade/models/entries.py +++ b/optimade/models/entries.py @@ -1,12 +1,13 @@ # pylint: disable=line-too-long,no-self-argument from datetime import datetime -from typing import Dict, List, Optional +from enum import Enum +from typing import Dict, List, Optional, Union from pydantic import BaseModel, validator # pylint: disable=no-name-in-module from optimade.models.jsonapi import Attributes, Relationships, Resource -from optimade.models.optimade_json import DataType, Relationship -from optimade.models.utils import OptimadeField, StrictField, SupportLevel +from optimade.models.optimade_json import AllowedJSONSchemaDataType, Relationship +from optimade.models.utils import OptimadeField, QuerySupport, StrictField, SupportLevel __all__ = ( "EntryRelationships", @@ -17,8 +18,194 @@ ) +class OptimadeAllowedUnitStandard(Enum): + GNU_UNITS = "gnu units" + UCUM = "ucum" + QUDT = "qudt" + + +class UnitResourceURIs(BaseModel): + relation: str + uri: str + + +class OptimadeUnitStandard(BaseModel): + name: OptimadeAllowedUnitStandard + version: str + symbol: str + + +class OptimadeUnitDefinition(BaseModel): + symbol: str + title: str + description: str + standard: OptimadeUnitStandard + resource_uris: Optional[List[UnitResourceURIs]] = StrictField( + ..., alias="resource-uris" + ) + + +class JSONSchemaObject(BaseModel): + + properties: Dict[str, "EntryInfoProperty"] = StrictField( + ..., + description="""Gives key-value pairs where each value is an inner Property Definition. +The defined property is a dictionary that can only contain keys present in this dictionary, and, if so, the corresponding value is described by the respective inner Property Definition. +(Or, if the `type` field is the list "object" and "null", it can also be `null`.)""", + ) + + required: Optional[List[str]] = StrictField( + ..., + description="""The list MUST only contain strings. + +The defined property MUST have keys that match all the strings in this list. +Other keys present in the `properties` field are OPTIONAL in the defined property. +If not present or empty, all keys in `properties` are regarded as OPTIONAL.""", + ) + maxProperties: Optional[int] + minProperties: Optional[int] + dependentRequired: Optional[Dict] + + +class JSONSchemaArray(BaseModel): + items: "EntryInfoProperty" = StrictField(...) + maxItems: Optional[int] + minItems: Optional[int] + uniqueItems: Optional[bool] + + +class JSONSchemaInteger(BaseModel): + multipleOf: Optional[int] + maximum: Optional[int] + exclusiveMaximum: Optional[int] + minimum: Optional[int] + exclusiveMinimum: Optional[int] + + +class JSONSchemaNumber(BaseModel): + multipleOf: Optional[float] + maximum: Optional[float] + exclusiveMaximum: Optional[float] + minimum: Optional[float] + exclusiveMinimum: Optional[float] + + +class JSONSchemaStringFormat(Enum): + DATETIME = "date-time" + DATE = "date" + TIME = "time" + DURATION = "duration" + EMAIL = "email" + URI = "uri" + + +class JSONSchemaString(BaseModel): + maxLength: Optional[int] + minLength: Optional[int] + format: Optional[JSONSchemaStringFormat] + + +class PropertyImplementationInfo(BaseModel): + + sortable: Optional[bool] = StrictField( + ..., + description="""If `TRUE`, specifies that results can be sorted on this property. + If `FALSE`, specifies that results cannot be sorted on this property. + Omitting the field is equivalent to `FALSE`.""", + ) + + query_support: Optional[QuerySupport] = StrictField( + ..., + alias="query-support", + description="""Defines a required level of support in formulating queries on this field. + + The string MUST be one of the following: + + - `all mandatory`: the defined property MUST be queryable using the OPTIMADE filter language with support for all mandatory filter features. + - `equality only`: the defined property MUST be queryable using the OPTIMADE filter language equality and inequality operators. Other filter language features do not need to be available. + - `partial`: the defined property MUST be queryable with support for a subset of the filter language operators as specified by the field `query-support-operators`. + - `none`: the defined property does not need to be queryable with any features of the filter language.""", + ) + + query_support_operators: Optional[List[str]] = StrictField( + ..., + alias="query-support-operators", + description="""Defines the filter language features supported on this property. + +Each string in the list MUST be one of `<`, `<=`, `>`, `>=`, `=`, `!=`, `CONTAINS`, `STARTS WITH`, `ENDS WITH`:, `HAS`, `HAS ALL`, `HAS ANY`, `HAS ONLY`, `IS KNOWN`, `IS UNKNOWN` with the following meanings: + +- `<`, `<=`, `>`, `>=`, `=`, `!=`: indicating support for filtering this property using the respective operator. + If the property is of Boolean type, support for `=` also designates support for boolean comparisons with the property being true that omit ":filter-fragment:`= TRUE`", e.g., specifying that filtering for "`is_yellow = TRUE`" is supported also implies support for "`is_yellow`" (which means the same thing). + Support for "`NOT is_yellow`" also follows. + +- `CONTAINS`, `STARTS WITH`, `ENDS WITH`: indicating support for substring filtering of this property using the respective operator. MUST NOT appear if the property is not of type String. + +- `HAS`, `HAS ALL`, `HAS ANY`: indicating support of the MANDATORY features for list property comparison using the respective operator. MUST NOT appear if the property is not of type List. + +- `HAS ONLY`: indicating support for list property comparison with all or a subset of the OPTIONAL constructs using this operator. MUST NOT appear if the property is not of type List. + +- `IS KNOWN`, `IS UNKNOWN`: indicating support for filtering this property on unknown values using the respective operator.""", + ) + + +class PropertyRequirementsInfo(PropertyImplementationInfo): + support: SupportLevel = StrictField( + ..., + description="""Describes the minimal required level of support for the Property by an implementation. + + This field SHOULD only appear in a `x-optimade-requirements` that is at the outermost level of a Property Definition, as the meaning of its inclusion on other levels is not defined. + The string MUST be one of the following: + + - `must`: the defined property MUST be recognized by the implementation (e.g., in filter strings) and MUST NOT be `null`. + - `should`: the defined property MUST be recognized by the implementation (e.g., in filter strings) and SHOULD NOT be `null`. + - `may`: it is OPTIONAL for the implementation to recognize the defined property and it MAY be equal to `null`.""", + ) + + +class PropertyRemoteResource(BaseModel): + + relation: str = StrictField( + ..., + description="A human-readable description of the relationship between the property and the remote resource, e.g., a 'natural language description'.", + ) + + uri: str = StrictField( + ..., + description="A URI of the external resource (which MAY be a resolvable URL).", + ) + + +class OptimadePropertyDefinition(BaseModel): + + property_uri: str = StrictField( + ..., + alias="property-uri", + description="""A static URI identifier that is a URN or URL representing the specific version of the property. +It SHOULD NOT be changed as long as the property definition remains the same, and SHOULD be changed when the property definition changes. +(If it is a URL, clients SHOULD NOT assign any interpretation to the response when resolving that URL.)""", + ) + + version: Optional[str] = StrictField( + ..., + description="""This string indicates the version of the property definition. +The string SHOULD be in the format described by the [semantic versioning v2](https://semver.org/spec/v2.0.0.html) standard.""", + ) + + unit_definitions: Optional[List[OptimadeUnitDefinition]] = StrictField( + ..., + alias="unit-definitions", + description="""A list of definitions of the symbols used in the Property Definition (including its nested levels) for physical units given as values of the `x-optimade-unit` field. +This field MUST be included if the defined property, at any level, includes an `x-optimade-unit` with a value that is not `dimensionless` or `inapplicable`.""", + ) + + resource_uris: Optional[List[PropertyRemoteResource]] = StrictField( + ..., + alias="resource-uris", + description="A list of dictionaries that references remote resources that describe the property.", + ) + + class TypedRelationship(Relationship): - # This may be updated when moving to Python 3.8 @validator("data") def check_rel_type(cls, data): if not isinstance(data, list): @@ -156,33 +343,97 @@ class EntryResource(Resource): class EntryInfoProperty(BaseModel): + title: str = StrictField( + ..., + description="A short single-line human-readable explanation of the defined property appropriate to show as part of a user interface.", + ) + description: str = StrictField( - ..., description="A human-readable description of the entry property" + ..., + description="""A human-readable multi-line description that explains the purpose, requirements, and conventions of the defined property. + +The format SHOULD be a one-line description, followed by a new paragraph (two newlines), followed by a more detailed description of all the requirements and conventions of the defined property. +Formatting in the text SHOULD use Markdown in the CommonMark v0.3 format.""", + ) + + property: OptimadePropertyDefinition = StrictField( + ..., + alias="x-optimade-property", + description="Additional information to define the property that is not covered by fields in the JSON Schema standard.", ) unit: Optional[str] = StrictField( None, - description="""The physical unit of the entry property. -This MUST be a valid representation of units according to version 2.1 of [The Unified Code for Units of Measure](https://unitsofmeasure.org/ucum.html). -It is RECOMMENDED that non-standard (non-SI) units are described in the description for the property.""", + alias="x-optimade-unit", + description="A (compound) symbol for the physical unit in which the value of the defined property is given or one of the strings `dimensionless` or `inapplicable`.", ) - sortable: Optional[bool] = StrictField( - None, - description="""Defines whether the entry property can be used for sorting with the "sort" parameter. -If the entry listing endpoint supports sorting, this key MUST be present for sortable properties with value `true`.""", + implementation: Optional[PropertyImplementationInfo] = StrictField( + ..., + alias="x-optimade-implementation", + description="""A dictionary describing the level of OPTIMADE API functionality provided by the present implementation. +If an implementation omits this field in its response, a client interacting with that implementation SHOULD NOT make any assumptions about the availability of these features.""", + ) + + requirements: Optional[PropertyRequirementsInfo] = StrictField( + ..., + alias="x-optimade-requirements", + description="""A dictionary describing the level of OPTIMADE API functionality required by all implementations of this property. +Omitting this field means the corresponding functionality is OPTIONAL.""", ) - type: Optional[DataType] = StrictField( + type: Union[ + AllowedJSONSchemaDataType, List[AllowedJSONSchemaDataType] + ] = StrictField( None, title="Type", - description="""The type of the property's value. -This MUST be any of the types defined in the Data types section. -For the purpose of compatibility with future versions of this specification, a client MUST accept values that are not `string` values specifying any of the OPTIMADE Data types, but MUST then also disregard the `type` field. -Note, if the value is a nested type, only the outermost type should be reported. -E.g., for the entry resource `structures`, the `species` property is defined as a list of dictionaries, hence its `type` value would be `list`.""", + description="""A string or list that specifies the type of the defined property. +It MUST be one of: + +- One of the strings `"boolean"`, `"object"` (refers to an OPTIMADE dictionary), `"array"` (refers to an OPTIMADE list), `"number"` (refers to an OPTIMADE float), `"string"`, or `"integer"`. +- A list where the first item MUST be one of the strings above, and the second item MUST be the string `"null"`.""", + ) + + deprecated: Optional[bool] = StrictField( + ..., + description=""" If `TRUE`, implementations SHOULD not use the defined property, and it MAY be removed in the future. +If `FALSE`, the defined property is not deprecated. +The field not being present means `FALSE`.""", + ) + + enum: Optional[List] = StrictField( + ..., + description="""The defined property MUST take one of the values given in the provided list. +The items in the list MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description. +If this key is given, for `null` to be a valid value of the defined property, the list MUST contain a `null` value and the `type` MUST be a list where the second value is the string `"null"`.""", ) + examples: Optional[List] = StrictField( + ..., + description="""A list of example values that the defined property can have. +These examples MUST all be of a data type that matches the `type` field and otherwise adhere to the rest of the Property Description.""", + ) + + +class EntryInfoPropertyObject(EntryInfoProperty, JSONSchemaObject): + ... + + +class EntryInfoPropertyArray(EntryInfoProperty, JSONSchemaArray): + ... + + +class EntryInfoPropertyNumber(EntryInfoProperty, JSONSchemaInteger): + ... + + +class EntryInfoPropertyString(EntryInfoProperty, JSONSchemaString): + ... + + +class EntryInfoPropertyInteger(EntryInfoProperty, JSONSchemaInteger): + ... + class EntryInfoResource(BaseModel): @@ -192,7 +443,17 @@ class EntryInfoResource(BaseModel): description: str = StrictField(..., description="Description of the entry.") - properties: Dict[str, EntryInfoProperty] = StrictField( + properties: Dict[ + str, + Union[ + EntryInfoProperty, + EntryInfoPropertyArray, + EntryInfoPropertyInteger, + EntryInfoPropertyNumber, + EntryInfoPropertyObject, + EntryInfoPropertyString, + ], + ] = StrictField( ..., description="A dictionary describing queryable properties for this entry type, where each key is a property name.", ) diff --git a/optimade/models/optimade_json.py b/optimade/models/optimade_json.py index bad738057..b97192318 100644 --- a/optimade/models/optimade_json.py +++ b/optimade/models/optimade_json.py @@ -121,6 +121,17 @@ def from_json_type(cls, json_type: str): return mapping.get(json_type, None) +class AllowedJSONSchemaDataType(Enum): + """The allowed values for `type` in the Property Definition restricted JSON Schema syntax.""" + + BOOLEAN = "boolean" + OBJECT = "object" + ARRAY = "array" + NUMBER = "number" + STRING = "string" + INTEGER = "integer" + + class OptimadeError(jsonapi.Error): """detail MUST be present""" diff --git a/optimade/models/utils.py b/optimade/models/utils.py index 603ef08ad..10d9d11bf 100644 --- a/optimade/models/utils.py +++ b/optimade/models/utils.py @@ -34,6 +34,13 @@ class SupportLevel(Enum): OPTIONAL = "optional" +class QuerySupport(Enum): + ALL_MANDATORY = "all mandatory" + EQUALITY_ONLY = "equality only" + PARTIAL = "partial" + NONE = "none" + + class StrictFieldInfo(FieldInfo): """Wraps the standard pydantic `FieldInfo` in order to prefix any custom keys from `StrictField`. From 13bbeca0c4e497146132698c02cb1dd48a8a2e8c Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Mon, 19 Dec 2022 21:11:14 +0100 Subject: [PATCH 2/2] Placeholder --- optimade/models/entries.py | 18 ++++- optimade/models/optimade_json.py | 108 +------------------------- optimade/models/utils.py | 129 ++++++++++++++++++++++++++++++- optimade/server/routers/info.py | 5 +- optimade/server/schemas.py | 28 +++++++ 5 files changed, 177 insertions(+), 111 deletions(-) diff --git a/optimade/models/entries.py b/optimade/models/entries.py index b5388e5df..186fad3ff 100644 --- a/optimade/models/entries.py +++ b/optimade/models/entries.py @@ -6,7 +6,8 @@ from pydantic import BaseModel, validator # pylint: disable=no-name-in-module from optimade.models.jsonapi import Attributes, Relationships, Resource -from optimade.models.optimade_json import AllowedJSONSchemaDataType, Relationship +from optimade.models.optimade_json import Relationship +from optimade.models.utils import AllowedJSONSchemaDataType from optimade.models.utils import OptimadeField, QuerySupport, StrictField, SupportLevel __all__ = ( @@ -73,6 +74,9 @@ class JSONSchemaArray(BaseModel): minItems: Optional[int] uniqueItems: Optional[bool] +class JSONSchemaBoolean(BaseModel): + pass + class JSONSchemaInteger(BaseModel): multipleOf: Optional[int] @@ -104,6 +108,18 @@ class JSONSchemaString(BaseModel): minLength: Optional[int] format: Optional[JSONSchemaStringFormat] +"""A mapping from the resricted JSON Schema data types to the expected +models for validating and contraining their schemas. +""" +JSON_SCHEMA_MODEL_MAPPING: Dict[AllowedJSONSchemaDataType, BaseModel] = { + AllowedJSONSchemaDataType.STRING: JSONSchemaString, + AllowedJSONSchemaDataType.NUMBER: JSONSchemaNumber, + AllowedJSONSchemaDataType.ARRAY: JSONSchemaArray, + AllowedJSONSchemaDataType.BOOLEAN: JSONSchemaBoolean, + AllowedJSONSchemaDataType.INTEGER: JSONSchemaInteger, + AllowedJSONSchemaDataType.OBJECT: JSONSchemaObject, +} + class PropertyImplementationInfo(BaseModel): diff --git a/optimade/models/optimade_json.py b/optimade/models/optimade_json.py index b97192318..a38e0d989 100644 --- a/optimade/models/optimade_json.py +++ b/optimade/models/optimade_json.py @@ -7,7 +7,7 @@ from pydantic import AnyHttpUrl, AnyUrl, BaseModel, EmailStr, root_validator from optimade.models import jsonapi -from optimade.models.utils import SemanticVersion, StrictField +from optimade.models.utils import SemanticVersion, StrictField, DataType __all__ = ( "DataType", @@ -25,112 +25,6 @@ ) -class DataType(Enum): - """Optimade Data Types - - See the section "Data types" in the OPTIMADE API specification for more information. - """ - - STRING = "string" - INTEGER = "integer" - FLOAT = "float" - BOOLEAN = "boolean" - TIMESTAMP = "timestamp" - LIST = "list" - DICTIONARY = "dictionary" - UNKNOWN = "unknown" - - @classmethod - def get_values(cls): - """Get OPTIMADE data types (enum values) as a (sorted) list""" - return sorted((_.value for _ in cls)) - - @classmethod - def from_python_type(cls, python_type: Union[type, str, object]): - """Get OPTIMADE data type from a Python type""" - mapping = { - "bool": cls.BOOLEAN, - "int": cls.INTEGER, - "float": cls.FLOAT, - "complex": None, - "generator": cls.LIST, - "list": cls.LIST, - "tuple": cls.LIST, - "range": cls.LIST, - "hash": cls.INTEGER, - "str": cls.STRING, - "bytes": cls.STRING, - "bytearray": None, - "memoryview": None, - "set": cls.LIST, - "frozenset": cls.LIST, - "dict": cls.DICTIONARY, - "dict_keys": cls.LIST, - "dict_values": cls.LIST, - "dict_items": cls.LIST, - "NoneType": cls.UNKNOWN, - "None": cls.UNKNOWN, - "datetime": cls.TIMESTAMP, - "date": cls.TIMESTAMP, - "time": cls.TIMESTAMP, - "datetime.datetime": cls.TIMESTAMP, - "datetime.date": cls.TIMESTAMP, - "datetime.time": cls.TIMESTAMP, - } - - if isinstance(python_type, type): - python_type = python_type.__name__ - elif isinstance(python_type, object): - if str(python_type) in mapping: - python_type = str(python_type) - else: - python_type = type(python_type).__name__ - - return mapping.get(python_type, None) - - @classmethod - def from_json_type(cls, json_type: str): - """Get OPTIMADE data type from a named JSON type""" - mapping = { - "string": cls.STRING, - "integer": cls.INTEGER, - "number": cls.FLOAT, # actually includes both integer and float - "object": cls.DICTIONARY, - "array": cls.LIST, - "boolean": cls.BOOLEAN, - "null": cls.UNKNOWN, - # OpenAPI "format"s: - "double": cls.FLOAT, - "float": cls.FLOAT, - "int32": cls.INTEGER, - "int64": cls.INTEGER, - "date": cls.TIMESTAMP, - "date-time": cls.TIMESTAMP, - "password": cls.STRING, - "byte": cls.STRING, - "binary": cls.STRING, - # Non-OpenAPI "format"s, but may still be used by pydantic/FastAPI - "email": cls.STRING, - "uuid": cls.STRING, - "uri": cls.STRING, - "hostname": cls.STRING, - "ipv4": cls.STRING, - "ipv6": cls.STRING, - } - - return mapping.get(json_type, None) - - -class AllowedJSONSchemaDataType(Enum): - """The allowed values for `type` in the Property Definition restricted JSON Schema syntax.""" - - BOOLEAN = "boolean" - OBJECT = "object" - ARRAY = "array" - NUMBER = "number" - STRING = "string" - INTEGER = "integer" - class OptimadeError(jsonapi.Error): """detail MUST be present""" diff --git a/optimade/models/utils.py b/optimade/models/utils.py index 10d9d11bf..e3bfd092d 100644 --- a/optimade/models/utils.py +++ b/optimade/models/utils.py @@ -3,7 +3,7 @@ import re import warnings from enum import Enum -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Optional, Union from pydantic import Field from pydantic.fields import FieldInfo @@ -11,6 +11,133 @@ if TYPE_CHECKING: # pragma: no cover from typing import Any +class DataType(Enum): + """Optimade Data Types + + See the section "Data types" in the OPTIMADE API specification for more information. + """ + + STRING = "string" + INTEGER = "integer" + FLOAT = "float" + BOOLEAN = "boolean" + TIMESTAMP = "timestamp" + LIST = "list" + DICTIONARY = "dictionary" + UNKNOWN = "unknown" + + @classmethod + def get_values(cls): + """Get OPTIMADE data types (enum values) as a (sorted) list""" + return sorted((_.value for _ in cls)) + + @classmethod + def from_python_type(cls, python_type: Union[type, str, object]): + """Get OPTIMADE data type from a Python type""" + mapping = { + "bool": cls.BOOLEAN, + "int": cls.INTEGER, + "float": cls.FLOAT, + "complex": None, + "generator": cls.LIST, + "list": cls.LIST, + "tuple": cls.LIST, + "range": cls.LIST, + "hash": cls.INTEGER, + "str": cls.STRING, + "bytes": cls.STRING, + "bytearray": None, + "memoryview": None, + "set": cls.LIST, + "frozenset": cls.LIST, + "dict": cls.DICTIONARY, + "dict_keys": cls.LIST, + "dict_values": cls.LIST, + "dict_items": cls.LIST, + "NoneType": cls.UNKNOWN, + "None": cls.UNKNOWN, + "datetime": cls.TIMESTAMP, + "date": cls.TIMESTAMP, + "time": cls.TIMESTAMP, + "datetime.datetime": cls.TIMESTAMP, + "datetime.date": cls.TIMESTAMP, + "datetime.time": cls.TIMESTAMP, + } + + if isinstance(python_type, type): + python_type = python_type.__name__ + elif isinstance(python_type, object): + if str(python_type) in mapping: + python_type = str(python_type) + else: + python_type = type(python_type).__name__ + + return mapping.get(python_type, None) + + @classmethod + def from_json_type(cls, json_type: str): + """Get OPTIMADE data type from a named JSON type""" + mapping = { + "string": cls.STRING, + "integer": cls.INTEGER, + "number": cls.FLOAT, # actually includes both integer and float + "object": cls.DICTIONARY, + "array": cls.LIST, + "boolean": cls.BOOLEAN, + "null": cls.UNKNOWN, + # OpenAPI "format"s: + "double": cls.FLOAT, + "float": cls.FLOAT, + "int32": cls.INTEGER, + "int64": cls.INTEGER, + "date": cls.TIMESTAMP, + "date-time": cls.TIMESTAMP, + "password": cls.STRING, + "byte": cls.STRING, + "binary": cls.STRING, + # Non-OpenAPI "format"s, but may still be used by pydantic/FastAPI + "email": cls.STRING, + "uuid": cls.STRING, + "uri": cls.STRING, + "hostname": cls.STRING, + "ipv4": cls.STRING, + "ipv6": cls.STRING, + } + + return mapping.get(json_type, None) + + +class AllowedJSONSchemaDataType(Enum): + """The allowed values for `type` in the Property Definition restricted JSON Schema syntax.""" + + BOOLEAN = "boolean" + OBJECT = "object" + ARRAY = "array" + NUMBER = "number" + STRING = "string" + INTEGER = "integer" + + @classmethod + def from_optimade_type(cls, type: str) -> Optional["AllowedJSONSchemaDataType"]: + """Returns a restricted JSON Schema type from an OPTIMADE type.""" + mapping = { + DataType.STRING: cls.STRING, + DataType.INTEGER: cls.INTEGER, + DataType.FLOAT: cls.NUMBER, + DataType.BOOLEAN: cls.BOOLEAN, + DataType.TIMESTAMP: cls.STRING, + DataType.LIST: cls.ARRAY, + DataType.DICTIONARY: cls.OBJECT, + } + try: + dt = DataType(type) + except ValueError: + return None + + return mapping.get(dt, None) + + + _PYDANTIC_FIELD_KWARGS = list(inspect.signature(Field).parameters.keys()) diff --git a/optimade/server/routers/info.py b/optimade/server/routers/info.py index 74c96ccd5..ea41c833a 100644 --- a/optimade/server/routers/info.py +++ b/optimade/server/routers/info.py @@ -8,7 +8,8 @@ from optimade.server.schemas import ( ENTRY_INFO_SCHEMAS, ERROR_RESPONSES, - retrieve_queryable_properties, + # retrieve_queryable_properties, + retrieve_new_property_definitions, ) router = APIRouter(redirect_slashes=True) @@ -67,7 +68,7 @@ def get_entry_info(request: Request, entry: str) -> EntryInfoResponse: schema = ENTRY_INFO_SCHEMAS[entry]() queryable_properties = {"id", "type", "attributes"} - properties = retrieve_queryable_properties( + properties = retrieve_new_property_definitions( schema, queryable_properties, entry_type=entry ) diff --git a/optimade/server/schemas.py b/optimade/server/schemas.py index 558745548..288649a84 100644 --- a/optimade/server/schemas.py +++ b/optimade/server/schemas.py @@ -6,6 +6,7 @@ ReferenceResource, StructureResource, ) +from optimade.models.utils import AllowedJSONSchemaDataType __all__ = ("ENTRY_INFO_SCHEMAS", "ERROR_RESPONSES", "retrieve_queryable_properties") @@ -46,6 +47,8 @@ def retrieve_queryable_properties( queryable_properties: The list of properties to find in the schema. entry_type: An optional entry type for the model. Will be used to lookup schemas for any config-defined fields. + new_style: If true, generate property definitions in the new JSONSchema + style, otherwise use the pre-1.2 OPTIMADE format. Returns: A flat dictionary with properties as keys, containing the field @@ -99,3 +102,28 @@ def retrieve_queryable_properties( properties[name]["sortable"] = field.get("sortable", True) return properties + +def retrieve_new_property_definitions(schema, queryable_properties=None, entry_type=None): + properties = retrieve_queryable_properties(schema, queryable_properties, entry_type) + return convert_property_definitions(properties) + + +def convert_property_definitions(properties): + from optimade.models.entries import JSON_SCHEMA_MODEL_MAPPING + if not properties: + return {} + output_properties = {} + for property in properties: + print(property) + type = AllowedJSONSchemaDataType.from_optimade_type(properties[property]["type"]) + model = JSON_SCHEMA_MODEL_MAPPING[type] + title = " ".join(property.split("_")) + description = properties[property]["description"] + implementation = { + "sortable": True, + "queryable": properties[property].get("queryable", None), + "support": properties[property].get("support", None), + } + output_properties[property] = {"title": title, "description": properties[property]["description"], "x-optimade-implementation": implementation} + + return output_properties