From e764efd921a669ae90d4d63f0bd1fe55a61715c6 Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Tue, 16 May 2023 10:31:10 +0200 Subject: [PATCH 1/2] feat(oas31): render JSON Schema 2020-12 in Operations and Webhooks Refs #8513 --- .../components/JSONSchema/JSONSchema.jsx | 6 +- .../components/keywords/Title/Title.jsx | 3 + .../components/keywords/Title/_title.scss | 2 + src/core/plugins/json-schema-2020-12/hooks.js | 9 +- src/core/plugins/oas31/components/_all.scss | 2 + .../oas31/components/model/_model.scss | 19 +++ .../plugins/oas31/components/model/model.jsx | 73 +++++++++ .../oas31/components/models/_models.scss | 3 + .../oas31/components/{ => models}/models.jsx | 0 src/core/plugins/oas31/index.js | 10 +- .../plugins/oas31/wrap-components/model.jsx | 150 ++++++++++++++++++ .../plugins/oas31/wrap-components/models.jsx | 1 + .../oas31/wrap-components/operations.jsx | 147 ----------------- .../oas31/wrap-components/webhooks.jsx | 141 ---------------- src/style/main.scss | 1 + 15 files changed, 270 insertions(+), 297 deletions(-) create mode 100644 src/core/plugins/oas31/components/_all.scss create mode 100644 src/core/plugins/oas31/components/model/_model.scss create mode 100644 src/core/plugins/oas31/components/model/model.jsx create mode 100644 src/core/plugins/oas31/components/models/_models.scss rename src/core/plugins/oas31/components/{ => models}/models.jsx (100%) create mode 100644 src/core/plugins/oas31/wrap-components/model.jsx delete mode 100644 src/core/plugins/oas31/wrap-components/operations.jsx delete mode 100644 src/core/plugins/oas31/wrap-components/webhooks.jsx diff --git a/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx b/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx index 40883087a04..b879ab44ea9 100644 --- a/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx +++ b/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx @@ -11,6 +11,7 @@ import { useLevel, useFn, useIsEmbedded, + useIsExpanded, useIsExpandedDeeply, useIsCircular, useRenderedSchemas, @@ -24,8 +25,9 @@ import { const JSONSchema = forwardRef( ({ schema, name, dependentRequired, onExpand }, ref) => { const fn = useFn() + const isExpanded = useIsExpanded() const isExpandedDeeply = useIsExpandedDeeply() - const [expanded, setExpanded] = useState(isExpandedDeeply) + const [expanded, setExpanded] = useState(isExpanded || isExpandedDeeply) const [expandedDeeply, setExpandedDeeply] = useState(isExpandedDeeply) const [level, nextLevel] = useLevel() const isEmbedded = useIsEmbedded() @@ -78,6 +80,8 @@ const JSONSchema = forwardRef( const KeywordWriteOnly = useComponent("KeywordWriteOnly") const ExpandDeepButton = useComponent("ExpandDeepButton") + console.dir(expandedDeeply) + /** * Effects handlers. */ diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Title/Title.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/Title/Title.jsx index 2e94c38ef85..675185b936c 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Title/Title.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Title/Title.jsx @@ -9,6 +9,9 @@ import { useFn } from "../../../hooks" const Title = ({ title, schema }) => { const fn = useFn() + const renderedTitle = title || fn.getTitle(schema) + + if (!renderedTitle) return null return (
diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Title/_title.scss b/src/core/plugins/json-schema-2020-12/components/keywords/Title/_title.scss index 45f1cb981c4..760d2650b03 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Title/_title.scss +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Title/_title.scss @@ -3,6 +3,8 @@ @include text_headline($section-models-model-title-font-color); display: inline-block; font-weight: bold; + font-size: 12px; + line-height: normal; & .json-schema-2020-12-keyword__name { margin: 0; diff --git a/src/core/plugins/json-schema-2020-12/hooks.js b/src/core/plugins/json-schema-2020-12/hooks.js index 2afd91eb8a6..18f129e7c2c 100644 --- a/src/core/plugins/json-schema-2020-12/hooks.js +++ b/src/core/plugins/json-schema-2020-12/hooks.js @@ -38,12 +38,15 @@ export const useIsEmbedded = () => { return level > 0 } -export const useIsExpandedDeeply = () => { +export const useIsExpanded = () => { const [level] = useLevel() const { defaultExpandedLevels } = useConfig() - const isExpandedByDefault = defaultExpandedLevels - level > 0 - return isExpandedByDefault || useContext(JSONSchemaDeepExpansionContext) + return defaultExpandedLevels - level > 0 +} + +export const useIsExpandedDeeply = () => { + return useContext(JSONSchemaDeepExpansionContext) } export const useRenderedSchemas = (schema = undefined) => { diff --git a/src/core/plugins/oas31/components/_all.scss b/src/core/plugins/oas31/components/_all.scss new file mode 100644 index 00000000000..672097d7cc4 --- /dev/null +++ b/src/core/plugins/oas31/components/_all.scss @@ -0,0 +1,2 @@ +@import './model/model'; +@import './models/models'; diff --git a/src/core/plugins/oas31/components/model/_model.scss b/src/core/plugins/oas31/components/model/_model.scss new file mode 100644 index 00000000000..0a952a3d861 --- /dev/null +++ b/src/core/plugins/oas31/components/model/_model.scss @@ -0,0 +1,19 @@ +.model-box { + // inferred names of Schema Objects + & .json-schema-2020-12:not(.json-schema-2020-12--embedded) > .json-schema-2020-12-head .json-schema-2020-12__title:first-of-type { + font-size: 16px; + } + + & > .json-schema-2020-12 { + margin: 0; + } + + .json-schema-2020-12 { + padding: 0; + background-color: transparent; + } + + .json-schema-2020-12-accordion, .json-schema-2020-12-expand-deep-button { + background-color: transparent; + } +} diff --git a/src/core/plugins/oas31/components/model/model.jsx b/src/core/plugins/oas31/components/model/model.jsx new file mode 100644 index 00000000000..72e456b6245 --- /dev/null +++ b/src/core/plugins/oas31/components/model/model.jsx @@ -0,0 +1,73 @@ +/** + * @prettier + */ +import React, { forwardRef, useCallback } from "react" +import PropTypes from "prop-types" +import ImPropTypes from "react-immutable-proptypes" + +const decodeRefName = (uri) => { + const unescaped = uri.replace(/~1/g, "/").replace(/~0/g, "~") + try { + return decodeURIComponent(unescaped) + } catch { + return unescaped + } +} +const getModelName = (uri) => { + if (typeof uri === "string" && uri.includes("#/components/schemas/")) { + return decodeRefName(uri.replace(/^.*#\/components\/schemas\//, "")) + } + return null +} + +const Model = forwardRef(({ schema, getComponent, onToggle }, ref) => { + const JSONSchema202012 = getComponent("JSONSchema202012") + const name = getModelName(schema.get("$$ref")) + + const handleExpand = useCallback( + (e, expanded) => { + onToggle(name, expanded) + }, + [name, onToggle] + ) + + return ( + + ) +}) + +Model.propTypes = { + schema: ImPropTypes.map.isRequired, + getComponent: PropTypes.func.isRequired, + getConfigs: PropTypes.func.isRequired, + specSelectors: PropTypes.object.isRequired, + specPath: ImPropTypes.list.isRequired, + name: PropTypes.string, + displayName: PropTypes.string, + isRef: PropTypes.bool, + required: PropTypes.bool, + expandDepth: PropTypes.number, + depth: PropTypes.number, + includeReadOnly: PropTypes.bool, + includeWriteOnly: PropTypes.bool, + onToggle: PropTypes.func, +} + +Model.defaultProps = { + name: "", + displayName: "", + isRef: false, + required: false, + expandDepth: 0, + depth: 1, + includeReadOnly: false, + includeWriteOnly: false, + onToggle: () => {}, +} + +export default Model diff --git a/src/core/plugins/oas31/components/models/_models.scss b/src/core/plugins/oas31/components/models/_models.scss new file mode 100644 index 00000000000..2b582eb15a6 --- /dev/null +++ b/src/core/plugins/oas31/components/models/_models.scss @@ -0,0 +1,3 @@ +.models .json-schema-2020-12:not(.json-schema-2020-12--embedded) > .json-schema-2020-12-head .json-schema-2020-12__title:first-of-type { + font-size: 16px; +} diff --git a/src/core/plugins/oas31/components/models.jsx b/src/core/plugins/oas31/components/models/models.jsx similarity index 100% rename from src/core/plugins/oas31/components/models.jsx rename to src/core/plugins/oas31/components/models/models.jsx diff --git a/src/core/plugins/oas31/index.js b/src/core/plugins/oas31/index.js index 3a25dfab591..b3e18b651e9 100644 --- a/src/core/plugins/oas31/index.js +++ b/src/core/plugins/oas31/index.js @@ -7,13 +7,13 @@ import Contact from "./components/contact" import Info from "./components/info" import JsonSchemaDialect from "./components/json-schema-dialect" import VersionPragmaFilter from "./components/version-pragma-filter" -import Models from "./components/models" +import Model from "./components/model/model" +import Models from "./components/models/models" import LicenseWrapper from "./wrap-components/license" import ContactWrapper from "./wrap-components/contact" import InfoWrapper from "./wrap-components/info" +import ModelWrapper from "./wrap-components/model" import ModelsWrapper from "./wrap-components/models" -import OperationsWrapper from "./wrap-components/operations" -import WebhooksWrapper from "./wrap-components/webhooks" import VersionPragmaFilterWrapper from "./wrap-components/version-pragma-filter" import VersionStampWrapper from "./wrap-components/version-stamp" import { @@ -87,6 +87,7 @@ const OAS31Plugin = ({ getSystem }) => { OAS31License: License, OAS31Contact: Contact, OAS31VersionPragmaFilter: VersionPragmaFilter, + OAS31Model: Model, OAS31Models: Models, JSONSchema202012KeywordExample, JSONSchema202012KeywordXml, @@ -99,9 +100,8 @@ const OAS31Plugin = ({ getSystem }) => { Contact: ContactWrapper, VersionPragmaFilter: VersionPragmaFilterWrapper, VersionStamp: VersionStampWrapper, + Model: ModelWrapper, Models: ModelsWrapper, - Operations: OperationsWrapper, - Webhooks: WebhooksWrapper, JSONSchema202012KeywordDescription: JSONSchema202012KeywordDescriptionWrapper, JSONSchema202012KeywordDefault: JSONSchema202012KeywordDefaultWrapper, diff --git a/src/core/plugins/oas31/wrap-components/model.jsx b/src/core/plugins/oas31/wrap-components/model.jsx new file mode 100644 index 00000000000..c720bd1fe75 --- /dev/null +++ b/src/core/plugins/oas31/wrap-components/model.jsx @@ -0,0 +1,150 @@ +/** + * @prettier + */ +import React from "react" + +import { createOnlyOAS31ComponentWrapper } from "../fn" +import { makeIsExpandable } from "../json-schema-2020-12-extensions/fn" + +const ModelWrapper = createOnlyOAS31ComponentWrapper( + ({ getSystem, ...props }) => { + const system = getSystem() + const { getComponent, fn, getConfigs } = system + const configs = getConfigs() + + const Model = getComponent("OAS31Model") + const JSONSchema = getComponent("JSONSchema202012") + const Keyword$schema = getComponent("JSONSchema202012Keyword$schema") + const Keyword$vocabulary = getComponent( + "JSONSchema202012Keyword$vocabulary" + ) + const Keyword$id = getComponent("JSONSchema202012Keyword$id") + const Keyword$anchor = getComponent("JSONSchema202012Keyword$anchor") + const Keyword$dynamicAnchor = getComponent( + "JSONSchema202012Keyword$dynamicAnchor" + ) + const Keyword$ref = getComponent("JSONSchema202012Keyword$ref") + const Keyword$dynamicRef = getComponent( + "JSONSchema202012Keyword$dynamicRef" + ) + const Keyword$defs = getComponent("JSONSchema202012Keyword$defs") + const Keyword$comment = getComponent("JSONSchema202012Keyword$comment") + const KeywordAllOf = getComponent("JSONSchema202012KeywordAllOf") + const KeywordAnyOf = getComponent("JSONSchema202012KeywordAnyOf") + const KeywordOneOf = getComponent("JSONSchema202012KeywordOneOf") + const KeywordNot = getComponent("JSONSchema202012KeywordNot") + const KeywordIf = getComponent("JSONSchema202012KeywordIf") + const KeywordThen = getComponent("JSONSchema202012KeywordThen") + const KeywordElse = getComponent("JSONSchema202012KeywordElse") + const KeywordDependentSchemas = getComponent( + "JSONSchema202012KeywordDependentSchemas" + ) + const KeywordPrefixItems = getComponent( + "JSONSchema202012KeywordPrefixItems" + ) + const KeywordItems = getComponent("JSONSchema202012KeywordItems") + const KeywordContains = getComponent("JSONSchema202012KeywordContains") + const KeywordProperties = getComponent("JSONSchema202012KeywordProperties") + const KeywordPatternProperties = getComponent( + "JSONSchema202012KeywordPatternProperties" + ) + const KeywordAdditionalProperties = getComponent( + "JSONSchema202012KeywordAdditionalProperties" + ) + const KeywordPropertyNames = getComponent( + "JSONSchema202012KeywordPropertyNames" + ) + const KeywordUnevaluatedItems = getComponent( + "JSONSchema202012KeywordUnevaluatedItems" + ) + const KeywordUnevaluatedProperties = getComponent( + "JSONSchema202012KeywordUnevaluatedProperties" + ) + const KeywordType = getComponent("JSONSchema202012KeywordType") + const KeywordEnum = getComponent("JSONSchema202012KeywordEnum") + const KeywordConst = getComponent("JSONSchema202012KeywordConst") + const KeywordConstraint = getComponent("JSONSchema202012KeywordConstraint") + const KeywordDependentRequired = getComponent( + "JSONSchema202012KeywordDependentRequired" + ) + const KeywordContentSchema = getComponent( + "JSONSchema202012KeywordContentSchema" + ) + const KeywordTitle = getComponent("JSONSchema202012KeywordTitle") + const KeywordDescription = getComponent( + "JSONSchema202012KeywordDescription" + ) + 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") + const withSchemaContext = getComponent("withJSONSchema202012Context") + + const ModelWithJSONSchemaContext = withSchemaContext(Model, { + config: { + default$schema: "https://spec.openapis.org/oas/3.1/dialect/base", + defaultExpandedLevels: configs.defaultModelExpandDepth, + includeReadOnly: Boolean(props.includeReadOnly), + includeWriteOnly: Boolean(props.includeWriteOnly), + }, + components: { + JSONSchema, + Keyword$schema, + Keyword$vocabulary, + Keyword$id, + Keyword$anchor, + Keyword$dynamicAnchor, + Keyword$ref, + Keyword$dynamicRef, + Keyword$defs, + Keyword$comment, + KeywordAllOf, + KeywordAnyOf, + KeywordOneOf, + KeywordNot, + KeywordIf, + KeywordThen, + KeywordElse, + KeywordDependentSchemas, + KeywordPrefixItems, + KeywordItems, + KeywordContains, + KeywordProperties, + KeywordPatternProperties, + KeywordAdditionalProperties, + KeywordPropertyNames, + KeywordUnevaluatedItems, + KeywordUnevaluatedProperties, + KeywordType, + KeywordEnum, + KeywordConst, + KeywordConstraint, + KeywordDependentRequired, + KeywordContentSchema, + KeywordTitle, + KeywordDescription, + KeywordDefault, + KeywordDeprecated, + KeywordReadOnly, + KeywordWriteOnly, + Accordion, + ExpandDeepButton, + ChevronRightIcon, + }, + fn: { + upperFirst: fn.upperFirst, + isExpandable: makeIsExpandable( + fn.jsonSchema202012.isExpandable, + system + ), + }, + }) + + return + } +) + +export default ModelWrapper diff --git a/src/core/plugins/oas31/wrap-components/models.jsx b/src/core/plugins/oas31/wrap-components/models.jsx index c5b939c03b2..7d94721993f 100644 --- a/src/core/plugins/oas31/wrap-components/models.jsx +++ b/src/core/plugins/oas31/wrap-components/models.jsx @@ -78,6 +78,7 @@ const ModelsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => { const ChevronRightIcon = getComponent("JSONSchema202012ChevronRightIcon") const withSchemaContext = getComponent("withJSONSchema202012Context") + // we cache the HOC as recreating it with every re-render is quite expensive ModelsWrapper.ModelsWithJSONSchemaContext = withSchemaContext(Models, { config: { default$schema: "https://spec.openapis.org/oas/3.1/dialect/base", diff --git a/src/core/plugins/oas31/wrap-components/operations.jsx b/src/core/plugins/oas31/wrap-components/operations.jsx deleted file mode 100644 index 5708a0567ba..00000000000 --- a/src/core/plugins/oas31/wrap-components/operations.jsx +++ /dev/null @@ -1,147 +0,0 @@ -/** - * @prettier - */ -import React from "react" - -import { createOnlyOAS31ComponentWrapper } from "../fn" -import { makeIsExpandable } from "../json-schema-2020-12-extensions/fn" - -const OperationsWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => { - const system = getSystem() - const { getComponent, fn, getConfigs } = system - const configs = getConfigs() - - if (OperationsWrapper.OperationsWithJSONSchemaContext) { - return - } - - const Operations = getComponent("operations", true) - const JSONSchema = getComponent("JSONSchema202012") - const Keyword$schema = getComponent("JSONSchema202012Keyword$schema") - const Keyword$vocabulary = getComponent("JSONSchema202012Keyword$vocabulary") - const Keyword$id = getComponent("JSONSchema202012Keyword$id") - const Keyword$anchor = getComponent("JSONSchema202012Keyword$anchor") - const Keyword$dynamicAnchor = getComponent( - "JSONSchema202012Keyword$dynamicAnchor" - ) - const Keyword$ref = getComponent("JSONSchema202012Keyword$ref") - const Keyword$dynamicRef = getComponent("JSONSchema202012Keyword$dynamicRef") - const Keyword$defs = getComponent("JSONSchema202012Keyword$defs") - const Keyword$comment = getComponent("JSONSchema202012Keyword$comment") - const KeywordAllOf = getComponent("JSONSchema202012KeywordAllOf") - const KeywordAnyOf = getComponent("JSONSchema202012KeywordAnyOf") - const KeywordOneOf = getComponent("JSONSchema202012KeywordOneOf") - const KeywordNot = getComponent("JSONSchema202012KeywordNot") - const KeywordIf = getComponent("JSONSchema202012KeywordIf") - const KeywordThen = getComponent("JSONSchema202012KeywordThen") - const KeywordElse = getComponent("JSONSchema202012KeywordElse") - const KeywordDependentSchemas = getComponent( - "JSONSchema202012KeywordDependentSchemas" - ) - const KeywordPrefixItems = getComponent("JSONSchema202012KeywordPrefixItems") - const KeywordItems = getComponent("JSONSchema202012KeywordItems") - const KeywordContains = getComponent("JSONSchema202012KeywordContains") - const KeywordProperties = getComponent("JSONSchema202012KeywordProperties") - const KeywordPatternProperties = getComponent( - "JSONSchema202012KeywordPatternProperties" - ) - const KeywordAdditionalProperties = getComponent( - "JSONSchema202012KeywordAdditionalProperties" - ) - const KeywordPropertyNames = getComponent( - "JSONSchema202012KeywordPropertyNames" - ) - const KeywordUnevaluatedItems = getComponent( - "JSONSchema202012KeywordUnevaluatedItems" - ) - const KeywordUnevaluatedProperties = getComponent( - "JSONSchema202012KeywordUnevaluatedProperties" - ) - const KeywordType = getComponent("JSONSchema202012KeywordType") - const KeywordEnum = getComponent("JSONSchema202012KeywordEnum") - const KeywordConst = getComponent("JSONSchema202012KeywordConst") - const KeywordConstraint = getComponent("JSONSchema202012KeywordConstraint") - const KeywordDependentRequired = getComponent( - "JSONSchema202012KeywordDependentRequired" - ) - const KeywordContentSchema = getComponent( - "JSONSchema202012KeywordContentSchema" - ) - const KeywordTitle = getComponent("JSONSchema202012KeywordTitle") - const KeywordDescription = getComponent("JSONSchema202012KeywordDescription") - 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") - const withSchemaContext = getComponent("withJSONSchema202012Context") - - OperationsWrapper.OperationsWithJSONSchemaContext = withSchemaContext( - Operations, - { - config: { - default$schema: "https://spec.openapis.org/oas/3.1/dialect/base", - defaultExpandedLevels: configs.defaultModelExpandDepth - 1, - }, - components: { - JSONSchema, - Keyword$schema, - Keyword$vocabulary, - Keyword$id, - Keyword$anchor, - Keyword$dynamicAnchor, - Keyword$ref, - Keyword$dynamicRef, - Keyword$defs, - Keyword$comment, - KeywordAllOf, - KeywordAnyOf, - KeywordOneOf, - KeywordNot, - KeywordIf, - KeywordThen, - KeywordElse, - KeywordDependentSchemas, - KeywordPrefixItems, - KeywordItems, - KeywordContains, - KeywordProperties, - KeywordPatternProperties, - KeywordAdditionalProperties, - KeywordPropertyNames, - KeywordUnevaluatedItems, - KeywordUnevaluatedProperties, - KeywordType, - KeywordEnum, - KeywordConst, - KeywordConstraint, - KeywordDependentRequired, - KeywordContentSchema, - KeywordTitle, - KeywordDescription, - KeywordDefault, - KeywordDeprecated, - KeywordReadOnly, - KeywordWriteOnly, - Accordion, - ExpandDeepButton, - ChevronRightIcon, - }, - fn: { - upperFirst: fn.upperFirst, - isExpandable: makeIsExpandable( - fn.jsonSchema202012.isExpandable, - system - ), - }, - } - ) - - return -}) - -OperationsWrapper.OperationsWithJSONSchemaContext = null - -export default OperationsWrapper diff --git a/src/core/plugins/oas31/wrap-components/webhooks.jsx b/src/core/plugins/oas31/wrap-components/webhooks.jsx deleted file mode 100644 index e2e848dfcaf..00000000000 --- a/src/core/plugins/oas31/wrap-components/webhooks.jsx +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @prettier - */ -import React from "react" - -import { createOnlyOAS31ComponentWrapper } from "../fn" -import { makeIsExpandable } from "../json-schema-2020-12-extensions/fn" - -const WebhooksWrapper = createOnlyOAS31ComponentWrapper(({ getSystem }) => { - const system = getSystem() - const { getComponent, fn, getConfigs } = system - const configs = getConfigs() - - if (WebhooksWrapper.WebhooksWithJSONSchemaContext) { - return - } - - const Webhooks = getComponent("Webhooks", true) - const JSONSchema = getComponent("JSONSchema202012") - const Keyword$schema = getComponent("JSONSchema202012Keyword$schema") - const Keyword$vocabulary = getComponent("JSONSchema202012Keyword$vocabulary") - const Keyword$id = getComponent("JSONSchema202012Keyword$id") - const Keyword$anchor = getComponent("JSONSchema202012Keyword$anchor") - const Keyword$dynamicAnchor = getComponent( - "JSONSchema202012Keyword$dynamicAnchor" - ) - const Keyword$ref = getComponent("JSONSchema202012Keyword$ref") - const Keyword$dynamicRef = getComponent("JSONSchema202012Keyword$dynamicRef") - const Keyword$defs = getComponent("JSONSchema202012Keyword$defs") - const Keyword$comment = getComponent("JSONSchema202012Keyword$comment") - const KeywordAllOf = getComponent("JSONSchema202012KeywordAllOf") - const KeywordAnyOf = getComponent("JSONSchema202012KeywordAnyOf") - const KeywordOneOf = getComponent("JSONSchema202012KeywordOneOf") - const KeywordNot = getComponent("JSONSchema202012KeywordNot") - const KeywordIf = getComponent("JSONSchema202012KeywordIf") - const KeywordThen = getComponent("JSONSchema202012KeywordThen") - const KeywordElse = getComponent("JSONSchema202012KeywordElse") - const KeywordDependentSchemas = getComponent( - "JSONSchema202012KeywordDependentSchemas" - ) - const KeywordPrefixItems = getComponent("JSONSchema202012KeywordPrefixItems") - const KeywordItems = getComponent("JSONSchema202012KeywordItems") - const KeywordContains = getComponent("JSONSchema202012KeywordContains") - const KeywordProperties = getComponent("JSONSchema202012KeywordProperties") - const KeywordPatternProperties = getComponent( - "JSONSchema202012KeywordPatternProperties" - ) - const KeywordAdditionalProperties = getComponent( - "JSONSchema202012KeywordAdditionalProperties" - ) - const KeywordPropertyNames = getComponent( - "JSONSchema202012KeywordPropertyNames" - ) - const KeywordUnevaluatedItems = getComponent( - "JSONSchema202012KeywordUnevaluatedItems" - ) - const KeywordUnevaluatedProperties = getComponent( - "JSONSchema202012KeywordUnevaluatedProperties" - ) - const KeywordType = getComponent("JSONSchema202012KeywordType") - const KeywordEnum = getComponent("JSONSchema202012KeywordEnum") - const KeywordConst = getComponent("JSONSchema202012KeywordConst") - const KeywordConstraint = getComponent("JSONSchema202012KeywordConstraint") - const KeywordDependentRequired = getComponent( - "JSONSchema202012KeywordDependentRequired" - ) - const KeywordContentSchema = getComponent( - "JSONSchema202012KeywordContentSchema" - ) - const KeywordTitle = getComponent("JSONSchema202012KeywordTitle") - const KeywordDescription = getComponent("JSONSchema202012KeywordDescription") - 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") - const withSchemaContext = getComponent("withJSONSchema202012Context") - - WebhooksWrapper.WebhooksWithJSONSchemaContext = withSchemaContext(Webhooks, { - config: { - default$schema: "https://spec.openapis.org/oas/3.1/dialect/base", - defaultExpandedLevels: configs.defaultModelExpandDepth - 1, - }, - components: { - JSONSchema, - Keyword$schema, - Keyword$vocabulary, - Keyword$id, - Keyword$anchor, - Keyword$dynamicAnchor, - Keyword$ref, - Keyword$dynamicRef, - Keyword$defs, - Keyword$comment, - KeywordAllOf, - KeywordAnyOf, - KeywordOneOf, - KeywordNot, - KeywordIf, - KeywordThen, - KeywordElse, - KeywordDependentSchemas, - KeywordPrefixItems, - KeywordItems, - KeywordContains, - KeywordProperties, - KeywordPatternProperties, - KeywordAdditionalProperties, - KeywordPropertyNames, - KeywordUnevaluatedItems, - KeywordUnevaluatedProperties, - KeywordType, - KeywordEnum, - KeywordConst, - KeywordConstraint, - KeywordDependentRequired, - KeywordContentSchema, - KeywordTitle, - KeywordDescription, - KeywordDefault, - KeywordDeprecated, - KeywordReadOnly, - KeywordWriteOnly, - Accordion, - ExpandDeepButton, - ChevronRightIcon, - }, - fn: { - upperFirst: fn.upperFirst, - isExpandable: makeIsExpandable(fn.jsonSchema202012.isExpandable, system), - }, - }) - - return -}) - -WebhooksWrapper.WebhooksWithJSONSchemaContext = null - -export default WebhooksWrapper diff --git a/src/style/main.scss b/src/style/main.scss index 758eec28691..413786180c3 100644 --- a/src/style/main.scss +++ b/src/style/main.scss @@ -19,4 +19,5 @@ @import 'split-pane-mode'; @import 'markdown'; @import '../core/plugins/json-schema-2020-12/components/all'; + @import '../core/plugins/oas31/components/all'; } From da1978e84cd1aa5280d8c0a50a5570f7e6caf219 Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Tue, 16 May 2023 10:33:33 +0200 Subject: [PATCH 2/2] style: fix --- .../json-schema-2020-12/components/JSONSchema/JSONSchema.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx b/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx index b879ab44ea9..0b9c92b7a32 100644 --- a/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx +++ b/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx @@ -80,8 +80,6 @@ const JSONSchema = forwardRef( const KeywordWriteOnly = useComponent("KeywordWriteOnly") const ExpandDeepButton = useComponent("ExpandDeepButton") - console.dir(expandedDeeply) - /** * Effects handlers. */