fix(oas31): render responses with empty content field (#9664)
Refs #9199
This commit is contained in:
@@ -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}>
|
||||
|
||||
@@ -21,6 +21,9 @@ export const sampleFromSchemaGeneric = (
|
||||
exampleOverride = undefined,
|
||||
respectXML = false
|
||||
) => {
|
||||
// there is nothing to generate schema from
|
||||
if (schema == null && exampleOverride === undefined) return undefined
|
||||
|
||||
if (typeof schema?.toJS === "function") schema = schema.toJS()
|
||||
schema = typeCast(schema)
|
||||
|
||||
|
||||
@@ -27,6 +27,10 @@ function afterLoad({ fn, getSystem }) {
|
||||
createXMLExample: fn.jsonSchema202012.createXMLExample,
|
||||
memoizedSampleFromSchema: fn.jsonSchema202012.memoizedSampleFromSchema,
|
||||
memoizedCreateXMLExample: fn.jsonSchema202012.memoizedCreateXMLExample,
|
||||
getJsonSampleSchema: fn.jsonSchema202012.getJsonSampleSchema,
|
||||
getYamlSampleSchema: fn.jsonSchema202012.getYamlSampleSchema,
|
||||
getXmlSampleSchema: fn.jsonSchema202012.getXmlSampleSchema,
|
||||
getSampleSchema: fn.jsonSchema202012.getSampleSchema,
|
||||
},
|
||||
getSystem()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user