Skip to content

Commit

Permalink
Merge pull request #2349 from ChristianCiach/issue2320
Browse files Browse the repository at this point in the history
Revert pointless commit to fix #2320
  • Loading branch information
frantuma authored Dec 21, 2017
2 parents 45000b5 + f5f8392 commit f8b92ac
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.swagger.jaxrs.listing;

import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.annotations.ApiOperation;

import javax.servlet.ServletConfig;
Expand All @@ -26,7 +25,7 @@ public Response getListingJson(
@Context Application app,
@Context ServletConfig sc,
@Context HttpHeaders headers,
@Context UriInfo uriInfo) throws JsonProcessingException {
@Context UriInfo uriInfo) {
return getListingJsonResponse(app, context, sc, headers, uriInfo);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.swagger.jaxrs.listing;

import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;

Expand All @@ -26,7 +25,7 @@ public Response getListing(
@Context ServletConfig sc,
@Context HttpHeaders headers,
@Context UriInfo uriInfo,
@PathParam("type") String type) throws JsonProcessingException {
@PathParam("type") String type) {
if (StringUtils.isNotBlank(type) && type.trim().equalsIgnoreCase("yaml")) {
return getListingYamlResponse(app, context, sc, headers, uriInfo);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.swagger.jaxrs.listing;

import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.config.FilterFactory;
import io.swagger.config.Scanner;
import io.swagger.config.SwaggerConfig;
Expand All @@ -11,7 +10,6 @@
import io.swagger.jaxrs.config.ReaderConfigUtils;
import io.swagger.jaxrs.config.SwaggerContextService;
import io.swagger.models.Swagger;
import io.swagger.util.Json;
import io.swagger.util.Yaml;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -141,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();
}
Expand All @@ -163,14 +151,13 @@ protected Response getListingJsonResponse(
ServletContext servletContext,
ServletConfig servletConfig,
HttpHeaders headers,
UriInfo uriInfo) throws JsonProcessingException {
UriInfo uriInfo) {
Swagger swagger = process(app, servletContext, servletConfig, headers, uriInfo);

if (swagger != null) {
return Response.ok().entity(Json.mapper().writeValueAsString(swagger)).type(MediaType.APPLICATION_JSON_TYPE).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<String, List<String>> getQueryParams(MultivaluedMap<String, String> params) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.swagger;

import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.jaxrs.Reader;
import io.swagger.jaxrs.listing.ApiListingResource;
import io.swagger.models.Swagger;
Expand All @@ -25,7 +24,7 @@ public void shouldCheckModelsSet() {
}

@Test
public void shouldHandleNullServletConfig_issue1689() throws JsonProcessingException {
public void shouldHandleNullServletConfig_issue1689() {
ApiListingResource a = new ApiListingResource();
try {
a.getListing(null, null, null, null, "json");
Expand All @@ -39,7 +38,7 @@ public void shouldHandleNullServletConfig_issue1689() throws JsonProcessingExcep

}
@Test
public void shouldHandleErrorServletConfig_issue1691() throws JsonProcessingException {
public void shouldHandleErrorServletConfig_issue1691() {

ServletConfig sc = new ServletConfig() {
@Override
Expand Down

0 comments on commit f8b92ac

Please sign in to comment.