json-schema-for-humans icon indicating copy to clipboard operation
json-schema-for-humans copied to clipboard

`$ref` support, with relative paths for `$id`.

Open danywu opened this issue 3 years ago • 2 comments

I have a bunch of schemas that use relative paths for $ids, e.g. /components/0.1/crs, being referenced in /elements/0.1/points, and so on. There's a folder structure that reflects those paths in the $ids. These schemas will be "deployed" to various environments, e.g. dev, staging, etc. I would like to keep the $ids relative for flexibility.

In the documentation, I could not find a way of specifying the base URI for all the schemas in the "top level". Is this something that is supported, or planned to be?

danywu avatar Aug 28 '22 21:08 danywu

@danywu are you already using this feature for validation, e.g. are you already using a validator where you can set the base URI externally and you would like to re-use the same schema files both for validation and for documentation generation?

If not, then the only way would be to set it statically in the $id of the top-level schema to something universal that would be present in all envs (for example, /var/tmp/something). This should make any JSON schema software happy, including this tool.

pspot2 avatar Oct 27 '22 23:10 pspot2

@danywu are you already using this feature for validation, e.g. are you already using a validator where you can set the base URI externally and you would like to re-use the same schema files both for validation and for documentation generation?

Yes, we are using this for validation already, by setting the base URI.

If not, then the only way would be to set it statically in the $id of the top-level schema to something universal that would be present in all envs (for example, /var/tmp/something). This should make any JSON schema software happy, including this tool.

Our schemas will be served through CDN, so the path will depend on the environments, e.g. ourschemas.com, dev.ourschemas.com, etc.

danywu avatar Jan 08 '23 19:01 danywu