Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

json-schema additional metadata

It is possible to add additional or custom metadata (other than title and description) to a json schema property?

Ideally I'd like to add some metadata like so:

//...
"properties": {
  "contactFullName": {
    "$ref": "#/definitions/fullName",
    "custom": "my custom metadata here"
  }
}
//...

Can you add something to definitions to allow that?

like image 578
kreek Avatar asked Feb 21 '17 01:02

kreek


2 Answers

You don't have to do anything special to use additional metadata keywords. You can just use them. In JSON Schema it is not an error to include undefined keywords. Anything that doesn't have JSON Schema semantics should be quietly ignored. So, the following schema is completely valid and should not conflict with any validator implementation.

{
  "title": "Foo",
  "description": "All the foo you can GET",
  "version": "1.0.3",
  "author": "Jason Desrosiers",
  "type": "object",
  "properties": {
    "id": { "type": "string" }
  }
}
like image 174
Jason Desrosiers Avatar answered Sep 29 '22 09:09

Jason Desrosiers


You could use the description property and put a certain structure in there that could then be interpreted and applied as needed (like JSON within a JSON schema, so to speak).

like image 40
rasmeister Avatar answered Sep 29 '22 09:09

rasmeister