Skip to content
Open
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.v3.core.util;

import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.slf4j.Logger;
Expand All @@ -19,7 +18,7 @@ public static ObjectMapper mapper() {
}

public static ObjectWriter pretty() {
return mapper().writer(new DefaultPrettyPrinter());
return mapper().writerWithDefaultPrettyPrinter();
}

public static String pretty(Object o) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.swagger.v3.core.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
Expand Down Expand Up @@ -32,7 +31,7 @@ public static ObjectMapper converterMapper() {
}

public static ObjectWriter pretty() {
return mapper().writer(new DefaultPrettyPrinter());
return mapper().writerWithDefaultPrettyPrinter();
}

public static String pretty(Object o) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.swagger.v3.core.util;

import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.slf4j.Logger;
Expand All @@ -19,7 +18,7 @@ public static ObjectMapper mapper() {
}

public static ObjectWriter pretty() {
return mapper().writer(new DefaultPrettyPrinter());
return mapper().writerWithDefaultPrettyPrinter();
}

public static String pretty(Object o) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.swagger.v3.core.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import io.swagger.v3.oas.models.media.Schema;
Expand All @@ -24,7 +23,7 @@ public static ObjectMapper mapper() {
}

public static ObjectWriter pretty() {
return mapper().writer(new DefaultPrettyPrinter());
return mapper().writerWithDefaultPrettyPrinter();
}

