Skip to content

Commit

Permalink
Revert "use custom object mapper to serialize json in order to avoid
Browse files Browse the repository at this point in the history
null values"

This reverts commit 3ad7595.

This fixes issue swagger-api#2320. The original commit is pointless and dangerous,
as it surprisingly overrides the behavior of SwaggerSerializers.java,
but does essentially the same (but without supporting pretty printing).
  • Loading branch information
christianc committed Aug 3, 2017
1 parent 222ef10 commit 3bce461
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 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 @@ -163,11 +161,11 @@ 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();
return Response.ok().entity(swagger).build();
} else {
return Response.status(404).build();
}
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 3bce461

Please sign in to comment.