Skip to content

Commit beabe8c

Browse files
committed
Merge branch 'master' into android-volley-library
Conflicts: modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java
2 parents bed94ac + 3eb78b1 commit beabe8c

File tree

87 files changed

+189
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+189
-118
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/CliOption.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.swagger.codegen;
22

33
import io.swagger.annotations.ApiModelProperty;
4+
import io.swagger.models.properties.BooleanProperty;
45
import io.swagger.models.properties.StringProperty;
56

67
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -78,6 +79,14 @@ public void setEnum(Map<String, String> enumValues) {
7879
this.enumValues = enumValues;
7980
}
8081

82+
public static CliOption newBoolean(String opt, String description) {
83+
return new CliOption(opt, description, BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString());
84+
}
85+
86+
public static CliOption newString(String opt, String description) {
87+
return new CliOption(opt, description, StringProperty.TYPE);
88+
}
89+
8190
@JsonIgnore
8291
public String getOptionHelp() {
8392
StringBuilder sb = new StringBuilder(description);

modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class CodegenConstants {
3838
public static final String SERIALIZABLE_MODEL_DESC = "boolean - toggle \"implements Serializable\" for generated models";
3939

4040
public static final String SERIALIZE_BIG_DECIMAL_AS_STRING = "bigDecimalAsString";
41-
public static final String SERIALIZE_BIG_DECIMAL_AS_STRING_DESC = "boolean - treat BigDecimal values as Strings to avoid precision loss. Default: false";
41+
public static final String SERIALIZE_BIG_DECIMAL_AS_STRING_DESC = "Treat BigDecimal values as Strings to avoid precision loss.";
4242

4343
public static final String LIBRARY = "library";
4444
public static final String LIBRARY_DESC = "library template (sub-template)";

modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,10 @@ public DefaultCodegen() {
439439
importMapping.put("LocalDate", "org.joda.time.*");
440440
importMapping.put("LocalTime", "org.joda.time.*");
441441

442-
cliOptions.add(new CliOption(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
443-
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC, BooleanProperty.TYPE)
444-
.defaultValue(Boolean.TRUE.toString()));
445-
cliOptions.add(new CliOption(CodegenConstants.ENSURE_UNIQUE_PARAMS, CodegenConstants.ENSURE_UNIQUE_PARAMS_DESC,
446-
BooleanProperty.TYPE).defaultValue(Boolean.TRUE.toString()));
442+
cliOptions.add(CliOption.newBoolean(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
443+
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString()));
444+
cliOptions.add(CliOption.newBoolean(CodegenConstants.ENSURE_UNIQUE_PARAMS, CodegenConstants
445+
.ENSURE_UNIQUE_PARAMS_DESC).defaultValue(Boolean.TRUE.toString()));
447446
}
448447

449448
/**

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public AndroidClientCodegen() {
7272
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, "artifactId for use in the generated build.gradle and pom.xml"));
7373
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "artifact version for use in the generated build.gradle and pom.xml"));
7474
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC));
75-
cliOptions.add(new CliOption(USE_ANDROID_MAVEN_GRADLE_PLUGIN, "A flag to toggle android-maven gradle plugin.",
76-
BooleanProperty.TYPE).defaultValue(Boolean.TRUE.toString()));
75+
cliOptions.add(CliOption.newBoolean(USE_ANDROID_MAVEN_GRADLE_PLUGIN, "A flag to toggle android-maven gradle plugin.")
76+
.defaultValue(Boolean.TRUE.toString()));
7777

7878
supportedLibraries.put("<default>", "HTTP client: Apache HttpClient 4.3.6. JSON processing: Gson 2.3.1");
7979
supportedLibraries.put("volley", "HTTP client: Volley 1.0.19");

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,10 @@ public CSharpClientCodegen() {
9494
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "C# package name (convention: Camel.Case).")
9595
.defaultValue("IO.Swagger"));
9696
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "C# package version.").defaultValue("1.0.0"));
97-
cliOptions.add(new CliOption(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
98-
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC, BooleanProperty.TYPE));
99-
cliOptions.add(new CliOption(CodegenConstants.OPTIONAL_METHOD_ARGUMENT, "C# Optional method argument, " +
100-
"e.g. void square(int x=10) (.net 4.0+ only).", BooleanProperty.TYPE)
101-
.defaultValue(Boolean.FALSE.toString()));
97+
cliOptions.add(CliOption.newBoolean(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
98+
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString()));
99+
cliOptions.add(CliOption.newBoolean(CodegenConstants.OPTIONAL_METHOD_ARGUMENT, "C# Optional method argument, " +
100+
"e.g. void square(int x=10) (.net 4.0+ only)."));
102101
}
103102

104103
@Override

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,10 @@ public JavaClientCodegen() {
7676
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC));
7777
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC));
7878
cliOptions.add(new CliOption(CodegenConstants.LOCAL_VARIABLE_PREFIX, CodegenConstants.LOCAL_VARIABLE_PREFIX_DESC));
79-
cliOptions.add(new CliOption(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC,
80-
BooleanProperty.TYPE));
81-
cliOptions.add(new CliOption(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING_DESC,
82-
BooleanProperty.TYPE));
83-
cliOptions.add(new CliOption(FULL_JAVA_UTIL, "whether to use fully qualified name for classes under java.util",
84-
BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString()));
79+
cliOptions.add(CliOption.newBoolean(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC));
80+
cliOptions.add(CliOption.newBoolean(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, CodegenConstants
81+
.SERIALIZE_BIG_DECIMAL_AS_STRING_DESC));
82+
cliOptions.add(CliOption.newBoolean(FULL_JAVA_UTIL, "whether to use fully qualified name for classes under java.util"));
8583

8684
supportedLibraries.put(DEFAULT_LIBRARY, "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2");
8785
supportedLibraries.put("feign", "HTTP client: Netflix Feign 8.1.1");
@@ -478,11 +476,13 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
478476
model.imports.add("JsonSerialize");
479477
}
480478
}
479+
481480
if(model.isEnum == null || model.isEnum) {
482481
// needed by all pojos, but not enums
483482
model.imports.add("ApiModelProperty");
484483
model.imports.add("ApiModel");
485-
model.imports.add("Objects");
484+
// comment out below as it's in the model template
485+
//model.imports.add("Objects");
486486

487487
final String lib = getLibrary();
488488
if(StringUtils.isEmpty(lib) || "feign".equals(lib) || "jersey2".equals(lib)) {

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ public PerlClientCodegen() {
7474
cliOptions.clear();
7575
cliOptions.add(new CliOption(MODULE_NAME, "Perl module name (convention: CamelCase).").defaultValue("SwaggerClient"));
7676
cliOptions.add(new CliOption(MODULE_VERSION, "Perl module version.").defaultValue("1.0.0"));
77-
cliOptions.add(new CliOption(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
78-
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC, BooleanProperty.TYPE));
79-
cliOptions.add(new CliOption(CodegenConstants.ENSURE_UNIQUE_PARAMS, CodegenConstants.ENSURE_UNIQUE_PARAMS_DESC,
80-
BooleanProperty.TYPE));
77+
cliOptions.add(CliOption.newBoolean(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
78+
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString()));
79+
cliOptions.add(CliOption.newBoolean(CodegenConstants.ENSURE_UNIQUE_PARAMS, CodegenConstants
80+
.ENSURE_UNIQUE_PARAMS_DESC).defaultValue(Boolean.TRUE.toString()));
8181

8282
}
8383

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ public PythonClientCodegen() {
5858
"and", "del", "from", "not", "while", "as", "elif", "global", "or", "with",
5959
"assert", "else", "if", "pass", "yield", "break", "except", "import",
6060
"print", "class", "exec", "in", "raise", "continue", "finally", "is",
61-
"return", "def", "for", "lambda", "try"));
61+
"return", "def", "for", "lambda", "try", "self"));
6262

6363
cliOptions.clear();
6464
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "python package name (convention: snake_case).")
6565
.defaultValue("swagger_client"));
6666
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "python package version.")
6767
.defaultValue("1.0.0"));
68-
cliOptions.add(new CliOption(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
69-
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC, BooleanProperty.TYPE));
68+
cliOptions.add(CliOption.newBoolean(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
69+
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString()));
7070
}
7171

7272
@Override

modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package {{package}};
22

3+
import java.util.Objects;
34
{{#imports}}import {{import}};
45
{{/imports}}
56

modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/model.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package {{package}};
22

3+
import java.util.Objects;
34
{{#imports}}import {{import}};
45
{{/imports}}
56

0 commit comments

Comments
 (0)