Skip to content

Commit

Permalink
feat(json-schema-2020-12): add support for dynamicRef keyword
Browse files Browse the repository at this point in the history
Refs #8513
  • Loading branch information
char0n committed Apr 26, 2023
1 parent 6c5a126 commit 51a7f4e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const JSONSchema = ({ schema, name }) => {
const Keyword$anchor = useComponent("Keyword$anchor")
const Keyword$dynamicAnchor = useComponent("Keyword$dynamicAnchor")
const Keyword$ref = useComponent("Keyword$ref")
const Keyword$dynamicRef = useComponent("Keyword$dynamicRef")
const KeywordProperties = useComponent("KeywordProperties")
const KeywordType = useComponent("KeywordType")
const KeywordFormat = useComponent("KeywordFormat")
Expand Down Expand Up @@ -107,6 +108,7 @@ const JSONSchema = ({ schema, name }) => {
<Keyword$anchor schema={schema} />
<Keyword$dynamicAnchor schema={schema} />
<Keyword$ref schema={schema} />
<Keyword$dynamicRef schema={schema} />
</div>
)}
</article>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @prettier
*/
import React from "react"

import { schema } from "../../prop-types"

const $dynamicRef = ({ schema }) => {
if (!schema?.$dynamicRef) return null

return (
<div className="json-schema-2020-12__$dynamicRef">
<span className="json-schema-2020-12-core-keyword">$dynamicRef</span>
<span className="json-schema-2020-12-core-keyword__value">
{schema.$dynamicRef}
</span>
</div>
)
}

$dynamicRef.propTypes = {
schema: schema.isRequired,
}

export default $dynamicRef
1 change: 1 addition & 0 deletions src/core/plugins/json-schema-2020-12/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const isExpandable = (schema) => {
schema?.$anchor ||
schema?.$dynamicAnchor ||
schema?.$ref ||
schema?.$dynamicRef ||
schema?.description ||
schema?.properties
)
Expand Down
2 changes: 2 additions & 0 deletions src/core/plugins/json-schema-2020-12/hoc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Keyword$id from "./components/keywords/$id"
import Keyword$anchor from "./components/keywords/$anchor"
import Keyword$dynamicAnchor from "./components/keywords/$dynamicAnchor"
import Keyword$ref from "./components/keywords/$ref"
import Keyword$dynamicRef from "./components/keywords/$dynamicRef"
import KeywordProperties from "./components/keywords/Properties"
import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format"
Expand Down Expand Up @@ -37,6 +38,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
Keyword$anchor,
Keyword$dynamicAnchor,
Keyword$ref,
Keyword$dynamicRef,
KeywordProperties,
KeywordType,
KeywordFormat,
Expand Down
2 changes: 2 additions & 0 deletions src/core/plugins/json-schema-2020-12/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Keyword$id from "./components/keywords/$id"
import Keyword$anchor from "./components/keywords/$anchor"
import Keyword$dynamicAnchor from "./components/keywords/$dynamicAnchor"
import Keyword$ref from "./components/keywords/$ref"
import Keyword$dynamicRef from "./components/keywords/$dynamicRef"
import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format"
import KeywordTitle from "./components/keywords/Title/Title"
Expand All @@ -28,6 +29,7 @@ const JSONSchema202012Plugin = () => ({
JSONSchema202012Keyword$anchor: Keyword$anchor,
JSONSchema202012Keyword$dynamicAnchor: Keyword$dynamicAnchor,
JSONSchema202012Keyword$ref: Keyword$ref,
JSONSchema202012Keyword$dynamicRef: Keyword$dynamicRef,
JSONSchema202012KeywordProperties: KeywordProperties,
JSONSchema202012KeywordType: KeywordType,
JSONSchema202012KeywordFormat: KeywordFormat,
Expand Down
2 changes: 2 additions & 0 deletions src/core/plugins/oas31/wrap-components/models.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
"JSONSchema202012Keyword$dynamicAnchor"
)
const Keyword$ref = getComponent("JSONSchema202012Keyword$ref")
const Keyword$dynamicRef = getComponent("JSONSchema202012Keyword$dynamicRef")
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
const KeywordType = getComponent("JSONSchema202012KeywordType")
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
Expand All @@ -42,6 +43,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
Keyword$anchor,
Keyword$dynamicAnchor,
Keyword$ref,
Keyword$dynamicRef,
KeywordProperties,
KeywordType,
KeywordFormat,
Expand Down

0 comments on commit 51a7f4e

Please sign in to comment.