I want to generate some documentation/description (probably some input forms) from a json schema that contains $refs. Is there a way in jsonschema to retrieve a json schema with $refs resolved and inlined, so I can iterate through the schema?
So from a schema like this:
{
"definitions": {
"some_object": {
"type": "object",
"title": "My definition",
"description": "Some description",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "number"
}
}
}
},
"properties": {
"list_of_objects": {
"type": "array",
"title": "Some stuff",
"description": "List of stuff",
"items": {"$ref": "#/definitions/some_object"}
}
}
}
I want to have this structure in my Python object (notice that the {$ref:...} section is replaced by the actual definition):
{
"definitions": {
"some_object": {
"type": "object",
"title": "My definition",
"description": "Some description",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "number"
}
}
}
},
"properties": {
"list_of_objects": {
"type": "array",
"title": "Some stuff",
"description": "List of stuff",
"items": {
"type": "object",
"title": "My definition",
"description": "Some description",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "number"
}
}
}
}
}
}
I am aware that with self-referencing schemas this will lead to an infinite structure, but hopefully this is feasible with reasonable limitations (eg. excluding self-refs).
I want to generate some documentation/description (probably some input forms) from a json schema that contains
$refs. Is there a way in jsonschema to retrieve a json schema with$refs resolved and inlined, so I can iterate through the schema?So from a schema like this:
{ "definitions": { "some_object": { "type": "object", "title": "My definition", "description": "Some description", "properties": { "name": { "type": "string" }, "value": { "type": "number" } } } }, "properties": { "list_of_objects": { "type": "array", "title": "Some stuff", "description": "List of stuff", "items": {"$ref": "#/definitions/some_object"} } } }I want to have this structure in my Python object (notice that the
{$ref:...}section is replaced by the actual definition):{ "definitions": { "some_object": { "type": "object", "title": "My definition", "description": "Some description", "properties": { "name": { "type": "string" }, "value": { "type": "number" } } } }, "properties": { "list_of_objects": { "type": "array", "title": "Some stuff", "description": "List of stuff", "items": { "type": "object", "title": "My definition", "description": "Some description", "properties": { "name": { "type": "string" }, "value": { "type": "number" } } } } } }I am aware that with self-referencing schemas this will lead to an infinite structure, but hopefully this is feasible with reasonable limitations (eg. excluding self-refs).