Geonovum / uml2json

Best Practise for OGC - UML to JSON Encoding Rules
https://geonovum.github.io/uml2json/document.html
0 stars 1 forks source link

By reference encoding plain URI does not specify target #54

Open PalmJanssen opened 3 months ago

PalmJanssen commented 3 months ago

A question or observation from a colleague regarding the by reference encoding by URI.

https://geonovum.github.io/uml2json/document.html#toc64

For a proper usable Json schema, it is necessary that when the UML model has an association from feature type A to feature type B with zero, one or more occurences, that this is also enforced in the schema. In the current specification document, it is only specified that feature type A has an association to a feature type and not that it must explicitly be feature type B.

image

In the following way, it would be good for use in an OpenAPI specification and the links can be navigated with a tool like Swagger.


  "Parcel" : {
      "$anchor" : "Parcel",
      "description" : "begrip: http://catalogus.kadaster.nl/id/begrip/Perceel",
      "type" : "object",
      "properties" : {
        "owner" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/$defs/Person"
          },
          "minItems" : 1,
          "uniqueItems" : true
        }
      },
      "required" : [ "owner" ]
    },
jechterhoff commented 3 months ago

The encoding of an association role depends upon tagged value inlineOrByReference:

if the value is inline then you'll get:

"items": {
   "$ref" : "#/$defs/Person"
}

if the value is byReference you get

"items": {
   "type": "string",
   "format": "uri-reference"
}

if the value is inlineOrByReference then it is an XOR-combination of the two (using keyword oneOf).

See /req/by-reference-basic/inline-or-by-reference-tag for how the value is determined if tag inlineOrByReference is undefined for the association role.

So, it is actually in the hands of the modeling expert on how the encoding looks like in the end. The snippet your colleague was looking at is just an example of the pure byReference-encoding.

PalmJanssen commented 3 months ago

I conclude that there is nothing new, less or more, than the GML (XML) implementation has:

Is there a standardized way of maybe annotating a target type when using 'by reference'?

jechterhoff commented 3 months ago

The only thing that comes to mind is OGC API - Features - Part 5: Schemas, which is in development. There, you have certain members, such as x-ogc-role and x-ogc-collectionId. In the future, that could lead to another requirements class for encoding property values by reference in the Best Practice specification.