improve: error message when rendering XML example (via #5253)
The original message gave no clues as to the underlying cause, which is that the element name needs to be specified explicitly (using xml/name) if it can't be determined from a $ref.
This commit is contained in:
@@ -632,7 +632,7 @@ export const getSampleSchema = (schema, contentType="", config={}) => {
|
|||||||
let match = schema.$$ref.match(/\S*\/(\S+)$/)
|
let match = schema.$$ref.match(/\S*\/(\S+)$/)
|
||||||
schema.xml.name = match[1]
|
schema.xml.name = match[1]
|
||||||
} else if (schema.type || schema.items || schema.properties || schema.additionalProperties) {
|
} else if (schema.type || schema.items || schema.properties || schema.additionalProperties) {
|
||||||
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- XML example cannot be generated -->"
|
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- XML example cannot be generated; root element name is undefined -->"
|
||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user