Skip to content
Merged
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
2 changes: 1 addition & 1 deletion bin/configs/python-flask.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
generatorName: python-flask
outputDir: samples/server/petstore/python-flask
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
inputSpec: modules/openapi-generator/src/test/resources/2_0/python-flask/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/python-flask
Original file line number Diff line number Diff line change
Expand Up @@ -1981,4 +1981,17 @@ public String toEnumValue(String value, String datatype) {
public String toEnumDefaultValue(String value, String datatype) {
return value;
}

/**
* checks if the data should be classified as "string" in enum
* e.g. double in C# needs to be double-quoted (e.g. "2.8") by treating it as a string
* In the future, we may rename this function to "isEnumString"
*
* @param dataType data type
* @return true if it's a enum string
*/
@Override
public boolean isDataTypeString(String dataType) {
return "str".equals(dataType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,9 @@

package org.openapitools.codegen.languages;

import static org.openapitools.codegen.utils.StringUtils.camelize;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;

import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
Expand Down Expand Up @@ -69,6 +61,8 @@
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.security.SecurityScheme;

import static org.openapitools.codegen.utils.StringUtils.*;

public abstract class AbstractPythonConnexionServerCodegen extends AbstractPythonCodegen implements CodegenConfig {
private static class PythonBooleanSerializer extends JsonSerializer<Boolean> {
@Override
Expand Down Expand Up @@ -178,7 +172,7 @@ public AbstractPythonConnexionServerCodegen(String templateDirectory, boolean fi
cliOptions.add(new CliOption(USE_PYTHON_SRC_ROOT_IN_IMPORTS, "include pythonSrcRoot in import namespaces.").
defaultValue("false"));
cliOptions.add(new CliOption(MOVE_TESTS_UNDER_PYTHON_SRC_ROOT, "generates test under the pythonSrcRoot folder.")
.defaultValue("false"));
.defaultValue("false"));
}

protected void addSupportingFiles() {
Expand Down Expand Up @@ -333,7 +327,6 @@ public String toApiName(String name) {
}



@Override
public String toApiTestFilename(String name) {
return "test_" + toApiFilename(name);
Expand Down Expand Up @@ -636,12 +629,6 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
postProcessPattern(property.pattern, property.vendorExtensions);
}

@Override
public ModelsMap postProcessModels(ModelsMap objs) {
// process enum in models
return postProcessModelsEnum(objs);
}

@Override
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
Map<String, ModelsMap> result = super.postProcessAllModels(objs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,20 +464,6 @@ protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Sc
}
}


/**
* checks if the data should be classified as "string" in enum
* e.g. double in C# needs to be double-quoted (e.g. "2.8") by treating it as a string
* In the future, we may rename this function to "isEnumString"
*
* @param dataType data type
* @return true if it's a enum string
*/
@Override
public boolean isDataTypeString(String dataType) {
return "str".equals(dataType);
}

@Override
public String escapeReservedWord(String name) {
if (this.reservedWordsMappings().containsKey(name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class {{classname}}(Model):
allowed enum values
"""
{{#enumVars}}
{{name}} = {{{value}}}{{^-last}}
{{{name}}} = {{{value}}}{{^-last}}
{{/-last}}
{{/enumVars}}
{{/allowableValues}}
Expand Down
Loading