@@ -27,6 +27,7 @@ import com.eviware.soapui.impl.rest.support.RestParameter
2727import com.eviware.soapui.impl.rest.support.RestParamsPropertyHolder.ParameterStyle
2828import com.eviware.soapui.impl.wsdl.WsdlProject
2929import com.eviware.soapui.support.StringUtils
30+ import com.eviware.soapui.support.xml.XmlUtils
3031import com.fasterxml.jackson.databind.ObjectMapper
3132import com.fasterxml.jackson.databind.module.SimpleModule
3233import io.swagger.inflector.examples.ExampleBuilder
@@ -216,7 +217,7 @@ class Swagger2Importer implements SwaggerImporter {
216217
217218 def consumes = operation. consumes
218219 if (consumes == null || consumes. empty) {
219- consumes = [ " application/json " ]
220+ consumes = swagger . consumes
220221 }
221222
222223 consumes. each {
@@ -255,6 +256,10 @@ class Swagger2Importer implements SwaggerImporter {
255256 operation. responses?. each {
256257 def response = it
257258
259+ if (operation. produces == null || operation. produces. empty){
260+ operation. produces = swagger. produces
261+ }
262+
258263 if (operation. produces == null || operation. produces. empty) {
259264 def representation = method. addNewRepresentation(RestRepresentation.Type . RESPONSE )
260265
@@ -307,13 +312,13 @@ class Swagger2Importer implements SwaggerImporter {
307312 def mapper = null
308313
309314 switch (mediaType) {
310- case " application/xml" : sampleValue = new XmlExampleSerializer (). serialize(output); break ;
315+ case " application/xml" : sampleValue = XmlUtils . prettyPrintXml( new XmlExampleSerializer (). serialize(output) ); break ;
311316 case " application/yaml" : mapper = yamlMapper; break ;
312317 case " application/json" : mapper = jsonMapper; break ;
313318 }
314319
315320 if (mapper != null ) {
316- sampleValue = mapper. writer (). writeValueAsString(output)
321+ sampleValue = mapper. writerWithDefaultPrettyPrinter (). writeValueAsString(output)
317322 }
318323 return sampleValue
319324 }
0 commit comments