feat(json-schema-2020-12): add support for writeOnly keyword (#8650)
Refs #8513
This commit is contained in:
@@ -75,6 +75,7 @@ const JSONSchema = forwardRef(
|
||||
const KeywordDefault = useComponent("KeywordDefault")
|
||||
const KeywordDeprecated = useComponent("KeywordDeprecated")
|
||||
const KeywordReadOnly = useComponent("KeywordReadOnly")
|
||||
const KeywordWriteOnly = useComponent("KeywordWriteOnly")
|
||||
const ExpandDeepButton = useComponent("ExpandDeepButton")
|
||||
|
||||
/**
|
||||
@@ -136,6 +137,7 @@ const JSONSchema = forwardRef(
|
||||
)}
|
||||
<KeywordDeprecated schema={schema} />
|
||||
<KeywordReadOnly schema={schema} />
|
||||
<KeywordWriteOnly schema={schema} />
|
||||
<KeywordType schema={schema} isCircular={isCircular} />
|
||||
{constraints.length > 0 &&
|
||||
constraints.map((constraint) => (
|
||||
|
||||
@@ -8,7 +8,7 @@ import { schema } from "../../../prop-types"
|
||||
const ReadOnly = ({ schema }) => {
|
||||
if (schema?.readOnly !== true) return null
|
||||
|
||||
return <span className="json-schema-2020-12__readonly">read-only</span>
|
||||
return <span className="json-schema-2020-12__readOnly">read-only</span>
|
||||
}
|
||||
|
||||
ReadOnly.propTypes = {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.json-schema-2020-12 {
|
||||
&__readonly {
|
||||
&__readOnly {
|
||||
@extend .json-schema-2020-12__deprecated;
|
||||
color: gray;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
import React from "react"
|
||||
|
||||
import { schema } from "../../../prop-types"
|
||||
|
||||
const WriteOnly = ({ schema }) => {
|
||||
if (schema?.writeOnly !== true) return null
|
||||
|
||||
return <span className="json-schema-2020-12__writeOnly">write-only</span>
|
||||
}
|
||||
|
||||
WriteOnly.propTypes = {
|
||||
schema: schema.isRequired,
|
||||
}
|
||||
|
||||
export default WriteOnly
|
||||
@@ -0,0 +1,5 @@
|
||||
.json-schema-2020-12 {
|
||||
&__writeOnly {
|
||||
@extend .json-schema-2020-12__readOnly;
|
||||
}
|
||||
}
|
||||
@@ -76,3 +76,4 @@
|
||||
@import './DependentRequired/dependent-required';
|
||||
@import './Deprecated/deprecated';
|
||||
@import './ReadOnly/read-only';
|
||||
@import './WriteOnly/write-only';
|
||||
|
||||
@@ -41,6 +41,7 @@ import KeywordDescription from "./components/keywords/Description/Description"
|
||||
import KeywordDefault from "./components/keywords/Default"
|
||||
import KeywordDeprecated from "./components/keywords/Deprecated/Deprecated"
|
||||
import KeywordReadOnly from "./components/keywords/ReadOnly/ReadOnly"
|
||||
import KeywordWriteOnly from "./components/keywords/WriteOnly/WriteOnly"
|
||||
import Accordion from "./components/Accordion/Accordion"
|
||||
import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton"
|
||||
import ChevronRightIcon from "./components/icons/ChevronRight"
|
||||
@@ -98,6 +99,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
|
||||
KeywordDefault,
|
||||
KeywordDeprecated,
|
||||
KeywordReadOnly,
|
||||
KeywordWriteOnly,
|
||||
Accordion,
|
||||
ExpandDeepButton,
|
||||
ChevronRightIcon,
|
||||
|
||||
@@ -39,6 +39,7 @@ import KeywordDescription from "./components/keywords/Description/Description"
|
||||
import KeywordDefault from "./components/keywords/Default"
|
||||
import KeywordDeprecated from "./components/keywords/Deprecated/Deprecated"
|
||||
import KeywordReadOnly from "./components/keywords/ReadOnly/ReadOnly"
|
||||
import KeywordWriteOnly from "./components/keywords/WriteOnly/WriteOnly"
|
||||
import Accordion from "./components/Accordion/Accordion"
|
||||
import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton"
|
||||
import ChevronRightIcon from "./components/icons/ChevronRight"
|
||||
@@ -85,6 +86,7 @@ const JSONSchema202012Plugin = () => ({
|
||||
JSONSchema202012KeywordDefault: KeywordDefault,
|
||||
JSONSchema202012KeywordDeprecated: KeywordDeprecated,
|
||||
JSONSchema202012KeywordReadOnly: KeywordReadOnly,
|
||||
JSONSchema202012KeywordWriteOnly: KeywordWriteOnly,
|
||||
JSONSchema202012Accordion: Accordion,
|
||||
JSONSchema202012ExpandDeepButton: ExpandDeepButton,
|
||||
JSONSchema202012ChevronRightIcon: ChevronRightIcon,
|
||||
|
||||
@@ -73,6 +73,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
||||
const KeywordDefault = getComponent("JSONSchema202012KeywordDefault")
|
||||
const KeywordDeprecated = getComponent("JSONSchema202012KeywordDeprecated")
|
||||
const KeywordReadOnly = getComponent("JSONSchema202012KeywordReadOnly")
|
||||
const KeywordWriteOnly = getComponent("JSONSchema202012KeywordWriteOnly")
|
||||
const Accordion = getComponent("JSONSchema202012Accordion")
|
||||
const ExpandDeepButton = getComponent("JSONSchema202012ExpandDeepButton")
|
||||
const ChevronRightIcon = getComponent("JSONSchema202012ChevronRightIcon")
|
||||
@@ -122,6 +123,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
||||
KeywordDefault,
|
||||
KeywordDeprecated,
|
||||
KeywordReadOnly,
|
||||
KeywordWriteOnly,
|
||||
Accordion,
|
||||
ExpandDeepButton,
|
||||
ChevronRightIcon,
|
||||
|
||||
Reference in New Issue
Block a user