feat(json-schema-2020-12): add support for readOnly keyword (#8649)
Refs #8513
This commit is contained in:
@@ -74,6 +74,7 @@ const JSONSchema = forwardRef(
|
|||||||
const KeywordDescription = useComponent("KeywordDescription")
|
const KeywordDescription = useComponent("KeywordDescription")
|
||||||
const KeywordDefault = useComponent("KeywordDefault")
|
const KeywordDefault = useComponent("KeywordDefault")
|
||||||
const KeywordDeprecated = useComponent("KeywordDeprecated")
|
const KeywordDeprecated = useComponent("KeywordDeprecated")
|
||||||
|
const KeywordReadOnly = useComponent("KeywordReadOnly")
|
||||||
const ExpandDeepButton = useComponent("ExpandDeepButton")
|
const ExpandDeepButton = useComponent("ExpandDeepButton")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,6 +135,7 @@ const JSONSchema = forwardRef(
|
|||||||
<KeywordTitle title={name} schema={schema} />
|
<KeywordTitle title={name} schema={schema} />
|
||||||
)}
|
)}
|
||||||
<KeywordDeprecated schema={schema} />
|
<KeywordDeprecated schema={schema} />
|
||||||
|
<KeywordReadOnly schema={schema} />
|
||||||
<KeywordType schema={schema} isCircular={isCircular} />
|
<KeywordType schema={schema} isCircular={isCircular} />
|
||||||
{constraints.length > 0 &&
|
{constraints.length > 0 &&
|
||||||
constraints.map((constraint) => (
|
constraints.map((constraint) => (
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* @prettier
|
||||||
|
*/
|
||||||
|
import React from "react"
|
||||||
|
|
||||||
|
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>
|
||||||
|
}
|
||||||
|
|
||||||
|
ReadOnly.propTypes = {
|
||||||
|
schema: schema.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ReadOnly
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
.json-schema-2020-12 {
|
||||||
|
&__readonly {
|
||||||
|
@extend .json-schema-2020-12__deprecated;
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,3 +75,4 @@
|
|||||||
@import './Constraint/constraint';
|
@import './Constraint/constraint';
|
||||||
@import './DependentRequired/dependent-required';
|
@import './DependentRequired/dependent-required';
|
||||||
@import './Deprecated/deprecated';
|
@import './Deprecated/deprecated';
|
||||||
|
@import './ReadOnly/read-only';
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import KeywordTitle from "./components/keywords/Title/Title"
|
|||||||
import KeywordDescription from "./components/keywords/Description/Description"
|
import KeywordDescription from "./components/keywords/Description/Description"
|
||||||
import KeywordDefault from "./components/keywords/Default"
|
import KeywordDefault from "./components/keywords/Default"
|
||||||
import KeywordDeprecated from "./components/keywords/Deprecated/Deprecated"
|
import KeywordDeprecated from "./components/keywords/Deprecated/Deprecated"
|
||||||
|
import KeywordReadOnly from "./components/keywords/ReadOnly/ReadOnly"
|
||||||
import Accordion from "./components/Accordion/Accordion"
|
import Accordion from "./components/Accordion/Accordion"
|
||||||
import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton"
|
import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton"
|
||||||
import ChevronRightIcon from "./components/icons/ChevronRight"
|
import ChevronRightIcon from "./components/icons/ChevronRight"
|
||||||
@@ -96,6 +97,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
|
|||||||
KeywordDescription,
|
KeywordDescription,
|
||||||
KeywordDefault,
|
KeywordDefault,
|
||||||
KeywordDeprecated,
|
KeywordDeprecated,
|
||||||
|
KeywordReadOnly,
|
||||||
Accordion,
|
Accordion,
|
||||||
ExpandDeepButton,
|
ExpandDeepButton,
|
||||||
ChevronRightIcon,
|
ChevronRightIcon,
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import KeywordTitle from "./components/keywords/Title/Title"
|
|||||||
import KeywordDescription from "./components/keywords/Description/Description"
|
import KeywordDescription from "./components/keywords/Description/Description"
|
||||||
import KeywordDefault from "./components/keywords/Default"
|
import KeywordDefault from "./components/keywords/Default"
|
||||||
import KeywordDeprecated from "./components/keywords/Deprecated/Deprecated"
|
import KeywordDeprecated from "./components/keywords/Deprecated/Deprecated"
|
||||||
|
import KeywordReadOnly from "./components/keywords/ReadOnly/ReadOnly"
|
||||||
import Accordion from "./components/Accordion/Accordion"
|
import Accordion from "./components/Accordion/Accordion"
|
||||||
import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton"
|
import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton"
|
||||||
import ChevronRightIcon from "./components/icons/ChevronRight"
|
import ChevronRightIcon from "./components/icons/ChevronRight"
|
||||||
@@ -83,6 +84,7 @@ const JSONSchema202012Plugin = () => ({
|
|||||||
JSONSchema202012KeywordDescription: KeywordDescription,
|
JSONSchema202012KeywordDescription: KeywordDescription,
|
||||||
JSONSchema202012KeywordDefault: KeywordDefault,
|
JSONSchema202012KeywordDefault: KeywordDefault,
|
||||||
JSONSchema202012KeywordDeprecated: KeywordDeprecated,
|
JSONSchema202012KeywordDeprecated: KeywordDeprecated,
|
||||||
|
JSONSchema202012KeywordReadOnly: KeywordReadOnly,
|
||||||
JSONSchema202012Accordion: Accordion,
|
JSONSchema202012Accordion: Accordion,
|
||||||
JSONSchema202012ExpandDeepButton: ExpandDeepButton,
|
JSONSchema202012ExpandDeepButton: ExpandDeepButton,
|
||||||
JSONSchema202012ChevronRightIcon: ChevronRightIcon,
|
JSONSchema202012ChevronRightIcon: ChevronRightIcon,
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
|||||||
)
|
)
|
||||||
const KeywordDefault = getComponent("JSONSchema202012KeywordDefault")
|
const KeywordDefault = getComponent("JSONSchema202012KeywordDefault")
|
||||||
const KeywordDeprecated = getComponent("JSONSchema202012KeywordDeprecated")
|
const KeywordDeprecated = getComponent("JSONSchema202012KeywordDeprecated")
|
||||||
|
const KeywordReadOnly = getComponent("JSONSchema202012KeywordReadOnly")
|
||||||
const Accordion = getComponent("JSONSchema202012Accordion")
|
const Accordion = getComponent("JSONSchema202012Accordion")
|
||||||
const ExpandDeepButton = getComponent("JSONSchema202012ExpandDeepButton")
|
const ExpandDeepButton = getComponent("JSONSchema202012ExpandDeepButton")
|
||||||
const ChevronRightIcon = getComponent("JSONSchema202012ChevronRightIcon")
|
const ChevronRightIcon = getComponent("JSONSchema202012ChevronRightIcon")
|
||||||
@@ -120,6 +121,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
|||||||
KeywordDescription,
|
KeywordDescription,
|
||||||
KeywordDefault,
|
KeywordDefault,
|
||||||
KeywordDeprecated,
|
KeywordDeprecated,
|
||||||
|
KeywordReadOnly,
|
||||||
Accordion,
|
Accordion,
|
||||||
ExpandDeepButton,
|
ExpandDeepButton,
|
||||||
ChevronRightIcon,
|
ChevronRightIcon,
|
||||||
|
|||||||
Reference in New Issue
Block a user