fix(xml): render example with oneOf/anyOf (#8206)
* test(e2e): render xml example with oneOf/anyOf
This commit is contained in:
@@ -605,18 +605,19 @@ export const validateParam = (param, value, { isOAS3 = false, bypassRequiredChec
|
||||
}
|
||||
|
||||
const getXmlSampleSchema = (schema, config, exampleOverride) => {
|
||||
if (schema && (!schema.xml || !schema.xml.name)) {
|
||||
schema.xml = schema.xml || {}
|
||||
|
||||
if (schema && !schema.xml) {
|
||||
schema.xml = {}
|
||||
}
|
||||
if (schema && !schema.xml.name) {
|
||||
if (!schema.$$ref && (schema.type || schema.items || schema.properties || schema.additionalProperties)) {
|
||||
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- XML example cannot be generated; root element name is undefined -->"
|
||||
}
|
||||
if (schema.$$ref) {
|
||||
let match = schema.$$ref.match(/\S*\/(\S+)$/)
|
||||
schema.xml.name = match[1]
|
||||
} else if (schema.type || schema.items || schema.properties || schema.additionalProperties) {
|
||||
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- XML example cannot be generated; root element name is undefined -->"
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return memoizedCreateXMLExample(schema, config, exampleOverride)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user