Closed as duplicate of#27
Closed as duplicate of#27
Description
Hi there, I'm trying to create a fully inlined JSON Schema where all references are resolved and included in a single document.
Example Schema
example-schema.json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://example.com/schemas/example-schema",
"type": "object",
"properties": {
"user": {
"$ref": "https://example.com/schemas/user-schema"
}
}
}
Let's take this schema as an example
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://example.com/schemas/user-schema",
"type": "object",
"properties": {
"profile": {
"$ref": "https://example.com/schemas/profile"
}
}
}
This subschema is referenced by
example-schema.json
, and can have N* subschemas itself.
What I'm Trying to Achieve
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/schemas/example-schema",
"type": "object",
"properties": {
"user": {
"$ref": "#/$defs/user"
}
},
"$defs": {
"user": {
"type": "object",
"properties": {
"profile": {
"$ref": "#/$defs/profile"
}
},
"required": ["profile"]
},
"profile": {
"type": "object",
"properties": {
"address": {
"$ref": "#/$defs/address"
}
},
"required": ["address"]
},
"address": {
"type": "object",
"properties": {
"street": { "type": "string" },
"city": { "type": "string" }
},
"required": ["street", "city"]
},
# N* subschemas
}
}
- All external schema references should be collected and placed in the appropriate definitions section (
definitions
or$defs
based on draft version) - References should be updated to point to the definitions section
- The process should work for N-level deep schemas
- The schema's draft version should be preserved
- The solution should be draft-agnostic, automatically using the correct keyword based on the schema's draft version
Questions
- Is there a built-in way to achieve this using the referencing package that I'm missing?
- If not, would this functionality be useful to add to the package?
I've looked through the documentation but might have missed something obvious. Any help would be appreciated!
Metadata
Metadata
Assignees
Labels
No labels