Replies: 2 comments 13 replies
-
Hello @gnidan , For the being time, recursive schemas are not on the roadmap yet because I didn't find a clear way to make that obvious to the end-users. So I am curious about your approch (with examples with pictures as I find it helps understanding) ... Here is one possible idea I have : Thanks to the parsing library used here, unresolved Draft specs about this
Let's focus on Input 1 & Output : Input 2 could come later. What do you think ? |
Beta Was this translation helpful? Give feedback.
-
Just realized that this discussion is still open. There's probably more to discuss here, but in the end the changes that resulted from this (namely the new context stuff in #234) enable me to achieve what I was looking for with only a small bit of ugly hackery. I think we can close this until someone else wants something better :) |
Beta Was this translation helpful? Give feedback.
-
I'm looking to author a Docusaurus site for a collection of several complex JSON Schemas. These schemas are recursive, but also just too big to explain properly in a single collapsible
<JSONSchemaViewer />
. I want to be able to document my schema in parts, with distinct pages or sections that contain individual<JSONSchemaViewer />
s for individual definitions.This plugin already allows specifying a JSON Pointer (which is essential!), but I'd also like to be specify known permalinks for subschemas when creating each
<JSONSchemaViewer />
. I'm imagining something like this:Example interface to tell JSONSchemaViewer about known permalinks
In this example, I'm imagining this plugin to keep track of
"$ref"
s and render a component that hyperlinks to the corresponding page instead of recursively rendering the schema.1Incidentally, this seems to be a viable way to workaround the lack of support for recursive
$ref
s. I've confirmed this already in my initial hacking, but I'm doing it with a wrapper aroundJSONSchemaViewer
that preprocesses my schema object by finding/rewriting all{ $ref: ..., ...others }
objects2. I don't like this approach because there's no way to customize the component rendering for a particular subschema other than specifying a component for alldescription
fields... I want hyperlinked schemas to appear visually obvious, and I believe there's no way to hyperlink at all via preprocessing except via the use of adescription
field with a custom<ReactMarkdown />
componentSince this behavior would dramatically improve the readability of my specification docs, over the next few days I plan to try implementing a proof of concept of this approach in my forked repo. I'd love to get insight from the maintainers here if this sort of use case is worth targeting, and if there's a particular interface or implementation strategy that they'd be most willing to accept. I really want this behavior, and I really don't want to have a lingering fork with this sort of behavior bolted on.
Any advice would be much appreciated 🙏 (and thank you for reading this!)
Footnotes
For now, I'm ignoring the concern about equivalent IDs (like
schema:my-schema#/$defs/...
vs. unprefixed#
), but I imagine this to be solvable or ignorable. ↩My hacky preprocessing strategy now is that I remove
$ref
fields and instead borrow fields from the referenced schema directly. For the hyperlink, I override with a customdescription
that includes the link. ↩Beta Was this translation helpful? Give feedback.
All reactions