committed by
Vladimír Gorej
parent
7cfc5e3656
commit
f06c1caed5
@@ -1,6 +1,6 @@
|
|||||||
.json-schema-2020-12-expand-deep-button {
|
.json-schema-2020-12-expand-deep-button {
|
||||||
@include text_headline($section-models-model-title-font-color);
|
@include text_headline($section-models-model-title-font-color);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #6b6b6b;
|
color: rgb(175, 174, 174);
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const JSONSchema = ({ schema, name }) => {
|
|||||||
const BooleanJSONSchema = useComponent("BooleanJSONSchema")
|
const BooleanJSONSchema = useComponent("BooleanJSONSchema")
|
||||||
const Accordion = useComponent("Accordion")
|
const Accordion = useComponent("Accordion")
|
||||||
const KeywordProperties = useComponent("KeywordProperties")
|
const KeywordProperties = useComponent("KeywordProperties")
|
||||||
|
const KeywordType = useComponent("KeywordType")
|
||||||
const ExpandDeepButton = useComponent("ExpandDeepButton")
|
const ExpandDeepButton = useComponent("ExpandDeepButton")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,6 +79,7 @@ const JSONSchema = ({ schema, name }) => {
|
|||||||
expanded={expanded}
|
expanded={expanded}
|
||||||
onClick={handleExpansionDeep}
|
onClick={handleExpansionDeep}
|
||||||
/>
|
/>
|
||||||
|
<KeywordType schema={schema} />
|
||||||
</div>
|
</div>
|
||||||
{expanded && (
|
{expanded && (
|
||||||
<div className="json-schema-2020-12-body">
|
<div className="json-schema-2020-12-body">
|
||||||
|
|||||||
@@ -38,21 +38,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__type {
|
|
||||||
@include text_code();
|
|
||||||
color: $prop-type-font-color;
|
|
||||||
font-size: 12px;
|
|
||||||
text-transform: capitalize;
|
|
||||||
font-weight: bold;
|
|
||||||
|
|
||||||
&:before {
|
|
||||||
content: "{";
|
|
||||||
}
|
|
||||||
&:after {
|
|
||||||
content: "}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__description {
|
&__description {
|
||||||
color: #6b6b6b;
|
color: #6b6b6b;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
@@ -66,6 +51,7 @@
|
|||||||
color: white;
|
color: white;
|
||||||
background-color: #D69E2E;
|
background-color: #D69E2E;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
text-transform: lowercase;
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
content: "format: ";
|
content: "format: ";
|
||||||
|
|||||||
@@ -2,3 +2,4 @@
|
|||||||
@import './JSONSchema/json-schema';
|
@import './JSONSchema/json-schema';
|
||||||
@import './Accordion/accordion';
|
@import './Accordion/accordion';
|
||||||
@import './ExpandDeepButton/expand-deep-button';
|
@import './ExpandDeepButton/expand-deep-button';
|
||||||
|
@import './keywords/Type/type';
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* @prettier
|
||||||
|
*/
|
||||||
|
import React from "react"
|
||||||
|
|
||||||
|
import { schema } from "../../../prop-types"
|
||||||
|
import { useFn } from "../../../hooks"
|
||||||
|
|
||||||
|
const Type = ({ schema }) => {
|
||||||
|
const fn = useFn()
|
||||||
|
|
||||||
|
return <span className="json-schema-2020-12__type">{fn.getType(schema)}</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
Type.propTypes = {
|
||||||
|
schema: schema.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Type
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
.json-schema-2020-12__type {
|
||||||
|
@include text_code();
|
||||||
|
color: $prop-type-font-color;
|
||||||
|
font-size: 12px;
|
||||||
|
text-transform: lowercase;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @prettier
|
* @prettier
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const upperFirst = (value) => {
|
export const upperFirst = (value) => {
|
||||||
if (typeof value === "string") {
|
if (typeof value === "string") {
|
||||||
return `${value.charAt(0).toUpperCase()}${value.slice(1)}`
|
return `${value.charAt(0).toUpperCase()}${value.slice(1)}`
|
||||||
@@ -17,4 +16,16 @@ export const getTitle = (schema) => {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getType = (schema) => {
|
||||||
|
if (Array.isArray(schema.type)) {
|
||||||
|
return schema.type.map(String).join(" | ")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (schema.type != null) {
|
||||||
|
return String(schema.type)
|
||||||
|
}
|
||||||
|
|
||||||
|
return "any"
|
||||||
|
}
|
||||||
|
|
||||||
export const isBooleanJSONSchema = (schema) => typeof schema === "boolean"
|
export const isBooleanJSONSchema = (schema) => typeof schema === "boolean"
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ import React from "react"
|
|||||||
import JSONSchema from "./components/JSONSchema/JSONSchema"
|
import JSONSchema from "./components/JSONSchema/JSONSchema"
|
||||||
import BooleanJSONSchema from "./components/BooleanJSONSchema/BooleanJSONSchema"
|
import BooleanJSONSchema from "./components/BooleanJSONSchema/BooleanJSONSchema"
|
||||||
import KeywordProperties from "./components/keywords/Properties"
|
import KeywordProperties from "./components/keywords/Properties"
|
||||||
|
import KeywordType from "./components/keywords/Type/Type"
|
||||||
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"
|
||||||
import { JSONSchemaContext } from "./context"
|
import { JSONSchemaContext } from "./context"
|
||||||
import { getTitle, isBooleanJSONSchema, upperFirst } from "./fn"
|
import { getTitle, isBooleanJSONSchema, upperFirst, getType } from "./fn"
|
||||||
|
|
||||||
export const withJSONSchemaContext = (Component, overrides = {}) => {
|
export const withJSONSchemaContext = (Component, overrides = {}) => {
|
||||||
const value = {
|
const value = {
|
||||||
@@ -18,6 +19,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
|
|||||||
JSONSchema,
|
JSONSchema,
|
||||||
BooleanJSONSchema,
|
BooleanJSONSchema,
|
||||||
KeywordProperties,
|
KeywordProperties,
|
||||||
|
KeywordType,
|
||||||
Accordion,
|
Accordion,
|
||||||
ExpandDeepButton,
|
ExpandDeepButton,
|
||||||
ChevronRightIcon,
|
ChevronRightIcon,
|
||||||
@@ -30,6 +32,7 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
|
|||||||
fn: {
|
fn: {
|
||||||
upperFirst,
|
upperFirst,
|
||||||
getTitle,
|
getTitle,
|
||||||
|
getType,
|
||||||
isBooleanJSONSchema,
|
isBooleanJSONSchema,
|
||||||
...overrides.fn,
|
...overrides.fn,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
import JSONSchema from "./components/JSONSchema/JSONSchema"
|
import JSONSchema from "./components/JSONSchema/JSONSchema"
|
||||||
import BooleanJSONSchema from "./components/BooleanJSONSchema/BooleanJSONSchema"
|
import BooleanJSONSchema from "./components/BooleanJSONSchema/BooleanJSONSchema"
|
||||||
import JSONSchemaKeywordProperties from "./components/keywords/Properties"
|
import KeywordProperties from "./components/keywords/Properties"
|
||||||
|
import KeywordType from "./components/keywords/Type/Type"
|
||||||
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"
|
||||||
@@ -14,7 +15,8 @@ const JSONSchema202012Plugin = () => ({
|
|||||||
components: {
|
components: {
|
||||||
JSONSchema202012: JSONSchema,
|
JSONSchema202012: JSONSchema,
|
||||||
BooleanJSONSchema202012: BooleanJSONSchema,
|
BooleanJSONSchema202012: BooleanJSONSchema,
|
||||||
JSONSchema202012KeywordProperties: JSONSchemaKeywordProperties,
|
JSONSchema202012KeywordProperties: KeywordProperties,
|
||||||
|
JSONSchema202012KeywordType: KeywordType,
|
||||||
JSONSchema202012Accordion: Accordion,
|
JSONSchema202012Accordion: Accordion,
|
||||||
JSONSchema202012ExpandDeepButton: ExpandDeepButton,
|
JSONSchema202012ExpandDeepButton: ExpandDeepButton,
|
||||||
JSONSchema202012ChevronRightIcon: ChevronRightIcon,
|
JSONSchema202012ChevronRightIcon: ChevronRightIcon,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
|||||||
const JSONSchema = getComponent("JSONSchema202012")
|
const JSONSchema = getComponent("JSONSchema202012")
|
||||||
const BooleanJSONSchema = getComponent("BooleanJSONSchema202012")
|
const BooleanJSONSchema = getComponent("BooleanJSONSchema202012")
|
||||||
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
|
const KeywordProperties = getComponent("JSONSchema202012KeywordProperties")
|
||||||
|
const KeywordType = getComponent("JSONSchema202012KeywordType")
|
||||||
const Accordion = getComponent("JSONSchema202012Accordion")
|
const Accordion = getComponent("JSONSchema202012Accordion")
|
||||||
const ExpandDeepButton = getComponent("JSONSchema202012ExpandDeepButton")
|
const ExpandDeepButton = getComponent("JSONSchema202012ExpandDeepButton")
|
||||||
const ChevronRightIcon = getComponent("JSONSchema202012ChevronRightIcon")
|
const ChevronRightIcon = getComponent("JSONSchema202012ChevronRightIcon")
|
||||||
@@ -23,6 +24,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => {
|
|||||||
JSONSchema,
|
JSONSchema,
|
||||||
BooleanJSONSchema,
|
BooleanJSONSchema,
|
||||||
KeywordProperties,
|
KeywordProperties,
|
||||||
|
KeywordType,
|
||||||
Accordion,
|
Accordion,
|
||||||
ExpandDeepButton,
|
ExpandDeepButton,
|
||||||
ChevronRightIcon,
|
ChevronRightIcon,
|
||||||
|
|||||||
Reference in New Issue
Block a user