fix(oas31): fix extendable behavior in OpenAPI 3.1 base dialect keywords (#8660)
This change is related to JSON Schema 2020-12. Refs #8513
This commit is contained in:
@@ -12,6 +12,7 @@ const Discriminator = ({ schema, getSystem }) => {
|
||||
const { fn, getComponent } = getSystem()
|
||||
const { useIsExpandedDeeply, useComponent } = fn.jsonSchema202012
|
||||
const isExpandedDeeply = useIsExpandedDeeply()
|
||||
const isExpandable = !!discriminator.mapping
|
||||
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
||||
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
||||
const Accordion = useComponent("Accordion")
|
||||
@@ -41,12 +42,24 @@ const Discriminator = ({ schema, getSystem }) => {
|
||||
return (
|
||||
<JSONSchemaDeepExpansionContext.Provider value={expandedDeeply}>
|
||||
<div className="json-schema-2020-12-keyword json-schema-2020-12-keyword--discriminator">
|
||||
{isExpandable ? (
|
||||
<>
|
||||
<Accordion expanded={expanded} onChange={handleExpansion}>
|
||||
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--secondary">
|
||||
Discriminator
|
||||
</span>
|
||||
</Accordion>
|
||||
<ExpandDeepButton expanded={expanded} onClick={handleExpansionDeep} />
|
||||
<ExpandDeepButton
|
||||
expanded={expanded}
|
||||
onClick={handleExpansionDeep}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--secondary">
|
||||
Discriminator
|
||||
</span>
|
||||
)}
|
||||
|
||||
{discriminator.propertyName && (
|
||||
<span className="json-schema-2020-12__attribute json-schema-2020-12__attribute--muted">
|
||||
{discriminator.propertyName}
|
||||
|
||||
@@ -12,6 +12,7 @@ const ExternalDocs = ({ schema, getSystem }) => {
|
||||
const { fn, getComponent } = getSystem()
|
||||
const { useIsExpandedDeeply, useComponent } = fn.jsonSchema202012
|
||||
const isExpandedDeeply = useIsExpandedDeeply()
|
||||
const isExpandable = !!(externalDocs.description || externalDocs.url)
|
||||
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
||||
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
||||
const Accordion = useComponent("Accordion")
|
||||
@@ -43,12 +44,23 @@ const ExternalDocs = ({ schema, getSystem }) => {
|
||||
return (
|
||||
<JSONSchemaDeepExpansionContext.Provider value={expandedDeeply}>
|
||||
<div className="json-schema-2020-12-keyword json-schema-2020-12-keyword--externalDocs">
|
||||
{isExpandable ? (
|
||||
<>
|
||||
<Accordion expanded={expanded} onChange={handleExpansion}>
|
||||
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--secondary">
|
||||
External documentation
|
||||
</span>
|
||||
</Accordion>
|
||||
<ExpandDeepButton expanded={expanded} onClick={handleExpansionDeep} />
|
||||
<ExpandDeepButton
|
||||
expanded={expanded}
|
||||
onClick={handleExpansionDeep}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--secondary">
|
||||
External documentation
|
||||
</span>
|
||||
)}
|
||||
<strong className="json-schema-2020-12__attribute json-schema-2020-12__attribute--primary">
|
||||
object
|
||||
</strong>
|
||||
|
||||
@@ -10,6 +10,7 @@ const Xml = ({ schema, getSystem }) => {
|
||||
const { fn, getComponent } = getSystem()
|
||||
const { useIsExpandedDeeply, useComponent } = fn.jsonSchema202012
|
||||
const isExpandedDeeply = useIsExpandedDeeply()
|
||||
const isExpandable = !!(xml.name || xml.namespace || xml.prefix)
|
||||
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
||||
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
||||
const Accordion = useComponent("Accordion")
|
||||
@@ -39,12 +40,23 @@ const Xml = ({ schema, getSystem }) => {
|
||||
return (
|
||||
<JSONSchemaDeepExpansionContext.Provider value={expandedDeeply}>
|
||||
<div className="json-schema-2020-12-keyword json-schema-2020-12-keyword--xml">
|
||||
{isExpandable ? (
|
||||
<>
|
||||
<Accordion expanded={expanded} onChange={handleExpansion}>
|
||||
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--secondary">
|
||||
XML
|
||||
</span>
|
||||
</Accordion>
|
||||
<ExpandDeepButton expanded={expanded} onClick={handleExpansionDeep} />
|
||||
<ExpandDeepButton
|
||||
expanded={expanded}
|
||||
onClick={handleExpansionDeep}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--secondary">
|
||||
XML
|
||||
</span>
|
||||
)}
|
||||
{xml.attribute === true && (
|
||||
<span className="json-schema-2020-12__attribute json-schema-2020-12__attribute--muted">
|
||||
attribute
|
||||
|
||||
Reference in New Issue
Block a user