From 980a13c1caeafef0974db6bf99479ccc1db54f6a Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Thu, 19 Nov 2026 14:25:00 +0100 Subject: [PATCH] Declare the landing-page class of OGC API - Common - Part 1 The landing page, the API definition and the conformance declaration are the resources of the class landing-page of Common Part 1 (OGC 19-072), whose core holds only the HTTP and query-parameter tests. The service serves the three and declared core alone. Common Part 1 requires the landing page to link the conformance declaration under the relation type http://www.opengis.net/def/rel/ogc/1.0/conformance (/req/landing-page/root-success), and Features Part 1, on which Moving Features builds, under conformance (/req/core/root-success). The landing page links it under both. The three routes are marked with landing-page. ats_common_test.go holds a row per abstract test of the class, each read through the routing table the service runs. The API definition is validated against the OpenAPI 3.0 schema, vendored byte for byte in openapi/; it found the four EDR operations stating no responses, which OpenAPI 3.0 requires of every operation, and they state them. --- api/surface.json | 6 +- ats_common_test.go | 148 +++ edr.go | 5 +- main.go | 21 +- openapi/README.md | 13 + openapi/oas-3.0-schema.json | 1651 ++++++++++++++++++++++++++ samples/api-definition.json | 26 +- samples/conformance-declaration.json | 1 + samples/landing-page.json | 5 + 9 files changed, 1865 insertions(+), 11 deletions(-) create mode 100644 ats_common_test.go create mode 100644 openapi/oas-3.0-schema.json diff --git a/api/surface.json b/api/surface.json index 7acdd3b..95d4b28 100644 --- a/api/surface.json +++ b/api/surface.json @@ -2,13 +2,13 @@ { "method": "GET", "path": "/", - "conformanceClass": "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core", + "conformanceClass": "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/landing-page", "functions": [] }, { "method": "GET", "path": "/api", - "conformanceClass": "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core", + "conformanceClass": "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/landing-page", "functions": [] }, { @@ -390,7 +390,7 @@ { "method": "GET", "path": "/conformance", - "conformanceClass": "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core", + "conformanceClass": "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/landing-page", "functions": [] }, { diff --git a/ats_common_test.go b/ats_common_test.go new file mode 100644 index 0000000..89a3a8a --- /dev/null +++ b/ats_common_test.go @@ -0,0 +1,148 @@ +// The abstract tests of the class landing-page of OGC API – Common – Part 1: Core +// (OGC 19-072), as rows beside those of Moving Features Part 1 (#atsDischargedBy) +// and Part 4 (#atsPart4): the landing page, the API definition and the +// conformance declaration, each requested through the routing table the service +// runs (#newMux) and read against the schema the abstract test names. +// +// The landing page and the conformance declaration are validated against the +// landingPage and confClasses schemas of the vendored Moving Features document, +// which state the constraints of Common's landingPage.yaml, confClasses.yaml and +// link.yaml: the same required members of the same types. The API definition is +// validated against the OpenAPI 3.0 schema, vendored in openapi/ beside them. +package main + +import ( + "bytes" + "encoding/json" + "net/http/httptest" + "os" + "path/filepath" + "testing" + + "github.com/santhosh-tekuri/jsonschema/v6" +) + +// oasSchemaPath is the vendored JSON Schema of OpenAPI 3.0 documents. +const oasSchemaPath = "openapi/oas-3.0-schema.json" + +// atsCommonLandingPage is the class landing-page, its abstract tests in the +// order Common Part 1 gives them, each with the test that reads what it states. +var atsCommonLandingPage = []struct{ id, dischargedBy string }{ + {"/conf/landing-page/root-op", "TestCommonLandingPage"}, + {"/conf/landing-page/root-success", "TestCommonLandingPage"}, + {"/conf/landing-page/api-definition-op", "TestCommonAPIDefinition"}, + {"/conf/landing-page/api-definition-success", "TestCommonAPIDefinition"}, + {"/conf/landing-page/conformance-op", "TestCommonConformanceDeclaration"}, + {"/conf/landing-page/conformance-success", "TestCommonConformanceDeclaration"}, +} + +// commonGet requests path through the routing table the service runs. +func commonGet(path string) *httptest.ResponseRecorder { + rec := httptest.NewRecorder() + newMux().ServeHTTP(rec, httptest.NewRequest("GET", path, nil)) + return rec +} + +// root-op, root-success: the landing page answers 200, is a landingPage, and +// links the API definition (service-desc) and the conformance declaration under +// the relation type Common Part 1 requires, beside the one Features Part 1 does. +func TestCommonLandingPage(t *testing.T) { + rec := commonGet("/") + validate(t, ogcSchemas(t)("landingPage"), rec, "the landing page") + var page struct { + Links []struct{ Href, Rel string } `json:"links"` + } + if err := json.Unmarshal(rec.Body.Bytes(), &page); err != nil { + t.Fatal(err) + } + links := map[string]string{} + for _, l := range page.Links { + links[l.Rel] = l.Href + } + for rel, href := range map[string]string{ + "service-desc": "/api", + relConformance: "/conformance", + "conformance": "/conformance", + "data": "/collections", + } { + if links[rel] != href { + t.Errorf("the landing page links %q to %q, want %q", rel, links[rel], href) + } + } +} + +// api-definition-op, api-definition-success: the API definition the landing page +// links answers 200 and is an OpenAPI 3.0 document. +func TestCommonAPIDefinition(t *testing.T) { + f, err := os.Open(oasSchemaPath) + if err != nil { + t.Fatalf("the vendored OpenAPI schema is missing: %v", err) + } + defer f.Close() + doc, err := jsonschema.UnmarshalJSON(f) + if err != nil { + t.Fatal(err) + } + c := jsonschema.NewCompiler() + if err := c.AddResource("oas.json", doc); err != nil { + t.Fatal(err) + } + schema, err := c.Compile("oas.json") + if err != nil { + t.Fatal(err) + } + validate(t, schema, commonGet("/api"), "the API definition") + + // The schema refuses what is no OpenAPI 3.0 document, so the validation + // above asserts something. + for _, bad := range []string{`{"openapi":"3.0.3","paths":{}}`, `{"openapi":"2.0","info":{"title":"x","version":"1"},"paths":{}}`} { + v, err := jsonschema.UnmarshalJSON(bytes.NewReader([]byte(bad))) + if err != nil { + t.Fatal(err) + } + if schema.Validate(v) == nil { + t.Errorf("the OpenAPI schema admits %s", bad) + } + } +} + +// conformance-op, conformance-success: the conformance declaration answers 200, +// is a confClasses, and lists the classes of Common Part 1 the service implements. +func TestCommonConformanceDeclaration(t *testing.T) { + validate(t, ogcSchemas(t)("confClasses"), commonGet("/conformance"), "the conformance declaration") + declared := declaredClasses(t) + for _, c := range []string{confCommonCore, confCommonLanding} { + if !declared[c] { + t.Errorf("the conformance declaration does not list %s", c) + } + } +} + +// Every row names a test a test file declares, as #TestATSPart4RowsAreDischarged +// holds the rows of Part 4, and the class is the one the routes are marked with. +func TestCommonLandingPageRowsAreDischarged(t *testing.T) { + files, err := filepath.Glob("*_test.go") + if err != nil { + t.Fatal(err) + } + var src []byte + for _, f := range files { + b, err := os.ReadFile(f) + if err != nil { + t.Fatal(err) + } + src = append(src, b...) + } + for _, r := range atsCommonLandingPage { + if !bytes.Contains(src, []byte("func "+r.dischargedBy+"(")) { + t.Errorf("%s names %s, which no test file declares", r.id, r.dischargedBy) + } + } + for _, r := range routeTable() { + if r.path == "/" || r.path == "/api" || r.path == "/conformance" { + if r.class != confCommonLanding { + t.Errorf("GET %s is marked %s, want %s", r.path, r.class, confCommonLanding) + } + } + } +} diff --git a/edr.go b/edr.go index b0f3b9a..8454233 100644 --- a/edr.go +++ b/edr.go @@ -294,7 +294,10 @@ func edrPaths() map[string]any { for _, q := range edrQueries { out["/collections/{cid}/"+q.name] = map[string]any{"get": map[string]any{"summary": fmt.Sprintf( "OGC API - EDR: the %s query over a raster collection, coords a WKT %s, answered in CoverageJSON", - q.name, q.geometry)}} + q.name, q.geometry), + // Every operation of an OpenAPI 3.0 document states its responses, as + // the operations #apiDoc writes do. + "responses": map[string]any{"200": map[string]any{"description": "OK"}}}} } return out } diff --git a/main.go b/main.go index 7156699..794b631 100644 --- a/main.go +++ b/main.go @@ -190,9 +190,14 @@ const ( confMovingFeatures = "http://www.opengis.net/spec/ogcapi-movingfeatures-1/1.0/conf/movingfeatures" confCQuery = "http://www.opengis.net/spec/ogcapi-movingfeatures-4/1.0/conf/cquery" confCommonCore = "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core" + confCommonLanding = "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/landing-page" confCommonCollections = "https://www.opengis.net/spec/ogcapi-common-2/1.0/conf/collections" ) +// relConformance is the relation type OGC API - Common - Part 1 gives the link +// from the landing page to the conformance declaration. +const relConformance = "http://www.opengis.net/def/rel/ogc/1.0/conformance" + // extension marks a route that is a requirement of no class the tier declares: // a MobilityAPI extension, which the API definition names as one and which // changes no answer a declared class defines. @@ -213,9 +218,9 @@ type route struct { func routeTable() []route { rs := []route{ {"GET", "/health", health, extension}, - {"GET", "/", landing, confCommonCore}, - {"GET", "/api", apiDoc, confCommonCore}, - {"GET", "/conformance", conformance, confCommonCore}, + {"GET", "/", landing, confCommonLanding}, + {"GET", "/api", apiDoc, confCommonLanding}, + {"GET", "/conformance", conformance, confCommonLanding}, {"GET", "/collections", listCollections, confMFCollection}, {"POST", "/collections", postCollection, confMFCollection}, {"GET", "/collections/{cid}", getCollection, confMFCollection}, @@ -360,6 +365,12 @@ func ident(s string) string { return `"` + strings.ReplaceAll(s, `"`, `""`) + `" // be parameterised): a collection id must be a plain SQL identifier. var validID = regexp.MustCompile(`^[a-z_][a-z0-9_]*$`) +// landing writes the landing page. The conformance declaration is linked under +// both relation types the standards require of it: conformance, as OGC API - +// Features - Part 1 requires (/req/core/root-success), on which Moving Features +// builds, and relConformance, as OGC API - Common - Part 1 requires +// (/req/landing-page/root-success). A client compares a relation type as a +// string, so each finds the link it looks for. func landing(w http.ResponseWriter, r *http.Request) { writeJSON(w, 200, map[string]any{ "title": "MobilityAPI-go", "description": "OGC API – Moving Features over MobilityDB", @@ -367,6 +378,7 @@ func landing(w http.ResponseWriter, r *http.Request) { {"rel": "self", "href": "/", "type": "application/json"}, {"rel": "service-desc", "href": "/api", "type": "application/vnd.oai.openapi+json;version=3.0"}, {"rel": "conformance", "href": "/conformance", "type": "application/json"}, + {"rel": relConformance, "href": "/conformance", "type": "application/json"}, {"rel": "data", "href": "/collections", "type": "application/json"}, }}) } @@ -388,7 +400,8 @@ func conformance(w http.ResponseWriter, r *http.Request) { // conformsTo answers the identifiers the conformance declaration lists. func conformsTo() []string { classes := append([]string{ - confMFCommon, confMFCollection, confMovingFeatures, confCQuery, confCommonCore, confCommonCollections, + confMFCommon, confMFCollection, confMovingFeatures, confCQuery, confCommonCore, confCommonLanding, + confCommonCollections, }, append(coverageConformance, edrConformance)...) var out []string for _, c := range classes { diff --git a/openapi/README.md b/openapi/README.md index e10a106..6a09d2e 100644 --- a/openapi/README.md +++ b/openapi/README.md @@ -112,3 +112,16 @@ Measured against the resolved schema, under either reading of `format`: The resolutions do narrow what the schema admits, and the test states each narrowing as a case: a scalar `values` (2), a three-character unit that is no common code such as `deg` (3), and an instant that is no RFC 3339 date-time (5). + +# The OpenAPI 3.0 schema + +`oas-3.0-schema.json` is the JSON Schema the OpenAPI Initiative publishes for OpenAPI 3.0.x +documents, vendored byte for byte: + + URL https://spec.openapis.org/oas/3.0/schema/2024-10-18 + bytes 35755 + sha256 2385f5bbb8c37878daae73baeabe7f34b2f022a4a8c049329ee61f71796f039c + +`ats_common_test.go` validates the API definition the tier writes against it, as abstract +test `/conf/landing-page/api-definition-success` of OGC API — Common — Part 1 asks. The copy +is never edited. diff --git a/openapi/oas-3.0-schema.json b/openapi/oas-3.0-schema.json new file mode 100644 index 0000000..a9cd941 --- /dev/null +++ b/openapi/oas-3.0-schema.json @@ -0,0 +1,1651 @@ +{ + "id": "https://spec.openapis.org/oas/3.0/schema/2024-10-18", + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "The description of OpenAPI v3.0.x Documents", + "type": "object", + "required": [ + "openapi", + "info", + "paths" + ], + "properties": { + "openapi": { + "type": "string", + "pattern": "^3\\.0\\.\\d(-.+)?$" + }, + "info": { + "$ref": "#/definitions/Info" + }, + "externalDocs": { + "$ref": "#/definitions/ExternalDocumentation" + }, + "servers": { + "type": "array", + "items": { + "$ref": "#/definitions/Server" + } + }, + "security": { + "type": "array", + "items": { + "$ref": "#/definitions/SecurityRequirement" + } + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/Tag" + }, + "uniqueItems": true + }, + "paths": { + "$ref": "#/definitions/Paths" + }, + "components": { + "$ref": "#/definitions/Components" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false, + "definitions": { + "Reference": { + "type": "object", + "required": [ + "$ref" + ], + "patternProperties": { + "^\\$ref$": { + "type": "string", + "format": "uri-reference" + } + } + }, + "Info": { + "type": "object", + "required": [ + "title", + "version" + ], + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "termsOfService": { + "type": "string", + "format": "uri-reference" + }, + "contact": { + "$ref": "#/definitions/Contact" + }, + "license": { + "$ref": "#/definitions/License" + }, + "version": { + "type": "string" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "Contact": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string", + "format": "uri-reference" + }, + "email": { + "type": "string", + "format": "email" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "License": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string", + "format": "uri-reference" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "Server": { + "type": "object", + "required": [ + "url" + ], + "properties": { + "url": { + "type": "string" + }, + "description": { + "type": "string" + }, + "variables": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/ServerVariable" + } + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "ServerVariable": { + "type": "object", + "required": [ + "default" + ], + "properties": { + "enum": { + "type": "array", + "items": { + "type": "string" + } + }, + "default": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "Components": { + "type": "object", + "properties": { + "schemas": { + "type": "object", + "patternProperties": { + "^[a-zA-Z0-9\\.\\-_]+$": { + "oneOf": [ + { + "$ref": "#/definitions/Schema" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + } + }, + "responses": { + "type": "object", + "patternProperties": { + "^[a-zA-Z0-9\\.\\-_]+$": { + "oneOf": [ + { + "$ref": "#/definitions/Reference" + }, + { + "$ref": "#/definitions/Response" + } + ] + } + } + }, + "parameters": { + "type": "object", + "patternProperties": { + "^[a-zA-Z0-9\\.\\-_]+$": { + "oneOf": [ + { + "$ref": "#/definitions/Reference" + }, + { + "$ref": "#/definitions/Parameter" + } + ] + } + } + }, + "examples": { + "type": "object", + "patternProperties": { + "^[a-zA-Z0-9\\.\\-_]+$": { + "oneOf": [ + { + "$ref": "#/definitions/Reference" + }, + { + "$ref": "#/definitions/Example" + } + ] + } + } + }, + "requestBodies": { + "type": "object", + "patternProperties": { + "^[a-zA-Z0-9\\.\\-_]+$": { + "oneOf": [ + { + "$ref": "#/definitions/Reference" + }, + { + "$ref": "#/definitions/RequestBody" + } + ] + } + } + }, + "headers": { + "type": "object", + "patternProperties": { + "^[a-zA-Z0-9\\.\\-_]+$": { + "oneOf": [ + { + "$ref": "#/definitions/Reference" + }, + { + "$ref": "#/definitions/Header" + } + ] + } + } + }, + "securitySchemes": { + "type": "object", + "patternProperties": { + "^[a-zA-Z0-9\\.\\-_]+$": { + "oneOf": [ + { + "$ref": "#/definitions/Reference" + }, + { + "$ref": "#/definitions/SecurityScheme" + } + ] + } + } + }, + "links": { + "type": "object", + "patternProperties": { + "^[a-zA-Z0-9\\.\\-_]+$": { + "oneOf": [ + { + "$ref": "#/definitions/Reference" + }, + { + "$ref": "#/definitions/Link" + } + ] + } + } + }, + "callbacks": { + "type": "object", + "patternProperties": { + "^[a-zA-Z0-9\\.\\-_]+$": { + "oneOf": [ + { + "$ref": "#/definitions/Reference" + }, + { + "$ref": "#/definitions/Callback" + } + ] + } + } + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "Schema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "multipleOf": { + "type": "number", + "minimum": 0, + "exclusiveMinimum": true + }, + "maximum": { + "type": "number" + }, + "exclusiveMaximum": { + "type": "boolean", + "default": false + }, + "minimum": { + "type": "number" + }, + "exclusiveMinimum": { + "type": "boolean", + "default": false + }, + "maxLength": { + "type": "integer", + "minimum": 0 + }, + "minLength": { + "type": "integer", + "minimum": 0, + "default": 0 + }, + "pattern": { + "type": "string", + "format": "regex" + }, + "maxItems": { + "type": "integer", + "minimum": 0 + }, + "minItems": { + "type": "integer", + "minimum": 0, + "default": 0 + }, + "uniqueItems": { + "type": "boolean", + "default": false + }, + "maxProperties": { + "type": "integer", + "minimum": 0 + }, + "minProperties": { + "type": "integer", + "minimum": 0, + "default": 0 + }, + "required": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1, + "uniqueItems": true + }, + "enum": { + "type": "array", + "items": {}, + "minItems": 1, + "uniqueItems": false + }, + "type": { + "type": "string", + "enum": [ + "array", + "boolean", + "integer", + "number", + "object", + "string" + ] + }, + "not": { + "oneOf": [ + { + "$ref": "#/definitions/Schema" + }, + { + "$ref": "#/definitions/Reference" + } + ] + }, + "allOf": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/definitions/Schema" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + }, + "oneOf": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/definitions/Schema" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + }, + "anyOf": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/definitions/Schema" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + }, + "items": { + "oneOf": [ + { + "$ref": "#/definitions/Schema" + }, + { + "$ref": "#/definitions/Reference" + } + ] + }, + "properties": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "$ref": "#/definitions/Schema" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + }, + "additionalProperties": { + "oneOf": [ + { + "$ref": "#/definitions/Schema" + }, + { + "$ref": "#/definitions/Reference" + }, + { + "type": "boolean" + } + ], + "default": true + }, + "description": { + "type": "string" + }, + "format": { + "type": "string" + }, + "default": {}, + "nullable": { + "type": "boolean", + "default": false + }, + "discriminator": { + "$ref": "#/definitions/Discriminator" + }, + "readOnly": { + "type": "boolean", + "default": false + }, + "writeOnly": { + "type": "boolean", + "default": false + }, + "example": {}, + "externalDocs": { + "$ref": "#/definitions/ExternalDocumentation" + }, + "deprecated": { + "type": "boolean", + "default": false + }, + "xml": { + "$ref": "#/definitions/XML" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "Discriminator": { + "type": "object", + "required": [ + "propertyName" + ], + "properties": { + "propertyName": { + "type": "string" + }, + "mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "XML": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "namespace": { + "type": "string", + "format": "uri" + }, + "prefix": { + "type": "string" + }, + "attribute": { + "type": "boolean", + "default": false + }, + "wrapped": { + "type": "boolean", + "default": false + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "Response": { + "type": "object", + "required": [ + "description" + ], + "properties": { + "description": { + "type": "string" + }, + "headers": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "$ref": "#/definitions/Header" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + }, + "content": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/MediaType" + } + }, + "links": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "$ref": "#/definitions/Link" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "MediaType": { + "type": "object", + "properties": { + "schema": { + "oneOf": [ + { + "$ref": "#/definitions/Schema" + }, + { + "$ref": "#/definitions/Reference" + } + ] + }, + "example": {}, + "examples": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "$ref": "#/definitions/Example" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + }, + "encoding": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Encoding" + } + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false, + "allOf": [ + { + "$ref": "#/definitions/ExampleXORExamples" + } + ] + }, + "Example": { + "type": "object", + "properties": { + "summary": { + "type": "string" + }, + "description": { + "type": "string" + }, + "value": {}, + "externalValue": { + "type": "string", + "format": "uri-reference" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "Header": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "required": { + "type": "boolean", + "default": false + }, + "deprecated": { + "type": "boolean", + "default": false + }, + "allowEmptyValue": { + "type": "boolean", + "default": false + }, + "style": { + "type": "string", + "enum": [ + "simple" + ], + "default": "simple" + }, + "explode": { + "type": "boolean" + }, + "allowReserved": { + "type": "boolean", + "default": false + }, + "schema": { + "oneOf": [ + { + "$ref": "#/definitions/Schema" + }, + { + "$ref": "#/definitions/Reference" + } + ] + }, + "content": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/MediaType" + }, + "minProperties": 1, + "maxProperties": 1 + }, + "example": {}, + "examples": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "$ref": "#/definitions/Example" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false, + "allOf": [ + { + "$ref": "#/definitions/ExampleXORExamples" + }, + { + "$ref": "#/definitions/SchemaXORContent" + } + ] + }, + "Paths": { + "type": "object", + "patternProperties": { + "^\\/": { + "$ref": "#/definitions/PathItem" + }, + "^x-": {} + }, + "additionalProperties": false + }, + "PathItem": { + "type": "object", + "properties": { + "$ref": { + "type": "string" + }, + "summary": { + "type": "string" + }, + "description": { + "type": "string" + }, + "get": { + "$ref": "#/definitions/Operation" + }, + "put": { + "$ref": "#/definitions/Operation" + }, + "post": { + "$ref": "#/definitions/Operation" + }, + "delete": { + "$ref": "#/definitions/Operation" + }, + "options": { + "$ref": "#/definitions/Operation" + }, + "head": { + "$ref": "#/definitions/Operation" + }, + "patch": { + "$ref": "#/definitions/Operation" + }, + "trace": { + "$ref": "#/definitions/Operation" + }, + "servers": { + "type": "array", + "items": { + "$ref": "#/definitions/Server" + } + }, + "parameters": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/definitions/Parameter" + }, + { + "$ref": "#/definitions/Reference" + } + ] + }, + "uniqueItems": true + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "Operation": { + "type": "object", + "required": [ + "responses" + ], + "properties": { + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "summary": { + "type": "string" + }, + "description": { + "type": "string" + }, + "externalDocs": { + "$ref": "#/definitions/ExternalDocumentation" + }, + "operationId": { + "type": "string" + }, + "parameters": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/definitions/Parameter" + }, + { + "$ref": "#/definitions/Reference" + } + ] + }, + "uniqueItems": true + }, + "requestBody": { + "oneOf": [ + { + "$ref": "#/definitions/RequestBody" + }, + { + "$ref": "#/definitions/Reference" + } + ] + }, + "responses": { + "$ref": "#/definitions/Responses" + }, + "callbacks": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "$ref": "#/definitions/Callback" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + }, + "deprecated": { + "type": "boolean", + "default": false + }, + "security": { + "type": "array", + "items": { + "$ref": "#/definitions/SecurityRequirement" + } + }, + "servers": { + "type": "array", + "items": { + "$ref": "#/definitions/Server" + } + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "Responses": { + "type": "object", + "properties": { + "default": { + "oneOf": [ + { + "$ref": "#/definitions/Response" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + }, + "patternProperties": { + "^[1-5](?:\\d{2}|XX)$": { + "oneOf": [ + { + "$ref": "#/definitions/Response" + }, + { + "$ref": "#/definitions/Reference" + } + ] + }, + "^x-": {} + }, + "minProperties": 1, + "additionalProperties": false + }, + "SecurityRequirement": { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "Tag": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "externalDocs": { + "$ref": "#/definitions/ExternalDocumentation" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "ExternalDocumentation": { + "type": "object", + "required": [ + "url" + ], + "properties": { + "description": { + "type": "string" + }, + "url": { + "type": "string", + "format": "uri-reference" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "ExampleXORExamples": { + "description": "Example and examples are mutually exclusive", + "not": { + "required": [ + "example", + "examples" + ] + } + }, + "SchemaXORContent": { + "description": "Schema and content are mutually exclusive, at least one is required", + "not": { + "required": [ + "schema", + "content" + ] + }, + "oneOf": [ + { + "required": [ + "schema" + ] + }, + { + "required": [ + "content" + ], + "description": "Some properties are not allowed if content is present", + "allOf": [ + { + "not": { + "required": [ + "style" + ] + } + }, + { + "not": { + "required": [ + "explode" + ] + } + }, + { + "not": { + "required": [ + "allowReserved" + ] + } + }, + { + "not": { + "required": [ + "example" + ] + } + }, + { + "not": { + "required": [ + "examples" + ] + } + } + ] + } + ] + }, + "Parameter": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "in": { + "type": "string" + }, + "description": { + "type": "string" + }, + "required": { + "type": "boolean", + "default": false + }, + "deprecated": { + "type": "boolean", + "default": false + }, + "allowEmptyValue": { + "type": "boolean", + "default": false + }, + "style": { + "type": "string" + }, + "explode": { + "type": "boolean" + }, + "allowReserved": { + "type": "boolean", + "default": false + }, + "schema": { + "oneOf": [ + { + "$ref": "#/definitions/Schema" + }, + { + "$ref": "#/definitions/Reference" + } + ] + }, + "content": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/MediaType" + }, + "minProperties": 1, + "maxProperties": 1 + }, + "example": {}, + "examples": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "$ref": "#/definitions/Example" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false, + "required": [ + "name", + "in" + ], + "allOf": [ + { + "$ref": "#/definitions/ExampleXORExamples" + }, + { + "$ref": "#/definitions/SchemaXORContent" + } + ], + "oneOf": [ + { + "$ref": "#/definitions/PathParameter" + }, + { + "$ref": "#/definitions/QueryParameter" + }, + { + "$ref": "#/definitions/HeaderParameter" + }, + { + "$ref": "#/definitions/CookieParameter" + } + ] + }, + "PathParameter": { + "description": "Parameter in path", + "required": [ + "required" + ], + "properties": { + "in": { + "enum": [ + "path" + ] + }, + "style": { + "enum": [ + "matrix", + "label", + "simple" + ], + "default": "simple" + }, + "required": { + "enum": [ + true + ] + } + } + }, + "QueryParameter": { + "description": "Parameter in query", + "properties": { + "in": { + "enum": [ + "query" + ] + }, + "style": { + "enum": [ + "form", + "spaceDelimited", + "pipeDelimited", + "deepObject" + ], + "default": "form" + } + } + }, + "HeaderParameter": { + "description": "Parameter in header", + "properties": { + "in": { + "enum": [ + "header" + ] + }, + "style": { + "enum": [ + "simple" + ], + "default": "simple" + } + } + }, + "CookieParameter": { + "description": "Parameter in cookie", + "properties": { + "in": { + "enum": [ + "cookie" + ] + }, + "style": { + "enum": [ + "form" + ], + "default": "form" + } + } + }, + "RequestBody": { + "type": "object", + "required": [ + "content" + ], + "properties": { + "description": { + "type": "string" + }, + "content": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/MediaType" + } + }, + "required": { + "type": "boolean", + "default": false + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "SecurityScheme": { + "oneOf": [ + { + "$ref": "#/definitions/APIKeySecurityScheme" + }, + { + "$ref": "#/definitions/HTTPSecurityScheme" + }, + { + "$ref": "#/definitions/OAuth2SecurityScheme" + }, + { + "$ref": "#/definitions/OpenIdConnectSecurityScheme" + } + ] + }, + "APIKeySecurityScheme": { + "type": "object", + "required": [ + "type", + "name", + "in" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "apiKey" + ] + }, + "name": { + "type": "string" + }, + "in": { + "type": "string", + "enum": [ + "header", + "query", + "cookie" + ] + }, + "description": { + "type": "string" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "HTTPSecurityScheme": { + "type": "object", + "required": [ + "scheme", + "type" + ], + "properties": { + "scheme": { + "type": "string" + }, + "bearerFormat": { + "type": "string" + }, + "description": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "http" + ] + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false, + "oneOf": [ + { + "description": "Bearer", + "properties": { + "scheme": { + "type": "string", + "pattern": "^[Bb][Ee][Aa][Rr][Ee][Rr]$" + } + } + }, + { + "description": "Non Bearer", + "not": { + "required": [ + "bearerFormat" + ] + }, + "properties": { + "scheme": { + "not": { + "type": "string", + "pattern": "^[Bb][Ee][Aa][Rr][Ee][Rr]$" + } + } + } + } + ] + }, + "OAuth2SecurityScheme": { + "type": "object", + "required": [ + "type", + "flows" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "oauth2" + ] + }, + "flows": { + "$ref": "#/definitions/OAuthFlows" + }, + "description": { + "type": "string" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "OpenIdConnectSecurityScheme": { + "type": "object", + "required": [ + "type", + "openIdConnectUrl" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "openIdConnect" + ] + }, + "openIdConnectUrl": { + "type": "string", + "format": "uri-reference" + }, + "description": { + "type": "string" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "OAuthFlows": { + "type": "object", + "properties": { + "implicit": { + "$ref": "#/definitions/ImplicitOAuthFlow" + }, + "password": { + "$ref": "#/definitions/PasswordOAuthFlow" + }, + "clientCredentials": { + "$ref": "#/definitions/ClientCredentialsFlow" + }, + "authorizationCode": { + "$ref": "#/definitions/AuthorizationCodeOAuthFlow" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "ImplicitOAuthFlow": { + "type": "object", + "required": [ + "authorizationUrl", + "scopes" + ], + "properties": { + "authorizationUrl": { + "type": "string", + "format": "uri-reference" + }, + "refreshUrl": { + "type": "string", + "format": "uri-reference" + }, + "scopes": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "PasswordOAuthFlow": { + "type": "object", + "required": [ + "tokenUrl", + "scopes" + ], + "properties": { + "tokenUrl": { + "type": "string", + "format": "uri-reference" + }, + "refreshUrl": { + "type": "string", + "format": "uri-reference" + }, + "scopes": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "ClientCredentialsFlow": { + "type": "object", + "required": [ + "tokenUrl", + "scopes" + ], + "properties": { + "tokenUrl": { + "type": "string", + "format": "uri-reference" + }, + "refreshUrl": { + "type": "string", + "format": "uri-reference" + }, + "scopes": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "AuthorizationCodeOAuthFlow": { + "type": "object", + "required": [ + "authorizationUrl", + "tokenUrl", + "scopes" + ], + "properties": { + "authorizationUrl": { + "type": "string", + "format": "uri-reference" + }, + "tokenUrl": { + "type": "string", + "format": "uri-reference" + }, + "refreshUrl": { + "type": "string", + "format": "uri-reference" + }, + "scopes": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + }, + "Link": { + "type": "object", + "properties": { + "operationId": { + "type": "string" + }, + "operationRef": { + "type": "string", + "format": "uri-reference" + }, + "parameters": { + "type": "object", + "additionalProperties": {} + }, + "requestBody": {}, + "description": { + "type": "string" + }, + "server": { + "$ref": "#/definitions/Server" + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false, + "not": { + "description": "Operation Id and Operation Ref are mutually exclusive", + "required": [ + "operationId", + "operationRef" + ] + } + }, + "Callback": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/PathItem" + }, + "patternProperties": { + "^x-": {} + } + }, + "Encoding": { + "type": "object", + "properties": { + "contentType": { + "type": "string" + }, + "headers": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "$ref": "#/definitions/Header" + }, + { + "$ref": "#/definitions/Reference" + } + ] + } + }, + "style": { + "type": "string", + "enum": [ + "form", + "spaceDelimited", + "pipeDelimited", + "deepObject" + ] + }, + "explode": { + "type": "boolean" + }, + "allowReserved": { + "type": "boolean", + "default": false + } + }, + "patternProperties": { + "^x-": {} + }, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/samples/api-definition.json b/samples/api-definition.json index bdecef8..334f299 100644 --- a/samples/api-definition.json +++ b/samples/api-definition.json @@ -14,7 +14,7 @@ } }, "summary": "Landing page", - "x-conformance-class": "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core" + "x-conformance-class": "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/landing-page" } }, "/api": { @@ -25,7 +25,7 @@ } }, "summary": "API definition", - "x-conformance-class": "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core" + "x-conformance-class": "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/landing-page" } }, "/collections": { @@ -95,6 +95,11 @@ }, "/collections/{cid}/area": { "get": { + "responses": { + "200": { + "description": "OK" + } + }, "summary": "OGC API - EDR: the area query over a raster collection, coords a WKT POLYGON, answered in CoverageJSON", "x-conformance-class": "http://www.opengis.net/spec/ogcapi-edr-1/1.1/conf/core" } @@ -112,6 +117,11 @@ }, "/collections/{cid}/corridor": { "get": { + "responses": { + "200": { + "description": "OK" + } + }, "summary": "OGC API - EDR: the corridor query over a raster collection, coords a WKT LINESTRING, answered in CoverageJSON", "x-conformance-class": "http://www.opengis.net/spec/ogcapi-edr-1/1.1/conf/core" } @@ -596,6 +606,11 @@ }, "/collections/{cid}/position": { "get": { + "responses": { + "200": { + "description": "OK" + } + }, "summary": "OGC API - EDR: the position query over a raster collection, coords a WKT POINT, answered in CoverageJSON", "x-conformance-class": "http://www.opengis.net/spec/ogcapi-edr-1/1.1/conf/core" } @@ -635,6 +650,11 @@ }, "/collections/{cid}/trajectory": { "get": { + "responses": { + "200": { + "description": "OK" + } + }, "summary": "OGC API - EDR: the trajectory query over a raster collection, coords a WKT LINESTRING, answered in CoverageJSON", "x-conformance-class": "http://www.opengis.net/spec/ogcapi-edr-1/1.1/conf/core" } @@ -647,7 +667,7 @@ } }, "summary": "Conformance declaration", - "x-conformance-class": "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core" + "x-conformance-class": "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/landing-page" } }, "/health": { diff --git a/samples/conformance-declaration.json b/samples/conformance-declaration.json index febe123..3befe08 100644 --- a/samples/conformance-declaration.json +++ b/samples/conformance-declaration.json @@ -5,6 +5,7 @@ "http://www.opengis.net/spec/ogcapi-movingfeatures-1/1.0/conf/movingfeatures", "http://www.opengis.net/spec/ogcapi-movingfeatures-4/1.0/conf/cquery", "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core", + "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/landing-page", "https://www.opengis.net/spec/ogcapi-common-2/1.0/conf/collections", "http://www.opengis.net/spec/ogcapi-common-2/1.0/conf/collections", "https://www.opengis.net/spec/ogcapi-coverages-1/1.0/conf/core", diff --git a/samples/landing-page.json b/samples/landing-page.json index 778e7f4..d989bde 100644 --- a/samples/landing-page.json +++ b/samples/landing-page.json @@ -16,6 +16,11 @@ "rel": "conformance", "type": "application/json" }, + { + "href": "/conformance", + "rel": "http://www.opengis.net/def/rel/ogc/1.0/conformance", + "type": "application/json" + }, { "href": "/collections", "rel": "data",