generated from rdilweb/template-docusaurus-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: qualifier message - unsolvedRefs (useful for recursive schemas)
- Loading branch information
Showing
6 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/theme/JSONSchemaViewer/utils/QualifierMessages/UnsolvedRefs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from "react" | ||
|
||
import { JSONSchema } from "json-schema-typed" | ||
import { JSVOptions } from "../../contexts" | ||
import Translate from "@docusaurus/Translate" | ||
|
||
type Props = { | ||
schema: Exclude<JSONSchema, true | false> | ||
options: JSVOptions | ||
nullable?: boolean | ||
} | ||
|
||
export default function UnsolvedRefsQM(props: Props): JSX.Element { | ||
const { | ||
schema, | ||
options: { UnresolvedRefsComponent }, | ||
} = props | ||
|
||
// Translated label | ||
const unsolvedRefLabel = ( | ||
<strong> | ||
<Translate | ||
values={{ | ||
id: "json-schema.labels.unsolvedRefs", | ||
}} | ||
> | ||
{"Unsolved ref :"} | ||
</Translate> | ||
</strong> | ||
) | ||
|
||
// Unsolved ref(s) | ||
// Technically speak, nothing prevents people to combine $ref / $dynamicRef / .. | ||
// So generic approach instead | ||
let unsolvedRefValue: string = [schema.$ref, schema.$dynamicRef] | ||
.filter((s) => s !== undefined) | ||
.join(" ") | ||
|
||
return ( | ||
<div key={"unsolvedRefs"}> | ||
{UnresolvedRefsComponent ? ( | ||
<UnresolvedRefsComponent schema={schema} /> | ||
) : ( | ||
<> | ||
{unsolvedRefLabel} | ||
| ||
{unsolvedRefValue} | ||
</> | ||
)} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters