json-schema-viewer
json-schema-viewer copied to clipboard
External Refs Resolution
Hi, given that external refs are not supported, i've tested out a local setup in which the only change im doing is adjusting the loadUrl
functionality such that it utilises json-refs library. for which all references are resolved.
Old Code
private loadUrl(url: string): void {
fetch(url)
.then(resp => resp.json())
.then(schema => this.setState({ result: { schema, currentUrl: url } }))
.catch(e => this.setState({ result: { currentUrl: url, schema: { message: e.message }}}));
}
New Code
private loadUrl(url: string): void {
jsonRefs.resolveRefsAt(url).then((result) =>
this.setState({ result: { schema: result.resolved as JsonSchema, currentUrl: url } })
).catch(e => this.setState({ result: { currentUrl: url, schema: { message: e.message }}}));
}
would such a PR be accepted?
maybe utilising a toggle in the homepage wether refs should be resolved or not, would switch between the two ?
Hmm, the idea of this App, for performance reasons, was never to have to load external schemas once your schema was successfully downloaded: you either got everything or nothing.
Is it possible to bundle your external schema fully before providing it to this tool?
However, that said, can you paste a screenshot of what the error state looks like in the event that a sub-referenced schema fails to load?
regs resolution would be very useful. most schemas in the Spatio Temporal Asset Catalog ecosystem use refs
this fails https://raw.githubusercontent.com/crim-ca/mlm-extension/main/json-schema/schema.json