fix(oas31): render responses with empty content field (#9664)

Refs #9199
This commit is contained in:
Vladimír Gorej
2024-03-06 14:20:45 +01:00
committed by GitHub
parent 4b4760d7fd
commit e2be707d7c
10 changed files with 356 additions and 13 deletions

View File

@@ -8,20 +8,16 @@ import { getKnownSyntaxHighlighterLanguage } from "core/utils/jsonParse"
const getExampleComponent = ( sampleResponse, HighlightCode, getConfigs ) => {
if (
sampleResponse !== undefined &&
sampleResponse !== null
) {
let language = null
let testValueForJson = getKnownSyntaxHighlighterLanguage(sampleResponse)
if (testValueForJson) {
language = "json"
}
return <div>
if (sampleResponse == null) return null
const testValueForJson = getKnownSyntaxHighlighterLanguage(sampleResponse)
const language = testValueForJson ? "json" : null
return (
<div>
<HighlightCode className="example" getConfigs={ getConfigs } language={ language } value={ stringify(sampleResponse) } />
</div>
}
return null
)
}
export default class Response extends React.Component {
@@ -171,7 +167,7 @@ export default class Response extends React.Component {
shouldOverrideSchemaExample ? mediaTypeExample : undefined
)
let example = getExampleComponent( sampleResponse, HighlightCode, getConfigs )
const example = getExampleComponent( sampleResponse, HighlightCode, getConfigs )
return (
<tr className={ "response " + ( className || "") } data-code={code}>