Skip to content

Model JSON Schema keyword additionalProperties in LinkML #28

@mahdanoura

Description

@mahdanoura

Currently, LinkML does not allow the equivalence of additionalProperties in JSON Schema. This means that the TD instance like the following will fail, because of the additional property "cov:methodName": "GET".

{
    "@context": "https://www.w3.org/2022/wot/td/v1.1",
    "id": "urn:uuid:014139c9-b267-4db5-9c61-cc2d2bfc217d",
    "@type": "Thing",
    "title": "MyCameraThing",
    "$title": "contentMedia and contentEncoding",
    "description": "Thing description for a camera thing",
    "$description": "In some cases, binary data is embedded in text-based values, e.g., a JSON string-based value embeds a base64 encoded image. The terms contentMediaType and contentEncoding can be used to clarify the context and encoding format of such name-value pairs.", 
    "securityDefinitions": {
        "basic_sc": {"scheme": "basic", "in": "header"}
    },
    "security": "basic_sc",
    "properties": {
        "image": { 
	        "description": "Provides latest image", 
	        "type": "string",
	        "contentMediaType": "image/png",
	        "contentEncoding": "base64",
	        "forms": [{ 
			    "op": "readproperty", 
			    "href": "http://camera.example.com/lastPicture", 
			    "cov:methodName": "GET",
			    "contentType": "application/json" 
		    }] 
        }
    }
}

Two ideas come to my mind, either

  1. model an attribute called additionalProperty with a default value of True, and then do some post processing on the generated JSON Schema.
  2. Extend the LinkML json schema generator, but then the question will be how should this modelled?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestjsonschemaLinkML JSON Schema generator bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions