diff --git a/schemas/README.md b/schemas/README.md new file mode 100644 index 0000000000..8af7a4f38d --- /dev/null +++ b/schemas/README.md @@ -0,0 +1,24 @@ +### **Summary of Key Upgrades** +Date: 08/22/2024 +Original version located: `v3.0/smartapi_schema.json` + +1. **Schema Version** + - **Upgraded** from JSON Schema Draft-04 to Draft 2020-12 for better compatibility with modern standards. + +2. **Definitions Location** + - **Changed** from `#/definitions/...` to `#/$defs/...` to align with the latest JSON Schema conventions. + +3. **Contact Roles** + - **Added** a new role `"document creator"` to better document contributors. + +4. **Server Maturity Levels** + - **Added** `"testing"` as a new maturity level for better server environment categorization. + +5. **Paths Object Flexibility** + - **Removed** the requirement for the `summary` field, providing more flexibility in operation documentation. + +6. **Response Value Type Validation** + - **Enhanced** validation logic to allow flexibility with `path`/`x-path` and `valueType`/`x-valueType`. + +7. **Improved Flexibility** + - **Introduced** more flexible validation using `allOf` and `anyOf` constructs, allowing for adaptable data structures. diff --git a/schemas/smartapi_schema.json b/schemas/smartapi_schema.json index b3e5979b6d..35d24dab57 100644 --- a/schemas/smartapi_schema.json +++ b/schemas/smartapi_schema.json @@ -1,241 +1,238 @@ -{ - "title": "The smartAPI extension to OpenAPI 3.0.", - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "description": "This is the root document object of the smartAPI definition file.", - "properties": { - "info": { - "$ref": "#/definitions/info" - }, - "servers": { - "type": "array", - "items": { - "$ref": "#/definitions/server" - } - }, - "x-externalResources": { - "type": "array", - "items": { - "$ref": "#/definitions/externalResource" - } - }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/tag" - } - }, - "paths": { - "type": "object", - "patternProperties": { - "^\\/": { - "type": "object", - "patternProperties": { - "get|put|post|delete|options|head|patch|trace": { - "type": "object", - "required": [ - "summary" - ], - "properties": { - "summary": { - "type": "string" - }, - "parameters": { - "type": "array", - "items": { - "$ref": "#/definitions/Parameter" - } - }, - "responses": { - "type": "object", - "patternProperties": { - "[1-5](?:\\d{2}|XX)": { - "type": "object", - "properties": { - "x-responseValueType": { - "type": "array", - "items": { - "$ref": "#/definitions/responseValueType" - } - } - } - } - } - }, - "x-accessRestriction": { - "type": "string", - "description": "Access restrictions to invoke the operation. values: none, limited, fee.", - "enum": [ - "none", - "limited", - "fee" - ] - } - } - } - } - } - } - } - }, - "definitions": { - "Reference": { - "type": "object", - "required": [ - "$ref" - ], - "properties": { - "$ref": { - "type": "string", - "format": "uri-reference" - } - } - }, - "info": { - "required": [ - "termsOfService" - ], - "properties": { - "x-otherContacts": { - "type": "array", - "items": { - "$ref": "#/definitions/contact" - } - }, - "x-accessRestriction": { - "type": "string", - "enum": [ - "none", - "limited", - "fee" - ], - "description": "Indicate whether there are restrictions to using the API. Values to use: none, limited, fee." - }, - "x-implementationLanguage": { - "type": "string", - "description": "API Implementation Language" - }, - "contact": { - "$ref": "#/definitions/contact" - }, - "termsOfService": { - "type": "string", - "format": "uri" - } - } - }, - "contact": { - "properties": { - "x-role": { - "type": "string", - "enum": [ - "responsible organization", - "responsible developer", - "contributor", - "support" - ] - }, - "x-id": { - "type": "string", - "format": "uri", - "description": "A resolvable HTTP URI that uniqely identifies the contact (e.g. orcid id github id)" - } - } - }, - "server": { - "properties": { - "x-location": { - "type": "string", - "description": "Location, city and country of the server hosting the API." - }, - "x-maturity": { - "type": "string", - "enum": [ - "development", - "staging", - "production" - ] - } - } - }, - "externalResource": { - "type": "object", - "additionalProperties": false, - "description": "information about external documentation", - "required": [ - "x-url", - "x-type" - ], - "properties": { - "x-description": { - "type": "string", - "description": "A short description of the target documentation. CommonMark syntax can be used for rich text representation." - }, - "x-url": { - "type": "string", - "format": "uri" - }, - "x-type": { - "type": "string", - "enum": [ - "api documentation", - "website", - "developer forum", - "mailing list", - "social media", - "publication" - ] - } - } - }, - "Parameter": { - "properties": { - "x-valueType": { - "type": "array", - "description": "a list of semantic identifiers of the parameter from identifiers.org, e.g. [http://identifiers.org/ncbigene/]", - "items": { - "type": "string", - "format": "uri" - }, - "uniqueItems": true - }, - "x-parameterType": { - "type": "string", - "description": "Type of parameter, e.g. InputParameter, NumberOfResultsReturned, OffsetParameter, SortParameter." - } - } - }, - "responseValueType": { - "required": [ - "path", - "valueType" - ], - "properties": { - "path": { - "type": "string", - "description": "The path, using dot notation, to the element of interest" - }, - "valueType": { - "type": "string", - "description": "The value type as specified by a concept URI for the element of interest" - } - } - }, - "tag": { - "properties": { - "x-id": { - "type": "string", - "description": "The name of the tag. Recommend that you use URI to specify the concept." - } - } - }, - "schema": { - "properties": { - "x-url": { - "type": "string", - "description": "The URL to a non-JSON schema." - } - } - } - } -} +{ + "title": "The smartAPI extension to OpenAPI 3.0.", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "description": "This is the root document object of the smartAPI definition file.", + "properties": { + "info": { + "$ref": "#/$defs/info" + }, + "servers": { + "type": "array", + "items": { + "$ref": "#/$defs/server" + } + }, + "x-externalResources": { + "type": "array", + "items": { + "$ref": "#/$defs/externalResource" + } + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/$defs/tag" + } + }, + "paths": { + "type": "object", + "patternProperties": { + "^\\/": { + "type": "object", + "patternProperties": { + "get|put|post|delete|options|head|patch|trace": { + "type": "object", + "properties": { + "summary": { + "type": "string" + }, + "parameters": { + "type": "array", + "items": { + "$ref": "#/$defs/Parameter" + } + }, + "responses": { + "type": "object", + "patternProperties": { + "[1-5](?:\\d{2}|XX)": { + "type": "object", + "properties": { + "x-responseValueType": { + "type": "array", + "items": { + "$ref": "#/$defs/responseValueType" + } + } + } + } + } + }, + "x-accessRestriction": { + "type": "string", + "description": "Access restrictions to invoke the operation. values: none, limited, fee.", + "enum": [ + "none", + "limited", + "fee" + ] + } + } + } + } + } + } + } + }, + "$defs": { + "Reference": { + "type": "object", + "required": [ + "$ref" + ], + "properties": { + "$ref": { + "type": "string", + "format": "uri-reference" + } + } + }, + "info": { + "properties": { + "x-otherContacts": { + "type": "array", + "items": { + "$ref": "#/$defs/contact" + } + }, + "x-accessRestriction": { + "type": "string", + "enum": [ + "none", + "limited", + "fee" + ], + "description": "Indicate whether there are restrictions to using the API. Values to use: none, limited, fee." + }, + "x-implementationLanguage": { + "type": "string", + "description": "API Implementation Language" + }, + "contact": { + "$ref": "#/$defs/contact" + }, + "termsOfService": { + "type": "string", + "format": "uri" + } + } + }, + "contact": { + "properties": { + "x-role": { + "type": "string", + "enum": [ + "responsible organization", + "responsible developer", + "contributor", + "support", + "document creator" + ] + }, + "x-id": { + "type": "string", + "format": "uri", + "description": "A resolvable HTTP URI that uniquely identifies the contact (e.g. orcid id github id)" + } + } + }, + "server": { + "properties": { + "x-location": { + "type": "string", + "description": "Location, city and country of the server hosting the API." + }, + "x-maturity": { + "type": "string", + "enum": [ + "development", + "staging", + "production", + "testing" + ] + } + } + }, + "externalResource": { + "type": "object", + "additionalProperties": false, + "description": "information about external documentation", + "required": [ + "x-url", + "x-type" + ], + "properties": { + "x-description": { + "type": "string", + "description": "A short description of the target documentation. CommonMark syntax can be used for rich text representation." + }, + "x-url": { + "type": "string", + "format": "uri" + }, + "x-type": { + "type": "string", + "enum": [ + "api documentation", + "website", + "developer forum", + "mailing list", + "social media", + "publication" + ] + } + } + }, + "Parameter": { + "properties": { + "x-valueType": { + "type": "array", + "description": "a list of semantic identifiers of the parameter from identifiers.org, e.g. [http://identifiers.org/ncbigene/]", + "items": { + "type": "string", + "format": "uri" + }, + "uniqueItems": true + }, + "x-parameterType": { + "type": "string", + "description": "Type of parameter, e.g. InputParameter, NumberOfResultsReturned, OffsetParameter, SortParameter." + } + } + }, + "responseValueType": { + "description": "The responseValueType field is now deprecated, switch to x-bte extensions for semantic annotation of the API response.", + "allOf": [ + { + "anyOf": [ + { "required": ["path"] }, + { "required": ["x-path"] } + ] + }, + { + "anyOf": [ + { "required": ["valueType"] }, + { "required": ["x-valueType"] } + ] + } + ] + }, + "tag": { + "properties": { + "x-id": { + "type": "string", + "description": "The name of the tag. Recommend that you use URI to specify the concept." + } + } + }, + "schema": { + "properties": { + "x-url": { + "type": "string", + "description": "The URL to a non-JSON schema." + } + } + } + } +} diff --git a/schemas/v3.0/smartapi_schema.json b/schemas/v3.0/smartapi_schema.json new file mode 100644 index 0000000000..b3e5979b6d --- /dev/null +++ b/schemas/v3.0/smartapi_schema.json @@ -0,0 +1,241 @@ +{ + "title": "The smartAPI extension to OpenAPI 3.0.", + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "description": "This is the root document object of the smartAPI definition file.", + "properties": { + "info": { + "$ref": "#/definitions/info" + }, + "servers": { + "type": "array", + "items": { + "$ref": "#/definitions/server" + } + }, + "x-externalResources": { + "type": "array", + "items": { + "$ref": "#/definitions/externalResource" + } + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/tag" + } + }, + "paths": { + "type": "object", + "patternProperties": { + "^\\/": { + "type": "object", + "patternProperties": { + "get|put|post|delete|options|head|patch|trace": { + "type": "object", + "required": [ + "summary" + ], + "properties": { + "summary": { + "type": "string" + }, + "parameters": { + "type": "array", + "items": { + "$ref": "#/definitions/Parameter" + } + }, + "responses": { + "type": "object", + "patternProperties": { + "[1-5](?:\\d{2}|XX)": { + "type": "object", + "properties": { + "x-responseValueType": { + "type": "array", + "items": { + "$ref": "#/definitions/responseValueType" + } + } + } + } + } + }, + "x-accessRestriction": { + "type": "string", + "description": "Access restrictions to invoke the operation. values: none, limited, fee.", + "enum": [ + "none", + "limited", + "fee" + ] + } + } + } + } + } + } + } + }, + "definitions": { + "Reference": { + "type": "object", + "required": [ + "$ref" + ], + "properties": { + "$ref": { + "type": "string", + "format": "uri-reference" + } + } + }, + "info": { + "required": [ + "termsOfService" + ], + "properties": { + "x-otherContacts": { + "type": "array", + "items": { + "$ref": "#/definitions/contact" + } + }, + "x-accessRestriction": { + "type": "string", + "enum": [ + "none", + "limited", + "fee" + ], + "description": "Indicate whether there are restrictions to using the API. Values to use: none, limited, fee." + }, + "x-implementationLanguage": { + "type": "string", + "description": "API Implementation Language" + }, + "contact": { + "$ref": "#/definitions/contact" + }, + "termsOfService": { + "type": "string", + "format": "uri" + } + } + }, + "contact": { + "properties": { + "x-role": { + "type": "string", + "enum": [ + "responsible organization", + "responsible developer", + "contributor", + "support" + ] + }, + "x-id": { + "type": "string", + "format": "uri", + "description": "A resolvable HTTP URI that uniqely identifies the contact (e.g. orcid id github id)" + } + } + }, + "server": { + "properties": { + "x-location": { + "type": "string", + "description": "Location, city and country of the server hosting the API." + }, + "x-maturity": { + "type": "string", + "enum": [ + "development", + "staging", + "production" + ] + } + } + }, + "externalResource": { + "type": "object", + "additionalProperties": false, + "description": "information about external documentation", + "required": [ + "x-url", + "x-type" + ], + "properties": { + "x-description": { + "type": "string", + "description": "A short description of the target documentation. CommonMark syntax can be used for rich text representation." + }, + "x-url": { + "type": "string", + "format": "uri" + }, + "x-type": { + "type": "string", + "enum": [ + "api documentation", + "website", + "developer forum", + "mailing list", + "social media", + "publication" + ] + } + } + }, + "Parameter": { + "properties": { + "x-valueType": { + "type": "array", + "description": "a list of semantic identifiers of the parameter from identifiers.org, e.g. [http://identifiers.org/ncbigene/]", + "items": { + "type": "string", + "format": "uri" + }, + "uniqueItems": true + }, + "x-parameterType": { + "type": "string", + "description": "Type of parameter, e.g. InputParameter, NumberOfResultsReturned, OffsetParameter, SortParameter." + } + } + }, + "responseValueType": { + "required": [ + "path", + "valueType" + ], + "properties": { + "path": { + "type": "string", + "description": "The path, using dot notation, to the element of interest" + }, + "valueType": { + "type": "string", + "description": "The value type as specified by a concept URI for the element of interest" + } + } + }, + "tag": { + "properties": { + "x-id": { + "type": "string", + "description": "The name of the tag. Recommend that you use URI to specify the concept." + } + } + }, + "schema": { + "properties": { + "x-url": { + "type": "string", + "description": "The URL to a non-JSON schema." + } + } + } + } +}