Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(oas31): fix extendable behavior in OpenAPI 3.1 base dialect keywords #8660

Merged
merged 1 commit into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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">
<Accordion expanded={expanded} onChange={handleExpansion}>
{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}
/>
</>
) : (
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--secondary">
Discriminator
</span>
</Accordion>
<ExpandDeepButton expanded={expanded} onClick={handleExpansionDeep} />
)}

{discriminator.propertyName && (
<span className="json-schema-2020-12__attribute json-schema-2020-12__attribute--muted">
{discriminator.propertyName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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">
<Accordion expanded={expanded} onChange={handleExpansion}>
{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}
/>
</>
) : (
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--secondary">
External documentation
</span>
</Accordion>
<ExpandDeepButton expanded={expanded} onClick={handleExpansionDeep} />
)}
<strong className="json-schema-2020-12__attribute json-schema-2020-12__attribute--primary">
object
</strong>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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">
<Accordion expanded={expanded} onChange={handleExpansion}>
{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}
/>
</>
) : (
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--secondary">
XML
</span>
</Accordion>
<ExpandDeepButton expanded={expanded} onClick={handleExpansionDeep} />
)}
{xml.attribute === true && (
<span className="json-schema-2020-12__attribute json-schema-2020-12__attribute--muted">
attribute
Expand Down