Description
Trying to migrate from swagger-ui 2x to 3.0.12. It seems that swagger-ui 3.x is not able to render x-examples data.
"/data/targets" : {
"post" : {
"tags" : [ "dummy" ],
"summary" : "Returns validation results of given list of targets.",
"description" : "",
"operationId" : "dataTargets",
"produces" : [ "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Targets list in JSON format.",
"required" : true,
"schema" : {
"type" : "string"
},
"x-examples" : {
"default" : "{\"targets\": \"[1, 2, 3, 4]\"}"
}
}
<...>
}
In version 2.x swagger-ui was able to use the value from x-examples as example request. As a quick and dirty hack, I have made some changes in src/core/components/param-body.jsx
updateValues = (props) => {
let { specSelectors, pathMethod, param, isExecute, consumesValue="" } = props
let parameter = specSelectors ? specSelectors.getParameter(pathMethod, param.get("name")) : {}
let isXml = /xml/i.test(consumesValue);
let paramValue = isXml ? parameter.get("value_xml") : parameter.get("value");
if (parameter.get("x-examples") && parameter.get("x-examples").get("default")) {
paramValue = parameter.get("x-examples").get("default")
}
....
}
Is it possible to address this properly? Add support of x-examples into core or maybe create a plugin for this?