Skip to content

Part 5: Application schema discovery for profiles #1025

@joostfarla

Description

@joostfarla

Current situation

  • Multiple variants share the same media types application/json and application/geo+json
  • Profiles are introduced to flag additional semantics for a variant (constraints, conventions, extensions)
  • Multiple profiles can be applied on each individual resource (if compatible with each other)
  • Profiles can be negotiated using the profile query-parameter
  • Profiles which are applied are communicated at runtime via response links (RFC 6906, header or payload)

The problem

  • OpenAPI Specification is not profile-aware and cannot key schema selection on RFC 6906 profile
  • This forces the use of bundled schemas, using oneOf (or similar), sacrificing the correlation between profile and schema
  • As a result, it is not discoverable what the impact of an individual profile is on the response schema

For example:

application/geo+json:
  schema:
    oneOf:
      - $ref: "#/components/schemas/FeatureRfc7946"
      - $ref: "#/components/schemas/FeatureJsonFg"
      - $ref: "#/components/schemas/MyCustomOgcRecord"

A machine cannot automatically determine that, when retrieving a document with profile https://www.opengis.net/def/profile/OGC/0/ogc-record applied, the expected response schema is #/components/schemas/MyCustomOgcRecord.

Suggestion 1: Introduce discovery mechanism for profile schemas

Introduce a standard location, where the mapping (from a global context) is published between profiles and schemas.
The location could be for example the landing page or a dedicated "profiles" page.

The mapping could look similar to this:

{
    "profileSchemas": {
        "http://www.opengis.net/def/profile/OGC/0/rfc7946": {
            "application/geo+json": "https://schemas.example.org/v1/FeatureRfc7946.json",
        },
        "http://www.opengis.net/def/profile/OGC/0/jsonfg": {
            "application/geo+json": "https://schemas.example.org/v1/FeatureJsonFg.json",
        },
        "https://www.opengis.net/def/profile/OGC/0/ogc-record": {
            "application/geo+json": "https://schemas.example.org/v1/MyCustomOgcRecord.json",
        },
    }
}

The schema must be a resolvable URL pointing to a schema document, corresponding to the media type.
Schema documents can also be documents other than JSON Schema, such as an XSD document for a GML application schema.

The above would enable static validation / codegen without losing determinism.

Suggestion 2: Support retrieving a compiled application schema for a given (set of) profile(s)

In addition to retrieving the logical schema for every collection (by requesting /collections/{collectionId}/schema), also support retrieving application schemas by passing a (set of) profile(s) as a query parameter.

@cportele can you share your current LDproxy implementation as a starting point?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions