Skip to content

Commit

Permalink
Merge pull request #9600 from swagger-api/disable_examples_options
Browse files Browse the repository at this point in the history
added option to disable examples.
  • Loading branch information
HugoMario committed Jul 26, 2019
2 parents f302d88 + 6cdba23 commit 7c7bc14
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class Generate implements Runnable {
protected List<String> reservedWordsMappings = new ArrayList<>();
protected String ignoreFileOverride;
protected Boolean removeOperationIdPrefix;
protected Boolean disableExamples;
private String url;
private List<CodegenArgument> codegenArguments;

Expand Down Expand Up @@ -213,6 +214,10 @@ public void setCodegenArguments(List<CodegenArgument> codegenArguments) {
this.codegenArguments = codegenArguments;
}

public void setDisableExamples(Boolean disableExamples) {
this.disableExamples = disableExamples;
}

@Override
public void run() {

Expand Down Expand Up @@ -324,6 +329,10 @@ public void run() {
configurator.setCodegenArguments(codegenArguments);
}

if (disableExamples != null && disableExamples) {
additionalProperties.add(String.format("%s=%s", CodegenConstants.DISABLE_EXAMPLES_OPTION, disableExamples.toString()));
}

if (CodegenConstants.MUSTACHE_TEMPLATE_ENGINE.equalsIgnoreCase(templateEngine)) {
additionalProperties.add(String.format("%s=%s", CodegenConstants.TEMPLATE_ENGINE, CodegenConstants.MUSTACHE_TEMPLATE_ENGINE));
} else {
Expand Down
7 changes: 6 additions & 1 deletion modules/swagger-codegen-cli/src/main/resources/oas3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ components:
description: "load arguments from a local file or remote URL. Arguments found will replace any one placed on command."
x-option: "--url"
x-short-version: "-u"
disableExamples:
type: "boolean"
title: "disable examples"
description: "avoid writing json/xml examples on generated operations."
x-option: "--disable-examples"
ConfigHelp:
x-command: "config-help"
x-command-description: "Config help for chosen lang"
Expand Down Expand Up @@ -236,4 +241,4 @@ components:
x-class-name: "io.swagger.codegen.v3.cli.cmd.Langs"
Version:
x-command-description: "Show version information"
x-class-name: "io.swagger.codegen.v3.cli.cmd.Version"
x-class-name: "io.swagger.codegen.v3.cli.cmd.Version"
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,
public static final String USE_OAS2_DESC = "use OpenAPI v2.0 (Swagger 1.5.x)";

public static final String TEMPLATE_ENGINE = "templateEngine";
public static final String DISABLE_EXAMPLES_OPTION = "disableExample";

public static final String IS_ENUM_EXT_NAME = PREFIX_IS + "enum";
public static final String IS_ALIAS_EXT_NAME = PREFIX_IS + "alias";
Expand Down

0 comments on commit 7c7bc14

Please sign in to comment.