-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schemas for Create/Replace/Update #740
Comments
Meetings 2022-08-15: @pvretano would probably have the same issue with the Records implementation. He will look into the issue and if that would also be a problem for him, too. We only need to say anything in the standard, if it is an issue for multiple implementations. If others have comments, their feedback would be valuable, too. |
Maybe we do not need separate schemas for Create/Update? JSON Schema (and the OpenAPI schema variant) specifies annotations
Spec reference: https://json-schema.org/draft/2020-12/json-schema-validation.html#name-readonly-and-writeonly Since the mapping between readOnly and writeOnly properties is unspecified and unknown to a client, the client still needs a capability to retrieve a representation in the write-schema. For Update (PATCH) a different schema is still required in any case as the differences cannot be expressed using annotations (no required properties, null must be allowed). |
Meeting 2022-10-24:
|
My proposal is documented below. We should discuss this, before I create a pull request. The JSON Schema of a Feature CollectionInstead of requirements to create a JSON Schema for a GeoJSON feature, we should provide a encoding-independent JSON Schema that specifies all the feature properties. This follows the same approach as the Queryables, Sortables and Tile Set Metadata resources. Note that APIs that want to encode The encoding-independent JSON Schema should follow the schema recommendations for the Queryables resource. The JSON Schema will use The property that represents the We should also address #797 in this context, that is, specify rules how to express feature-feature relationships in such a schema. Note that this is separate from the considerations how to express relationships in the encoded data, where in a Web API a typical approach will be to represent them as a URI or web link consistent with RFC 8288. A reference would then be represented as either a string or integer, the Here is an example schema: {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"title": "Roads",
"description": "A road is a metalled way for vehicles.",
"type": "object",
"required": ["id", "geometry", "type", "level"],
"properties": {
"id": {"type": "integer", "x-ogc-role": "ID", "readOnly": true},
"geometry": {
"format": "geometry-linestring"
},
"type": {
"title": "Type",
"type": "string",
"enum": ["Primary", "Motorway"]
},
"name": {"title": "Name", "type": "string"},
"number": {"title": "Number", "type": "string"},
"level": { "title": "Level", "type": "integer", "enum": [0, 1, 2] },
"inMunicipality": {
"title" : "In Municipality" ,
"type" : "integer" ,
"readOnly" : true,
"$comment" : "readOnly, because it is derived from the data",
"x-ogc-role" : "reference",
"x-ogc-collectionId": "municipality"
},
"maintainers": {
"title": "Organizations maintaining this Road",
"type": "array",
"items": {
"type": "string",
"x-ogc-role": "reference",
"x-ogc-collectionId": "organization",
"x-ogc-apiLandingPage": "https://www.example.com/api/v1/road-maintenance"
}
}
},
"additionalProperties": false
} Encoding of feature relationshipsIt should be possible to request the encoding of the feature-relationships depending on the need of the client. In the work on JSON-FG it was identified that different use cases will prefer different representations of a feature-feature relationship in GeoJSON / JSON-FG (link). IETF has specified RFC 6906 for such cases using the concept of profiles:
The idea would be to define profiles for different ways to express a relationship in an instance. The examples below use a GeoJSON representation, but this could apply to other media types, too. Some media types may only support a subset of the profiles. An example would be media types that only support scalar property values. Example 1: As a link object with a URI and a human readable title (profile {
"type": "Feature",
"id": 1,
"geometry": {...},
"properties": {
"type": "Primary",
"level": 1,
"inMunicipality": {
"href": "/collections/municipalities/items/15",
"title": "Tanelorn"
},
"maintainers": [ {
"href": "https://www.example.com/api/v1/road-maintenance/collections/organization/items/Acme",
"title": "Acme Inc."
} ]
},
"links:": [
{
"href": "http://www.opengis.net/def/profile/ogc/0/rel-as-link",
"rel": "profile"
}
]
} Example 2: As a URI (profile {
"type": "Feature",
"id": 1,
"geometry": {...},
"properties": {
"type": "Primary",
"level": 1,
"inMunicipality": "/collections/municipalities/items/15",
"maintainers": [ "https://www.example.com/api/v1/road-maintenance/collections/organization/items/Acme" ]
},
"links:": [
{
"href": "http://www.opengis.net/def/profile/ogc/0/rel-as-uri",
"rel": "profile"
}
]
} Example 3: Just the identifier (the default profile consistent with the encoding-independent schema, {
"type": "Feature",
"id": 1,
"geometry": {...},
"properties": {
"type": "Primary",
"level": 1,
"inMunicipality": 15,
"maintainers": [ "Acme" ]
}
} Example 4: As a web link with a URI, a link relation type and other optional link attributes (profile {
"type": "Feature",
"id": 1,
"geometry": {...},
"properties": {
"type": "Primary",
"level": 1
},
"links:": [
{
"href": "/collections/municipalities/items/15",
"rel": "https://www.example.com/def/rel/within",
"title": "Tanelorn"
},
{
"href": "https://www.example.com/api/v1/road-maintenance/collections/organization/items/Acme",
"rel": "https://www.example.com/def/rel/maintainer",
"title": "Acme Inc."
},
{
"href": "http://www.opengis.net/def/profile/ogc/0/rel-as-weblink",
"rel": "profile"
}
]
} Note: If the response is a feature collection, the links also need an anchor since the link context is not the resource, but an embedded resource. For example, the JSON link object for the 10th feature would be the following, if the payload is GeoJSON or JSON-FG. {
"href" : "/collections/municipalities/items/15",
"anchor": "#/features/9",
"rel" : "https://www.example.com/def/rel/within",
"title": "Tanelorn"
} Requesting a profile in a Features requestWhen requesting features via an API, a Note: There were also attempts to standardize HTTP content negotiation for profiles in IETF (HTTPAPI WG) and W3C (DXWG), but these efforts did not gain much traction. Different clients / use cases will prefer different representations. For example, for presentation to a human, a title and a resolvable URI may be important and the client uses For cases where the client has knowledge about the data structures and wants to process data, just the local id of the referenced object may be sufficient ( |
There was a discussion during the April 2023 Code Sprint with general agreement on the approach. As a result, we could get rid of the need for specific schemas for Create, Replace or Update and address #797 at the same time. As a consequence, the discussion of schemas could be moved to the Schema extension. I have made minor updates to the previous comment based on the discussion. In addition we discussed:
@cportele will now work on a pull request. @pvretano @jerstlouis @maxcollombin - please correct/add anything that I missed or got wrong. |
Before working on a pull request, I have made an implementation in ldproxy and updated the demonstration deployment at demo.ldproxy.net. Some remarks on the implementation: Additional
|
I recently became aware of Features - Part 5 and found the Create, Replace and Update shemas in there. |
@m-mohr The OpenAPI documentation describes the API and the responses to the operations on different resources. Those responses may include schemas, which are normally specific to a particular media type. The Features - Part 5: Schemas is mainly focused on describing the properties (measured/observed) of the data in a collection, in a manner agnostic of a particular representation or particular access mechanism. It describes the data model behind the API. Note that this issue has gone beyond the original "Create/Replace/Update" scope from the title, and also addresses multiple profile and read/write access to properties. It is my hope that this can be a Common building block that we can also use in Coverages to describe the RangeType. |
Thanks. Hmm, I still don't quite get it. As JSON Schema is JSON-specific, you can (afaik) also describe all this per collection in the API document (I'm not saying that I'd prefer that). It's just still not clear to me what the difference is and I think this should be made very clear in the specification. |
|
Let me just add another reason for extending JSON Schema for feature collections: Defining variables (observedProperties) that can be measured that has a definition samewhere else and has UoM. This is a possible JSON Schema for that:
|
For information: I have started to work on Part 5 in branch part5-schemas. This is incomplete, but it should be complete in a few days. I will then create a pull request. |
This is feedback from developing a client.
The spec currently states:
A typical case is that the server may require or prohibit the presence of an "id" member/property, depending on the id policy of the server and the operation. Or for update, all properties are optional.
However, the current text does not state, which difference from the schema of the returnables are allowed.
In our work, most APIs include some transformation between the data in the data store and the representation that is returned by the API. A simple example is a link to another feature in the same dataset. In the data store it is typically a foreign key column. In the API response we often include it as a link object with 'href' and 'title' properties. There are many other reasons for such transformations, e.g., that the feature representation should conform to some schema (e.g., INSPIRE) that differs somehow from the storage schema of the data.
The transformations will often not be bijective, so it is not an option to accept data in the returnables schema as payload of a create/replace/update request, because it cannot be mapped unambiguously to the database schema.
As a result, a client also needs to be able to request the feature data in a representation that directly matches the database schema in order to support editing feature attributes for a replace/update operation. Such a request is currently not specified and we had to implement it as a custom extension (we use a query parameter
schema=receivables
in the Feature request).I think what we need to do in the standard is the following:
Add requirements about the differences between the returnables schema and the create/replace/update schemas and restrict those to the resource id and whether a property is required/optional. This supports clients that want to edit a feature so that it can be replaced/updated.
Decide whether we want to support other differences between the returnables schema and the create/replace/update schemas in an additional requirements class or if we consider this out-of-scope for Part 4 and whoever needs this (like us) has to implement their own extension. If added, the requirements class would have to support fetching a feature in the replace/update schema.
The text was updated successfully, but these errors were encountered: