Hack around limitation that prevents $ref: ...
s from having siblings
#81
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For any schema that defines a
$ref
property alongside any other properties, docusaurus-json-schema-plugin currently loses all other properties and treats the schema as just the $ref'd other schema itself. This is because docusaurus-json-schema-plugin uses the now-unmaintained @stoplight/json-ref-resolver, which is stuck on the old JSON Schema drafts 4-7 semantics. (In those older drafts, this behavior was correct.)To work around this issue:
Expand the existing schema preprocessing logic to detect all $ref's with siblings
For each such case, replace the
{ $ref: "...", ...props }
with that $ref moved into an available schema composition keyword. (e.g., it might become{ ...props, allOf: [{ $ref: "..." }] }
).Throw an error if the schema uses all three composition keywords and there's no place for this weird unnecessary composition. (This seems quite unlikely, though)
Override docusaurus-json-schema-plugin's rendering to detect this preprocessed "unnecessary composition" and treat it as a special-case apart from the normal way it presents lists of composed schemas.
When a schema composition is used with only one item, treat it as representing the extension of a base schema, and present it as such.
Present purely annotative extensions with less visual clutter (like, for when a schema is just
{ $ref: "...", description: "..." }