Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add option to set recursion limit
  • Loading branch information
wing328 committed Sep 23, 2020
commit 79e83eed87a42ba8e6afdffc4ad7ae03c5c57689
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
public static final String DEFAULT_LIBRARY = "urllib3";
// nose is a python testing framework, we use pytest if USE_NOSE is unset
public static final String USE_NOSE = "useNose";
public static final String SET_RECURSION_LIMIT = "setRecursionLimit";

protected String packageName = "openapi_client";
protected String packageVersion = "1.0.0";
Expand Down Expand Up @@ -184,6 +185,7 @@ public PythonClientCodegen() {
.defaultValue(Boolean.FALSE.toString()));
cliOptions.add(CliOption.newBoolean(USE_NOSE, "use the nose test framework").
defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(SET_RECURSION_LIMIT, "Set recursion limit. If not, using the system default value."));

supportedLibraries.put("urllib3", "urllib3-based client");
supportedLibraries.put("asyncio", "Asyncio-based client (python 3.5+)");
Expand Down Expand Up @@ -253,6 +255,15 @@ public void processOpts() {
setUseNose((String) additionalProperties.get(USE_NOSE));
}

// check to see if setRecursionLimit is set and whether it's an integer
if (additionalProperties.containsKey(SET_RECURSION_LIMIT)) {
try {
Integer.parseInt((String)additionalProperties.get(SET_RECURSION_LIMIT));
} catch(NumberFormatException | NullPointerException e) {
throw new IllegalArgumentException("setRecursionLimit must be an integer, e.g. 2000.");
}
}

String readmePath = "README.md";
String readmeTemplate = "README.mustache";
if (generateSourceCodeOnly) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ from {{packageName}}.exceptions import ApiException
# import models into sdk package
{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}}
{{/model}}{{/models}}
{{#setRecursionLimit}}

__import__('sys').setrecursionlimit({{{.}}})
{{/setRecursionLimit}}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ from {{packageName}}.exceptions import ApiAttributeError
from {{packageName}}.exceptions import ApiTypeError
from {{packageName}}.exceptions import ApiValueError
from {{packageName}}.exceptions import ApiKeyError
from {{packageName}}.exceptions import ApiException
from {{packageName}}.exceptions import ApiException
{{#setRecursionLimit}}

__import__('sys').setrecursionlimit({{{.}}})
{{/setRecursionLimit}}