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:
Alan Wessman
2019-04-09 18:17:36 -06:00
committed by kyle
parent 98610f88a6
commit f50bbecc38

View File

@@ -632,7 +632,7 @@ export const getSampleSchema = (schema, contentType="", config={}) => {
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 -->"
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- XML example cannot be generated; root element name is undefined -->"
} else {
return null
}