Skip to content

Commit

Permalink
improve: error message when rendering XML example (via #5253)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alanyst authored and shockey committed Apr 10, 2019
1 parent 98610f8 commit f50bbec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -842,4 +842,4 @@ export function paramToValue(param, paramValues) {
.filter(value => value !== undefined)

return values[0]
}
}

0 comments on commit f50bbec

Please sign in to comment.