Skip to content

Commit

Permalink
Merge pull request #3874 from swagger-api/ticket-3868
Browse files Browse the repository at this point in the history
fix #3868 - maven plugin: use prettyPrint from config file
  • Loading branch information
frantuma authored Feb 8, 2021
2 parents daf8213 + 6685cc1 commit 881ceb3
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
OpenApiContext context = builder.buildContext(true);
OpenAPI openAPI = context.read();

if (StringUtils.isNotBlank(filterClass)) {
if (StringUtils.isNotBlank(config.getFilterClass())) {
try {
OpenAPISpecFilter filterImpl = (OpenAPISpecFilter) this.getClass().getClassLoader().loadClass(filterClass).newInstance();
OpenAPISpecFilter filterImpl = (OpenAPISpecFilter) this.getClass().getClassLoader().loadClass(config.getFilterClass()).newInstance();
SpecFilter f = new SpecFilter();
openAPI = f.filter(openAPI, filterImpl, new HashMap<>(), new HashMap<>(),
new HashMap<>());
Expand All @@ -98,14 +98,14 @@ public void execute() throws MojoExecutionException, MojoFailureException {
String openapiJson = null;
String openapiYaml = null;
if (Format.JSON.equals(outputFormat) || Format.JSONANDYAML.equals(outputFormat)) {
if (prettyPrint != null && prettyPrint) {
if (config.isPrettyPrint() != null && config.isPrettyPrint()) {
openapiJson = context.getOutputJsonMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(openAPI);
} else {
openapiJson = context.getOutputJsonMapper().writeValueAsString(openAPI);
}
}
if (Format.YAML.equals(outputFormat) || Format.JSONANDYAML.equals(outputFormat)) {
if (prettyPrint != null && prettyPrint) {
if (config.isPrettyPrint() != null && config.isPrettyPrint()) {
openapiYaml = context.getOutputYamlMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(openAPI);
} else {
openapiYaml = context.getOutputYamlMapper().writeValueAsString(openAPI);
Expand Down

0 comments on commit 881ceb3

Please sign in to comment.