Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions bin/configs/python-experimental.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/python-experimental/
templateDir: modules/openapi-generator/src/main/resources/python
additionalProperties:
packageName: petstore_api
setRecursionLimit: "1234"
1 change: 1 addition & 0 deletions docs/generators/python-experimental.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ sidebar_label: python-experimental
|packageUrl|python package URL.| |null|
|packageVersion|python package version.| |1.0.0|
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
|setRecursionLimit|Set recursion limit. If not set, use the system default value.| |null|
|useNose|use the nose test framework| |false|

## IMPORT MAPPING
Expand Down
1 change: 1 addition & 0 deletions docs/generators/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ sidebar_label: python
|packageUrl|python package URL.| |null|
|packageVersion|python package version.| |1.0.0|
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
|setRecursionLimit|Set recursion limit. If not set, use the system default value.| |null|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|useNose|use the nose test framework| |false|

Expand Down
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 set, use 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}}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class PythonClientOptionsProvider implements OptionsProvider {
public static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
public static final String PACKAGE_URL_VALUE = "";
public static final String USE_NOSE_VALUE = "false";
public static final String SET_RECURSION_LIMIT = "1200";

@Override
public String getLanguage() {
Expand All @@ -47,6 +48,7 @@ public Map<String, String> createOptions() {
.put(CodegenConstants.SOURCECODEONLY_GENERATION, "false")
.put(CodegenConstants.LIBRARY, "urllib3")
.put(PythonClientCodegen.USE_NOSE, USE_NOSE_VALUE)
.put(PythonClientCodegen.SET_RECURSION_LIMIT, SET_RECURSION_LIMIT)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
from petstore_api.exceptions import ApiTypeError
from petstore_api.exceptions import ApiValueError
from petstore_api.exceptions import ApiKeyError
from petstore_api.exceptions import ApiException
from petstore_api.exceptions import ApiException
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
from x_auth_id_alias.exceptions import ApiTypeError
from x_auth_id_alias.exceptions import ApiValueError
from x_auth_id_alias.exceptions import ApiKeyError
from x_auth_id_alias.exceptions import ApiException
from x_auth_id_alias.exceptions import ApiException
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
from dynamic_servers.exceptions import ApiTypeError
from dynamic_servers.exceptions import ApiValueError
from dynamic_servers.exceptions import ApiKeyError
from dynamic_servers.exceptions import ApiException
from dynamic_servers.exceptions import ApiException
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@
from petstore_api.exceptions import ApiTypeError
from petstore_api.exceptions import ApiValueError
from petstore_api.exceptions import ApiKeyError
from petstore_api.exceptions import ApiException
from petstore_api.exceptions import ApiException

__import__('sys').setrecursionlimit(1234)
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Generated by: https://openapi-generator.tech
"""

import sys
from collections import namedtuple
import unittest
import json
Expand Down Expand Up @@ -98,6 +99,12 @@ def test_boolean(self):
assert endpoint.openapi_types['body'] == (bool,)
assert endpoint.settings['response_type'] == (bool,)

def test_setrecursionlimit(self):
"""Test case for setrecursionlimit

"""
assert sys.getrecursionlimit() == 1234

def test_fake_health_get(self):
"""Test case for fake_health_get

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,20 @@ def setUp(self):
def tearDown(self):
pass

def test_setrecursionlimit(self):
"""Test case for setrecursionlimit

"""
assert sys.getrecursionlimit() == 1234

def testShape(self):
"""Test Shape"""
from petstore_api.model import complex_quadrilateral
from petstore_api.model import simple_quadrilateral
from petstore_api.model import equilateral_triangle
from petstore_api.model import isosceles_triangle
from petstore_api.model import scalene_triangle

tri = triangle.Triangle(
shape_type="Triangle",
triangle_type="EquilateralTriangle"
Expand Down