Skip to content

Commit

Permalink
feat(json-schema-2020-12): add support for format keyword
Browse files Browse the repository at this point in the history
Refs #8513
  • Loading branch information
char0n committed Apr 26, 2023
1 parent f06c1ca commit c4ec33b
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const JSONSchema = ({ schema, name }) => {
const Accordion = useComponent("Accordion")
const KeywordProperties = useComponent("KeywordProperties")
const KeywordType = useComponent("KeywordType")
const KeywordFormat = useComponent("KeywordFormat")
const ExpandDeepButton = useComponent("ExpandDeepButton")

/**
Expand Down Expand Up @@ -80,6 +81,7 @@ const JSONSchema = ({ schema, name }) => {
onClick={handleExpansionDeep}
/>
<KeywordType schema={schema} />
<KeywordFormat schema={schema} />
</div>
{expanded && (
<div className="json-schema-2020-12-body">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,6 @@
font-size: 12px;
}

&__format {
@include text_code();
margin-left: 10px;
line-height: 1.5;
padding: 1px;
color: white;
background-color: #D69E2E;
border-radius: 4px;
text-transform: lowercase;

&:before {
content: "format: ";
}
}

&__limit {
@include text_code();
margin-left: 10px;
Expand Down
1 change: 1 addition & 0 deletions src/core/plugins/json-schema-2020-12/components/_all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
@import './Accordion/accordion';
@import './ExpandDeepButton/expand-deep-button';
@import './keywords/Type/type';
@import './keywords/Format/format';
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @prettier
*/
import React from "react"

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

const Format = ({ schema }) => {
if (!schema.format) return null

return <span className="json-schema-2020-12__format">{schema.format}</span>
}

Format.propTypes = {
schema: schema.isRequired,
}

export default Format
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.json-schema-2020-12__format {
@include text_code();
margin-left: 10px;
line-height: 1.5;
padding: 1px;
color: white;
background-color: #D69E2E;
border-radius: 4px;
text-transform: lowercase;

&:before {
content: "format: ";
}
}
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 BooleanJSONSchema from "./components/BooleanJSONSchema/BooleanJSONSchema"
import KeywordProperties from "./components/keywords/Properties"
import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format"
import Accordion from "./components/Accordion/Accordion"
import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton"
import ChevronRightIcon from "./components/icons/ChevronRight"
Expand All @@ -20,6 +21,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
BooleanJSONSchema,
KeywordProperties,
KeywordType,
KeywordFormat,
Accordion,
ExpandDeepButton,
ChevronRightIcon,
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 @@ -5,6 +5,7 @@ import JSONSchema from "./components/JSONSchema/JSONSchema"
import BooleanJSONSchema from "./components/BooleanJSONSchema/BooleanJSONSchema"
import KeywordProperties from "./components/keywords/Properties"
import KeywordType from "./components/keywords/Type/Type"
import KeywordFormat from "./components/keywords/Format/Format"
import Accordion from "./components/Accordion/Accordion"
import ExpandDeepButton from "./components/ExpandDeepButton/ExpandDeepButton"
import ChevronRightIcon from "./components/icons/ChevronRight"
Expand All @@ -17,6 +18,7 @@ const JSONSchema202012Plugin = () => ({
BooleanJSONSchema202012: BooleanJSONSchema,
JSONSchema202012KeywordProperties: KeywordProperties,
JSONSchema202012KeywordType: KeywordType,
JSONSchema202012KeywordFormat: KeywordFormat,
JSONSchema202012Accordion: Accordion,
JSONSchema202012ExpandDeepButton: ExpandDeepButton,
JSONSchema202012ChevronRightIcon: ChevronRightIcon,
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 BooleanJSONSchema = getComponent("BooleanJSONSchema202012")
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
const KeywordType = getComponent("JSONSchema202012KeywordType")
const KeywordFormat = getComponent("JSONSchema202012KeywordFormat")
const Accordion = getComponent("JSONSchema202012Accordion")
const ExpandDeepButton = getComponent("JSONSchema202012ExpandDeepButton")
const ChevronRightIcon = getComponent("JSONSchema202012ChevronRightIcon")
Expand All @@ -25,6 +26,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
BooleanJSONSchema,
KeywordProperties,
KeywordType,
KeywordFormat,
Accordion,
ExpandDeepButton,
ChevronRightIcon,
Expand Down

0 comments on commit c4ec33b

Please sign in to comment.