Skip to content

Commit

Permalink
feat(json-schema-2020-12): add support for anchor keyword
Browse files Browse the repository at this point in the history
Refs #8513
  • Loading branch information
char0n committed Apr 19, 2023
1 parent 5f51ce0 commit 986f6e0
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const JSONSchema = ({ schema, name }) => {
const Keyword$schema = useComponent("Keyword$schema")
const Keyword$vocabulary = useComponent("Keyword$vocabulary")
const Keyword$id = useComponent("Keyword$id")
const Keyword$anchor = useComponent("Keyword$anchor")
const KeywordProperties = useComponent("KeywordProperties")
const KeywordType = useComponent("KeywordType")
const KeywordFormat = useComponent("KeywordFormat")
Expand Down Expand Up @@ -101,6 +102,7 @@ const JSONSchema = ({ schema, name }) => {
<Keyword$schema schema={schema} />
<Keyword$vocabulary schema={schema} />
<Keyword$id schema={schema} />
<Keyword$anchor schema={schema} />
</div>
)}
</article>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@
//}
}

.json-schema-2020-12-core-keyword + .json-schema-2020-12-core-keyword__value::before {
content: '='
}


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 $anchor = ({ schema }) => {
if (!schema?.$anchor) return null

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

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

export default $anchor
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const $id = ({ schema }) => {
<div className="json-schema-2020-12__$id">
<span className="json-schema-2020-12-core-keyword">$id</span>
<span className="json-schema-2020-12-core-keyword__value">
={schema.$id}
{schema.$id}
</span>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const $schema = ({ schema }) => {
<div className="json-schema-2020-12__$schema">
<span className="json-schema-2020-12-core-keyword">$schema</span>
<span className="json-schema-2020-12-core-keyword__value">
={schema.$schema}
{schema.$schema}
</span>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
border-radius: 4px;
text-transform: lowercase;

&:before {
&::before {
content: "format: ";
}
}
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 @@ -116,6 +116,7 @@ export const isExpandable = (schema) => {
schema?.$schema ||
schema?.$vocabulary ||
schema?.$id ||
schema?.$anchor ||
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 @@ -7,6 +7,7 @@ import JSONSchema from "./components/JSONSchema/JSONSchema"
import Keyword$schema from "./components/keywords/$schema"
import Keyword$vocabulary from "./components/keywords/$vocabulary/$vocabulary"
import Keyword$id from "./components/keywords/$id"
import Keyword$anchor from "./components/keywords/$anchor"
import KeywordProperties from "./components/keywords/Properties"
import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format"
Expand All @@ -31,6 +32,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
Keyword$schema,
Keyword$vocabulary,
Keyword$id,
Keyword$anchor,
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 @@ -6,6 +6,7 @@ import KeywordProperties from "./components/keywords/Properties"
import Keyword$schema from "./components/keywords/$schema"
import Keyword$vocabulary from "./components/keywords/$vocabulary/$vocabulary"
import Keyword$id from "./components/keywords/$id"
import Keyword$anchor from "./components/keywords/$anchor"
import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format"
import KeywordTitle from "./components/keywords/Title/Title"
Expand All @@ -22,6 +23,7 @@ const JSONSchema202012Plugin = () => ({
JSONSchema202012Keyword$schema: Keyword$schema,
JSONSchema202012Keyword$vocabulary: Keyword$vocabulary,
JSONSchema202012Keyword$id: Keyword$id,
JSONSchema202012Keyword$anchor: Keyword$anchor,
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 @@ -12,6 +12,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
const Keyword$schema = getComponent("JSONSchema202012Keyword$schema")
const Keyword$vocabulary = getComponent("JSONSchema202012Keyword$vocabulary")
const Keyword$id = getComponent("JSONSchema202012Keyword$id")
const Keyword$anchor = getComponent("JSONSchema202012Keyword$anchor")
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
const KeywordType = getComponent("JSONSchema202012KeywordType")
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
Expand All @@ -34,6 +35,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
Keyword$schema,
Keyword$vocabulary,
Keyword$id,
Keyword$anchor,
KeywordProperties,
KeywordType,
KeywordFormat,
Expand Down

0 comments on commit 986f6e0

Please sign in to comment.