diff --git a/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/listing/BaseApiListingResource.java b/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/listing/BaseApiListingResource.java index d167052ec0..4399f0cf89 100644 --- a/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/listing/BaseApiListingResource.java +++ b/modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/listing/BaseApiListingResource.java @@ -139,19 +139,9 @@ protected Response getListingYamlResponse( HttpHeaders headers, UriInfo uriInfo) { Swagger swagger = process(app, servletContext, servletConfig, headers, uriInfo); - try { - if (swagger != null) { - String yaml = Yaml.mapper().writeValueAsString(swagger); - StringBuilder b = new StringBuilder(); - String[] parts = yaml.split("\n"); - for (String part : parts) { - b.append(part); - b.append("\n"); - } - return Response.ok().entity(b.toString()).type("application/yaml").build(); - } - } catch (Exception e) { - e.printStackTrace(); + + if (swagger != null) { + return Response.ok().entity(swagger).type("application/yaml").build(); } return Response.status(404).build(); } @@ -165,10 +155,9 @@ protected Response getListingJsonResponse( Swagger swagger = process(app, servletContext, servletConfig, headers, uriInfo); if (swagger != null) { - return Response.ok().entity(swagger).build(); - } else { - return Response.status(404).build(); + return Response.ok().entity(swagger).type(MediaType.APPLICATION_JSON).build(); } + return Response.status(404).build(); } private static Map> getQueryParams(MultivaluedMap params) {