Skip to content

Commit d7b489c

Browse files
authored
feat(json-schema-2020-12): add support for writeOnly keyword (#8650)
Refs #8513
1 parent 964a11a commit d7b489c

File tree

9 files changed

+34
-2
lines changed

9 files changed

+34
-2
lines changed

src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const JSONSchema = forwardRef(
7575
const KeywordDefault = useComponent("KeywordDefault")
7676
const KeywordDeprecated = useComponent("KeywordDeprecated")
7777
const KeywordReadOnly = useComponent("KeywordReadOnly")
78+
const KeywordWriteOnly = useComponent("KeywordWriteOnly")
7879
const ExpandDeepButton = useComponent("ExpandDeepButton")
7980

8081
/**
@@ -136,6 +137,7 @@ const JSONSchema = forwardRef(
136137
)}
137138
<KeywordDeprecated schema={schema} />
138139
<KeywordReadOnly schema={schema} />
140+
<KeywordWriteOnly schema={schema} />
139141
<KeywordType schema={schema} isCircular={isCircular} />
140142
{constraints.length > 0 &&
141143
constraints.map((constraint) => (

src/core/plugins/json-schema-2020-12/components/keywords/ReadOnly/ReadOnly.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { schema } from "../../../prop-types"
88
const ReadOnly = ({ schema }) => {
99
if (schema?.readOnly !== true) return null
1010

11-
return <span className="json-schema-2020-12__readonly">read-only</span>
11+
return <span className="json-schema-2020-12__readOnly">read-only</span>
1212
}
1313

1414
ReadOnly.propTypes = {

src/core/plugins/json-schema-2020-12/components/keywords/ReadOnly/_read-only.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.json-schema-2020-12 {
2-
&__readonly {
2+
&__readOnly {
33
@extend .json-schema-2020-12__deprecated;
44
color: gray;
55
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @prettier
3+
*/
4+
import React from "react"
5+
6+
import { schema } from "../../../prop-types"
7+
8+
const WriteOnly = ({ schema }) => {
9+
if (schema?.writeOnly !== true) return null
10+
11+
return <span className="json-schema-2020-12__writeOnly">write-only</span>
12+
}
13+
14+
WriteOnly.propTypes = {
15+
schema: schema.isRequired,
16+
}
17+
18+
export default WriteOnly
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.json-schema-2020-12 {
2+
&__writeOnly {
3+
@extend .json-schema-2020-12__readOnly;
4+
}
5+
}

src/core/plugins/json-schema-2020-12/components/keywords/_all.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,4 @@
7676
@import './DependentRequired/dependent-required';
7777
@import './Deprecated/deprecated';
7878
@import './ReadOnly/read-only';
79+
@import './WriteOnly/write-only';

src/core/plugins/json-schema-2020-12/hoc.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import KeywordDescription from "./components/keywords/Description/Description"
4141
import KeywordDefault from "./components/keywords/Default"
4242
import KeywordDeprecated from "./components/keywords/Deprecated/Deprecated"
4343
import KeywordReadOnly from "./components/keywords/ReadOnly/ReadOnly"
44+
import KeywordWriteOnly from "./components/keywords/WriteOnly/WriteOnly"
4445
import Accordion from "./components/Accordion/Accordion"
4546
import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton"
4647
import ChevronRightIcon from "./components/icons/ChevronRight"
@@ -98,6 +99,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
9899
KeywordDefault,
99100
KeywordDeprecated,
100101
KeywordReadOnly,
102+
KeywordWriteOnly,
101103
Accordion,
102104
ExpandDeepButton,
103105
ChevronRightIcon,

src/core/plugins/json-schema-2020-12/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import KeywordDescription from "./components/keywords/Description/Description"
3939
import KeywordDefault from "./components/keywords/Default"
4040
import KeywordDeprecated from "./components/keywords/Deprecated/Deprecated"
4141
import KeywordReadOnly from "./components/keywords/ReadOnly/ReadOnly"
42+
import KeywordWriteOnly from "./components/keywords/WriteOnly/WriteOnly"
4243
import Accordion from "./components/Accordion/Accordion"
4344
import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton"
4445
import ChevronRightIcon from "./components/icons/ChevronRight"
@@ -85,6 +86,7 @@ const JSONSchema202012Plugin = () => ({
8586
JSONSchema202012KeywordDefault: KeywordDefault,
8687
JSONSchema202012KeywordDeprecated: KeywordDeprecated,
8788
JSONSchema202012KeywordReadOnly: KeywordReadOnly,
89+
JSONSchema202012KeywordWriteOnly: KeywordWriteOnly,
8890
JSONSchema202012Accordion: Accordion,
8991
JSONSchema202012ExpandDeepButton: ExpandDeepButton,
9092
JSONSchema202012ChevronRightIcon: ChevronRightIcon,

src/core/plugins/oas31/wrap-components/models.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
7373
const KeywordDefault = getComponent("JSONSchema202012KeywordDefault")
7474
const KeywordDeprecated = getComponent("JSONSchema202012KeywordDeprecated")
7575
const KeywordReadOnly = getComponent("JSONSchema202012KeywordReadOnly")
76+
const KeywordWriteOnly = getComponent("JSONSchema202012KeywordWriteOnly")
7677
const Accordion = getComponent("JSONSchema202012Accordion")
7778
const ExpandDeepButton = getComponent("JSONSchema202012ExpandDeepButton")
7879
const ChevronRightIcon = getComponent("JSONSchema202012ChevronRightIcon")
@@ -122,6 +123,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
122123
KeywordDefault,
123124
KeywordDeprecated,
124125
KeywordReadOnly,
126+
KeywordWriteOnly,
125127
Accordion,
126128
ExpandDeepButton,
127129
ChevronRightIcon,

0 commit comments

Comments
 (0)