remove unnecessary changes for python codegen

This commit is contained in:
wing328
2016-08-31 15:49:22 +08:00
parent 2ced9e1deb
commit ebfddd0a58
7 changed files with 38 additions and 20 deletions

View File

@@ -127,4 +127,6 @@ public class CodegenConstants {
public static final String GENERATE_MODEL_TESTS = "generateModelTests";
public static final String GENERATE_MODEL_TESTS_DESC = "Specifies that model tests are to be generated.";
public static final String HIDE_GENERATION_TIMESTAMP = "hideGenerationTimestamp";
public static final String HIDE_GENERATION_TIMESTAMP_DESC = "Hides the generation timestamp.";
}

View File

@@ -507,6 +507,13 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
bundle.put("modelPackage", config.modelPackage());
List<CodegenSecurity> authMethods = config.fromSecurity(swagger.getSecurityDefinitions());
if (authMethods != null && !authMethods.isEmpty()) {
// sort auth methods to maintain the same order
Collections.sort(authMethods, new Comparator<CodegenSecurity>() {
@Override
public int compare(CodegenSecurity one, CodegenSecurity another) {
return ObjectUtils.compare(one.name, another.name);
}
});
bundle.put("authMethods", authMethods);
bundle.put("hasAuthMethods", true);
}

View File

@@ -114,6 +114,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
.defaultValue("1.0.0"));
cliOptions.add(CliOption.newBoolean(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString()));
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
.defaultValue(Boolean.TRUE.toString()));
}
@Override
@@ -139,6 +141,11 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
setPackageVersion("1.0.0");
}
// default HIDE_GENERATION_TIMESTAMP to true
if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
}
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);