public static String pretty(Object o) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.swagger.v3.core.resolving;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
Expand Down Expand Up @@ -29,7 +28,7 @@ protected ModelResolver modelResolver() {

protected void prettyPrint(Object o) {
try {
LOGGER.debug(mapper().writer(new DefaultPrettyPrinter()).writeValueAsString(o));
LOGGER.debug(mapper().writerWithDefaultPrettyPrinter().writeValueAsString(o));
} catch (Exception e) {
LOGGER.error("Failed to pretty print object", e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.swagger.v3.java17.resolving;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
Expand Down Expand Up @@ -29,7 +28,7 @@ protected ModelResolver modelResolver() {

protected void prettyPrint(Object o) {
try {
LOGGER.debug(mapper().writer(new DefaultPrettyPrinter()).writeValueAsString(o));
LOGGER.debug(mapper().writerWithDefaultPrettyPrinter().writeValueAsString(o));
} catch (Exception e) {
LOGGER.error("Failed to pretty print object", e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.swagger.v3.jaxrs2.integration;

import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import io.swagger.v3.core.filter.OpenAPISpecFilter;
import io.swagger.v3.core.filter.SpecFilter;
import io.swagger.v3.jaxrs2.util.ServletUtils;
Expand Down Expand Up @@ -86,12 +85,12 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
if (type.equalsIgnoreCase("yaml")) {
resp.setContentType(APPLICATION_YAML);
try (PrintWriter pw = resp.getWriter()) {
pw.write(pretty ? ctx.getOutputYamlMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(oas) : ctx.getOutputYamlMapper().writeValueAsString(oas));
pw.write(pretty ? ctx.getOutputYamlMapper().writerWithDefaultPrettyPrinter().writeValueAsString(oas) : ctx.getOutputYamlMapper().writeValueAsString(oas));
}
} else {
resp.setContentType(APPLICATION_JSON);
try (PrintWriter pw = resp.getWriter()) {
pw.write(pretty ? ctx.getOutputJsonMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(oas) : ctx.getOutputJsonMapper().writeValueAsString(oas));
pw.write(pretty ? ctx.getOutputJsonMapper().writerWithDefaultPrettyPrinter().writeValueAsString(oas) : ctx.getOutputJsonMapper().writeValueAsString(oas));
}
}

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

import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import io.swagger.v3.core.filter.OpenAPISpecFilter;
import io.swagger.v3.core.filter.SpecFilter;
import io.swagger.v3.core.util.Configuration;
Expand Down Expand Up @@ -401,14 +400,14 @@ public Map<String, String> resolve() throws Exception{
String openapiYaml = null;
if ("JSON".equals(outputFormat) || "JSONANDYAML".equals(outputFormat)) {
if (prettyPrint != null && prettyPrint) {
openapiJson = context.getOutputJsonMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(openAPI);
openapiJson = context.getOutputJsonMapper().writerWithDefaultPrettyPrinter().writeValueAsString(openAPI);
} else {
openapiJson = context.getOutputJsonMapper().writeValueAsString(openAPI);
}
}
if ("YAML".equals(outputFormat) || "JSONANDYAML".equals(outputFormat)) {
if (prettyPrint != null && prettyPrint) {
openapiYaml = context.getOutputYamlMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(openAPI);
openapiYaml = context.getOutputYamlMapper().writerWithDefaultPrettyPrinter().writeValueAsString(openAPI);
} else {
openapiYaml = context.getOutputYamlMapper().writeValueAsString(openAPI);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.swagger.v3.jaxrs2.integration.resources;

import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import io.swagger.v3.core.filter.OpenAPISpecFilter;
import io.swagger.v3.core.filter.SpecFilter;
import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder;
Expand Down Expand Up @@ -71,14 +70,14 @@ protected Response getOpenApi(HttpHeaders headers,
if (StringUtils.isNotBlank(type) && type.trim().equalsIgnoreCase("yaml")) {
return Response.status(Response.Status.OK)
.entity(pretty ?
ctx.getOutputYamlMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(oas) :
ctx.getOutputYamlMapper().writerWithDefaultPrettyPrinter().writeValueAsString(oas) :
ctx.getOutputYamlMapper().writeValueAsString(oas))
.type("application/yaml")
.build();
} else {
return Response.status(Response.Status.OK)
.entity(pretty ?
ctx.getOutputJsonMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(oas) :
ctx.getOutputJsonMapper().writerWithDefaultPrettyPrinter().writeValueAsString(oas) :
ctx.getOutputJsonMapper().writeValueAsString(oas))
.type(MediaType.APPLICATION_JSON_TYPE)
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.swagger.v3.jaxrs2;

import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder;
import io.swagger.v3.oas.integration.OpenApiConfigurationException;
import io.swagger.v3.oas.integration.OpenApiContextLocator;
Expand Down Expand Up @@ -68,7 +67,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se

resp.setContentType("application/yaml");
try (PrintWriter pw = resp.getWriter()) {
pw.write(ctx.getOutputYamlMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(oas));
pw.write(ctx.getOutputYamlMapper().writerWithDefaultPrettyPrinter().writeValueAsString(oas));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
Expand Down Expand Up @@ -71,7 +70,7 @@ public void sortOutputTest() throws Exception {
.init();

OpenAPI openApi = ctx.read();
String sorted = ctx.getOutputYamlMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(openApi);
String sorted = ctx.getOutputYamlMapper().writerWithDefaultPrettyPrinter().writeValueAsString(openApi);

openApiConfiguration = new SwaggerConfiguration()
.resourcePackages(Collections.singleton("com.my.sorted.resources"));
Expand All @@ -80,7 +79,7 @@ public void sortOutputTest() throws Exception {
.openApiConfiguration(openApiConfiguration)
.init();

String notSorted = ctx.getOutputYamlMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(openApi);
String notSorted = ctx.getOutputYamlMapper().writerWithDefaultPrettyPrinter().writeValueAsString(openApi);

assertEquals(sorted, expectedSorted);
assertEquals(notSorted, expectedNotSorted);
Expand Down Expand Up @@ -176,7 +175,7 @@ public void configOutputTest() throws Exception {
.init();

OpenAPI openApi = ctx.read();
String sorted = ctx.getOutputYamlMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(openApi);
String sorted = ctx.getOutputYamlMapper().writerWithDefaultPrettyPrinter().writeValueAsString(openApi);

openApiConfiguration = new SwaggerConfiguration()
.resourcePackages(Collections.singleton("com.my.sorted.resources"));
Expand All @@ -185,7 +184,7 @@ public void configOutputTest() throws Exception {
.openApiConfiguration(openApiConfiguration)
.init();

String notSorted = ctx.getOutputYamlMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(openApi);
String notSorted = ctx.getOutputYamlMapper().writerWithDefaultPrettyPrinter().writeValueAsString(openApi);

assertEquals(sorted, expectedSorted);
assertEquals(notSorted, expectedNotSorted);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.swagger.v3.plugin.maven;

import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import io.swagger.v3.core.filter.OpenAPISpecFilter;
import io.swagger.v3.core.filter.SpecFilter;
import io.swagger.v3.core.util.Configuration;
Expand Down Expand Up @@ -101,14 +100,14 @@ public void execute() throws MojoExecutionException, MojoFailureException {
String openapiYaml = null;
if (Format.JSON.equals(outputFormat) || Format.JSONANDYAML.equals(outputFormat)) {
if (config.isPrettyPrint() != null && config.isPrettyPrint()) {
openapiJson = context.getOutputJsonMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(openAPI);
openapiJson = context.getOutputJsonMapper().writerWithDefaultPrettyPrinter().writeValueAsString(openAPI);
} else {
openapiJson = context.getOutputJsonMapper().writeValueAsString(openAPI);
}
}
if (Format.YAML.equals(outputFormat) || Format.JSONANDYAML.equals(outputFormat)) {
if (config.isPrettyPrint() != null && config.isPrettyPrint()) {
openapiYaml = context.getOutputYamlMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(openAPI);
openapiYaml = context.getOutputYamlMapper().writerWithDefaultPrettyPrinter().writeValueAsString(openAPI);
} else {
openapiYaml = context.getOutputYamlMapper().writeValueAsString(openAPI);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.swagger.test;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
Expand Down Expand Up @@ -134,6 +133,6 @@ public static String writeJson(Object value) throws Exception {
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

return mapper.writer(new DefaultPrettyPrinter()).writeValueAsString(value);
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(value);
}
}