Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert pointless commit to fix #2320 #2349

Merged
merged 2 commits into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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