thema
thema copied to clipboard
Move schemas to the root of the json
I guess it's better to illustrate what this PR does with an example:
before this PR schema is defined under $.components.schemas
{
"openapi": "3.0.0",
"info": {
"title": "team",
"version": "0.0"
},
"paths": {},
"components": {
"schemas": {
"team": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"description": "Name of the team.",
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
}
}
}
This change moves the schema definition to the root of the JSON:
[
{
"team": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"description": "Name of the team.",
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
}
]
From a JSON schema perspective I would expect an object with an $id at the root and $defs for subschemas.
{
"$id": "http://example.com/schemas/0.0/team.json",
"$schema": "http://json-schema.org/draft-04/schema#",
"$defs": {
"memberCount": { "type": "integer" }
},
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"description": "Name of the team.",
"type": "string"
},
"count": {
"$ref": "#/$defs/memberCount"
}
}
}
This is more cleanly explained here: http://json-schema.org/understanding-json-schema/structuring.html
is fixing this a blocker for fully automating our pipelines in grok, at least for grafonnet?