From 34b6587007722b3da62083bc151ac0d83f37a264 Mon Sep 17 00:00:00 2001 From: Vamshik Shetty Date: Thu, 14 Feb 2019 21:50:49 +0530 Subject: [PATCH 1/9] mustache files for submodules --- .../python/__init__api_submodule.mustache | 5 +++++ .../python/__init__model_submodule.mustache | 6 ++++++ .../python/__init__package_submodule.mustache | 20 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 modules/openapi-generator/src/main/resources/python/__init__api_submodule.mustache create mode 100644 modules/openapi-generator/src/main/resources/python/__init__model_submodule.mustache create mode 100644 modules/openapi-generator/src/main/resources/python/__init__package_submodule.mustache diff --git a/modules/openapi-generator/src/main/resources/python/__init__api_submodule.mustache b/modules/openapi-generator/src/main/resources/python/__init__api_submodule.mustache new file mode 100644 index 000000000000..14871d4c5691 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/__init__api_submodule.mustache @@ -0,0 +1,5 @@ + +# {{apiPackage}} +{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} +{{/apis}}{{/apiInfo}} + diff --git a/modules/openapi-generator/src/main/resources/python/__init__model_submodule.mustache b/modules/openapi-generator/src/main/resources/python/__init__model_submodule.mustache new file mode 100644 index 000000000000..72bae97e73f3 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/__init__model_submodule.mustache @@ -0,0 +1,6 @@ + +# {{modelPackage}} +{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}}{{/model}} +{{/models}} + + diff --git a/modules/openapi-generator/src/main/resources/python/__init__package_submodule.mustache b/modules/openapi-generator/src/main/resources/python/__init__package_submodule.mustache new file mode 100644 index 000000000000..ec2165f1864c --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/__init__package_submodule.mustache @@ -0,0 +1,20 @@ +# coding: utf-8 + +# flake8: noqa + +{{>partial_header}} + +from __future__ import absolute_import + +__version__ = "{{packageVersion}}" + +# import apis into sdk package +import {{apiPackage}} +{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} +{{/apis}}{{/apiInfo}} + + +# import models into sdk package +import {{modelPackage}} +{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}} +{{/model}}{{/models}} \ No newline at end of file From 6718e2dd28fe2673c31453b88ae7337c5cda664f Mon Sep 17 00:00:00 2001 From: Vamshik Shetty Date: Thu, 14 Feb 2019 21:51:32 +0530 Subject: [PATCH 2/9] package submodule file without apil cient --- .../src/main/resources/python/__init__package.mustache | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/python/__init__package.mustache b/modules/openapi-generator/src/main/resources/python/__init__package.mustache index a21c6dbac9dc..ab8f8e8fb1b5 100644 --- a/modules/openapi-generator/src/main/resources/python/__init__package.mustache +++ b/modules/openapi-generator/src/main/resources/python/__init__package.mustache @@ -9,11 +9,13 @@ from __future__ import absolute_import __version__ = "{{packageVersion}}" # import apis into sdk package +import {{apiPackage}} {{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} {{/apis}}{{/apiInfo}} # import ApiClient from {{packageName}}.api_client import ApiClient from {{packageName}}.configuration import Configuration # import models into sdk package +import {{modelPackage}} {{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}} {{/model}}{{/models}} \ No newline at end of file From e44d3db46da0ca15d0d44b7f013a39e68cfb9e86 Mon Sep 17 00:00:00 2001 From: Vamshik Shetty Date: Thu, 14 Feb 2019 21:52:38 +0530 Subject: [PATCH 3/9] merge File content function added --- .../codegen/AbstractGenerator.java | 25 +++++++++++++++++++ .../codegen/DefaultGenerator.java | 6 ++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/AbstractGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/AbstractGenerator.java index 8a3c8b09e502..5630fb2dde4a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/AbstractGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/AbstractGenerator.java @@ -48,6 +48,31 @@ public File writeToFile(String filename, String contents) throws IOException { return output; } + public String mergeFileContent(String fileName, String content) throws IOException { + + File f1 = new File(fileName); + + if(!f1.exists()){ + return content; + } + + FileReader fileReader = new FileReader(f1); + BufferedReader bufferedReader = new BufferedReader(fileReader); + String line,existingContent = ""; + + while((line = bufferedReader.readLine()) != null) { + if(existingContent=="") + existingContent = line; + else + existingContent += System.lineSeparator() + line; + } + + if(!existingContent.isEmpty()) { + content = existingContent + System.lineSeparator() + content; + } + return content; + } + public String readTemplate(String name) { try { Reader reader = getTemplateReader(name); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 34c5026f64ff..cfb23e015ce3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -712,7 +712,11 @@ public Reader getTemplate(String name) { .defaultValue("") .compile(template); - writeToFile(outputFilename, tmpl.execute(bundle)); + String contents = tmpl.execute(bundle); + if(support.merge) + contents = mergeFileContent(outputFilename, contents); + writeToFile(outputFilename, contents); + File written = new File(outputFilename); files.add(written); if (config.isEnablePostProcessFile()) { From 111703ea069eb66b4e3344c26556e8065fa5b7f2 Mon Sep 17 00:00:00 2001 From: Vamshik Shetty Date: Thu, 14 Feb 2019 21:53:37 +0530 Subject: [PATCH 4/9] third variant of SupportingFile for content that needs to be merged --- .../java/org/openapitools/codegen/SupportingFile.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/SupportingFile.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/SupportingFile.java index 84e88afcd750..d6a37c78ae21 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/SupportingFile.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/SupportingFile.java @@ -22,6 +22,9 @@ public class SupportingFile { public String folder; public String destinationFilename; + // to add details of submodule generated to main module + public boolean merge = false; + public SupportingFile(String templateFile, String destinationFilename) { this(templateFile, "", destinationFilename); } @@ -32,6 +35,13 @@ public SupportingFile(String templateFile, String folder, String destinationFile this.destinationFilename = destinationFilename; } + public SupportingFile(String templateFile, String folder, String destinationFilename, boolean merge) { + this.templateFile = templateFile; + this.folder = folder; + this.destinationFilename = destinationFilename; + this.merge = merge; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); From 5b4438353b3c22fe91907fb8a937b7078b00831f Mon Sep 17 00:00:00 2001 From: Vamshik Shetty Date: Thu, 14 Feb 2019 21:54:40 +0530 Subject: [PATCH 5/9] invoker python constant added --- .../languages/PythonClientCodegen.java | 52 +++++++++++++++---- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java index 24803f481904..0973476bc701 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java @@ -40,6 +40,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig public static final String DEFAULT_LIBRARY = "urllib3"; protected String packageName; // e.g. petstore_api + protected String invokerPackage; protected String packageVersion; protected String projectName; // for setup.py, e.g. petstore-api protected String packageUrl; @@ -192,11 +193,22 @@ public void processOpts() { setPackageVersion("1.0.0"); } + if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { + setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));} + else { + setInvokerPackage(""); + } + Boolean generateSourceCodeOnly = false; if (additionalProperties.containsKey(CodegenConstants.SOURCECODEONLY_GENERATION)) { generateSourceCodeOnly = Boolean.valueOf(additionalProperties.get(CodegenConstants.SOURCECODEONLY_GENERATION).toString()); } + Boolean isSubModule = false; + if(packageName != null) + if(packageName.contains(".")) + isSubModule = true; + additionalProperties.put(CodegenConstants.PROJECT_NAME, projectName); additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion); @@ -234,7 +246,7 @@ public void processOpts() { supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml")); supportingFiles.add(new SupportingFile("setup.mustache", "", "setup.py")); } - supportingFiles.add(new SupportingFile("configuration.mustache", packagePath(), "configuration.py")); + supportingFiles.add(new SupportingFile("__init__package.mustache", packagePath(), "__init__.py")); supportingFiles.add(new SupportingFile("__init__model.mustache", packagePath() + File.separatorChar + modelPackage, "__init__.py")); supportingFiles.add(new SupportingFile("__init__api.mustache", packagePath() + File.separatorChar + apiPackage, "__init__.py")); @@ -243,16 +255,24 @@ public void processOpts() { supportingFiles.add(new SupportingFile("__init__test.mustache", testFolder, "__init__.py")); } - supportingFiles.add(new SupportingFile("api_client.mustache", packagePath(), "api_client.py")); + if(!isSubModule){ + supportingFiles.add(new SupportingFile("api_client.mustache", packagePath(), "api_client.py")); + supportingFiles.add(new SupportingFile("configuration.mustache", packagePath(), "configuration.py")); - if ("asyncio".equals(getLibrary())) { - supportingFiles.add(new SupportingFile("asyncio/rest.mustache", packagePath(), "rest.py")); - additionalProperties.put("asyncio", "true"); - } else if ("tornado".equals(getLibrary())) { - supportingFiles.add(new SupportingFile("tornado/rest.mustache", packagePath(), "rest.py")); - additionalProperties.put("tornado", "true"); - } else { - supportingFiles.add(new SupportingFile("rest.mustache", packagePath(), "rest.py")); + if ("asyncio".equals(getLibrary())) { + supportingFiles.add(new SupportingFile("asyncio/rest.mustache", packagePath(), "rest.py")); + additionalProperties.put("asyncio", "true"); + } else if ("tornado".equals(getLibrary())) { + supportingFiles.add(new SupportingFile("tornado/rest.mustache", packagePath(), "rest.py")); + additionalProperties.put("tornado", "true"); + } else { + supportingFiles.add(new SupportingFile("rest.mustache", packagePath(), "rest.py")); + } + } + if(isSubModule){ + // If file already exists merge i.e merge API and MODELS data of submodule __init__ with main module __init__ + supportingFiles.add(new SupportingFile("__init__api_submodule.mustache", invokerPath() + File.separatorChar + apiPackage, "__init__.py", true)); + supportingFiles.add(new SupportingFile("__init__model_submodule.mustache", invokerPath() + File.separatorChar + modelPackage, "__init__.py", true)); } modelPackage = packageName + "." + modelPackage; @@ -570,6 +590,10 @@ public void setPackageName(String packageName) { this.packageName = packageName; } + public void setInvokerPackage(String invokerPackage) { + this.invokerPackage = invokerPackage; + } + public void setProjectName(String projectName) { this.projectName = projectName; } @@ -583,9 +607,15 @@ public void setPackageUrl(String packageUrl) { } public String packagePath() { - return packageName.replace('.', File.separatorChar); + return this.packageName.replace('.', File.separatorChar); + } + + public String invokerPath() { + return this.invokerPackage.replace('.', File.separatorChar); } + + /** * Generate Python package name from String `packageName` *

From 6002062dae5fdf3c17bcf0aeddc6fd4b12bc4193 Mon Sep 17 00:00:00 2001 From: Vamshik Shetty Date: Fri, 15 Feb 2019 00:31:32 +0530 Subject: [PATCH 6/9] changes created after running test cases --- .../petstore-security-test/python/README.md | 2 + .../python/docs/FakeApi.md | 1 + .../python/petstore_api/__init__.py | 2 + .../python/petstore_api/api_client.py | 16 ++++-- .../python/petstore_api/configuration.py | 57 +++++++++++++++++-- .../petstore/python/petstore_api/__init__.py | 2 + .../petstore/python/petstore_api/__init__.py | 2 + 7 files changed, 72 insertions(+), 10 deletions(-) diff --git a/samples/client/petstore-security-test/python/README.md b/samples/client/petstore-security-test/python/README.md index 72ef2b830b1c..d1ed889e202c 100644 --- a/samples/client/petstore-security-test/python/README.md +++ b/samples/client/petstore-security-test/python/README.md @@ -51,6 +51,7 @@ import petstore_api from petstore_api.rest import ApiException from pprint import pprint + # create an instance of the API class api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration)) test_code_inject____end____rn_n_r = 'test_code_inject____end____rn_n_r_example' # str | To test code injection */ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r (optional) @@ -86,6 +87,7 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key */ ' " =end -- \r\n \n \r - **Location**: HTTP header + ## petstore_auth - **Type**: OAuth diff --git a/samples/client/petstore-security-test/python/docs/FakeApi.md b/samples/client/petstore-security-test/python/docs/FakeApi.md index 559e39fb202d..42a1ec123079 100644 --- a/samples/client/petstore-security-test/python/docs/FakeApi.md +++ b/samples/client/petstore-security-test/python/docs/FakeApi.md @@ -15,6 +15,7 @@ To test code injection */ ' \" =end -- \\r\\n \\n \\r To test code injection */ ' \" =end -- \\r\\n \\n \\r ### Example + ```python from __future__ import print_function import time diff --git a/samples/client/petstore-security-test/python/petstore_api/__init__.py b/samples/client/petstore-security-test/python/petstore_api/__init__.py index 93e0a9fa9dce..1d2c132a6be5 100644 --- a/samples/client/petstore-security-test/python/petstore_api/__init__.py +++ b/samples/client/petstore-security-test/python/petstore_api/__init__.py @@ -18,10 +18,12 @@ __version__ = "1.0.0" # import apis into sdk package +import petstore_api.api from petstore_api.api.fake_api import FakeApi # import ApiClient from petstore_api.api_client import ApiClient from petstore_api.configuration import Configuration # import models into sdk package +import petstore_api.models from petstore_api.models.model_return import ModelReturn diff --git a/samples/client/petstore-security-test/python/petstore_api/api_client.py b/samples/client/petstore-security-test/python/petstore_api/api_client.py index acf72f112eaa..6132154e1b1f 100644 --- a/samples/client/petstore-security-test/python/petstore_api/api_client.py +++ b/samples/client/petstore-security-test/python/petstore_api/api_client.py @@ -110,7 +110,7 @@ def __call_api( query_params=None, header_params=None, body=None, post_params=None, files=None, response_type=None, auth_settings=None, _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None): + _preload_content=True, _request_timeout=None, _host=None): config = self.configuration @@ -157,7 +157,11 @@ def __call_api( body = self.sanitize_for_serialization(body) # request url - url = self.configuration.host + resource_path + if _host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path # perform request and return response response_data = self.request( @@ -290,7 +294,7 @@ def call_api(self, resource_path, method, body=None, post_params=None, files=None, response_type=None, auth_settings=None, async_req=None, _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None): + _preload_content=True, _request_timeout=None, _host=None): """Makes the HTTP request (synchronous) and returns deserialized data. To make an async_req request, set the async_req parameter. @@ -333,7 +337,7 @@ def call_api(self, resource_path, method, body, post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, - _preload_content, _request_timeout) + _preload_content, _request_timeout, _host) else: thread = self.pool.apply_async(self.__call_api, (resource_path, method, path_params, query_params, @@ -342,7 +346,9 @@ def call_api(self, resource_path, method, response_type, auth_settings, _return_http_data_only, collection_formats, - _preload_content, _request_timeout)) + _preload_content, + _request_timeout, + _host)) return thread def request(self, method, url, query_params=None, headers=None, diff --git a/samples/client/petstore-security-test/python/petstore_api/configuration.py b/samples/client/petstore-security-test/python/petstore_api/configuration.py index ec9b97540828..b7ae97b238d5 100644 --- a/samples/client/petstore-security-test/python/petstore_api/configuration.py +++ b/samples/client/petstore-security-test/python/petstore_api/configuration.py @@ -60,10 +60,8 @@ def __init__(self): self.username = "" # Password for HTTP basic authentication self.password = "" - - # access token for OAuth + # access token for OAuth/Bearer self.access_token = "" - # Logging Settings self.logger = {} self.logger["package_logger"] = logging.getLogger("petstore_api") @@ -223,7 +221,6 @@ def auth_settings(self): 'key': 'api_key */ ' " =end -- \r\n \n \r', 'value': self.get_api_key_with_prefix('api_key */ ' " =end -- \r\n \n \r') }, - 'petstore_auth': { 'type': 'oauth2', @@ -231,7 +228,6 @@ def auth_settings(self): 'key': 'Authorization', 'value': 'Bearer ' + self.access_token }, - } def to_debug_report(self): @@ -245,3 +241,54 @@ def to_debug_report(self): "Version of the API: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r\n"\ "SDK Package Version: 1.0.0".\ format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "//petstore.swagger.io */ ' " =end -- \r\n \n \r/v2 */ ' " =end -- \r\n \n \r", + 'description': "No description provided", + } + ] + + def get_host_from_settings(self, index, variables={}): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :return: URL based on host settings + """ + + servers = self.get_host_settings() + + # check array index out of bound + if index < 0 or index >= len(servers): + raise ValueError( + "Invalid index {} when selecting the host settings. Must be less than {}" # noqa: E501 + .format(index, len(servers))) + + server = servers[index] + url = server['url'] + + # go through variable and assign a value + for variable_name in server['variables']: + if variable_name in variables: + if variables[variable_name] in server['variables'][ + variable_name]['enum_values']: + url = url.replace("{" + variable_name + "}", + variables[variable_name]) + else: + raise ValueError( + "The variable `{}` in the host URL has invalid value {}. Must be {}." # noqa: E501 + .format( + variable_name, variables[variable_name], + server['variables'][variable_name]['enum_values'])) + else: + # use default value + url = url.replace( + "{" + variable_name + "}", + server['variables'][variable_name]['default_value']) + + return url diff --git a/samples/client/petstore/python/petstore_api/__init__.py b/samples/client/petstore/python/petstore_api/__init__.py index cf9b1b0db3f9..d81d8a98078b 100644 --- a/samples/client/petstore/python/petstore_api/__init__.py +++ b/samples/client/petstore/python/petstore_api/__init__.py @@ -17,6 +17,7 @@ __version__ = "1.0.0" # import apis into sdk package +import petstore_api.api from petstore_api.api.another_fake_api import AnotherFakeApi from petstore_api.api.fake_api import FakeApi from petstore_api.api.fake_classname_tags_123_api import FakeClassnameTags123Api @@ -28,6 +29,7 @@ from petstore_api.api_client import ApiClient from petstore_api.configuration import Configuration # import models into sdk package +import petstore_api.models from petstore_api.models.additional_properties_class import AdditionalPropertiesClass from petstore_api.models.animal import Animal from petstore_api.models.api_response import ApiResponse diff --git a/samples/openapi3/client/petstore/python/petstore_api/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/__init__.py index 4ee9bd7e0381..ca892618a88f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -17,6 +17,7 @@ __version__ = "1.0.0" # import apis into sdk package +import petstore_api.api from petstore_api.api.another_fake_api import AnotherFakeApi from petstore_api.api.default_api import DefaultApi from petstore_api.api.fake_api import FakeApi @@ -29,6 +30,7 @@ from petstore_api.api_client import ApiClient from petstore_api.configuration import Configuration # import models into sdk package +import petstore_api.models from petstore_api.models.additional_properties_class import AdditionalPropertiesClass from petstore_api.models.animal import Animal from petstore_api.models.api_response import ApiResponse From b517194c4f6dfba71fa4e6309aa3ec5f230d0924 Mon Sep 17 00:00:00 2001 From: Vamshik Shetty Date: Fri, 15 Feb 2019 00:46:19 +0530 Subject: [PATCH 7/9] adding support to make entire client binding a submodule --- .../org/openapitools/codegen/languages/PythonClientCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java index 0973476bc701..3603af6f4465 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java @@ -206,7 +206,7 @@ public void processOpts() { Boolean isSubModule = false; if(packageName != null) - if(packageName.contains(".")) + if(packageName.contains(".") && invokerPackage != "") isSubModule = true; additionalProperties.put(CodegenConstants.PROJECT_NAME, projectName); From f7573f56bbdca36c70cd7c32a41bd4b6669f2757 Mon Sep 17 00:00:00 2001 From: Vamshik Shetty Date: Fri, 15 Feb 2019 10:35:54 +0530 Subject: [PATCH 8/9] avoiding interdependency --- .../openapi-generator/src/main/resources/python/api.mustache | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/python/api.mustache b/modules/openapi-generator/src/main/resources/python/api.mustache index 5e8027e839f0..3e4170a1f75a 100644 --- a/modules/openapi-generator/src/main/resources/python/api.mustache +++ b/modules/openapi-generator/src/main/resources/python/api.mustache @@ -9,7 +9,7 @@ import re # noqa: F401 # python 2 and python 3 compatibility library import six -from {{packageName}}.api_client import ApiClient + {{#operations}} @@ -22,6 +22,7 @@ class {{classname}}(object): def __init__(self, api_client=None): if api_client is None: + from {{packageName}}.api_client import ApiClient api_client = ApiClient() self.api_client = api_client {{#operation}} From d01e9b9a69fb9f52b9bca1c016ca75d2bf9ad6fe Mon Sep 17 00:00:00 2001 From: Vamshik Shetty Date: Fri, 15 Feb 2019 10:39:41 +0530 Subject: [PATCH 9/9] running bin shell scripts --- .../petstore-security-test/python/petstore_api/api/fake_api.py | 3 ++- .../petstore/python/petstore_api/api/another_fake_api.py | 3 ++- samples/client/petstore/python/petstore_api/api/fake_api.py | 3 ++- .../python/petstore_api/api/fake_classname_tags_123_api.py | 3 ++- samples/client/petstore/python/petstore_api/api/pet_api.py | 3 ++- samples/client/petstore/python/petstore_api/api/store_api.py | 3 ++- samples/client/petstore/python/petstore_api/api/user_api.py | 3 ++- .../petstore/python/petstore_api/api/another_fake_api.py | 3 ++- .../client/petstore/python/petstore_api/api/default_api.py | 3 ++- .../client/petstore/python/petstore_api/api/fake_api.py | 3 ++- .../python/petstore_api/api/fake_classname_tags_123_api.py | 3 ++- .../client/petstore/python/petstore_api/api/pet_api.py | 3 ++- .../client/petstore/python/petstore_api/api/store_api.py | 3 ++- .../client/petstore/python/petstore_api/api/user_api.py | 3 ++- 14 files changed, 28 insertions(+), 14 deletions(-) diff --git a/samples/client/petstore-security-test/python/petstore_api/api/fake_api.py b/samples/client/petstore-security-test/python/petstore_api/api/fake_api.py index 24a1c4fe1b94..179edc325015 100644 --- a/samples/client/petstore-security-test/python/petstore_api/api/fake_api.py +++ b/samples/client/petstore-security-test/python/petstore_api/api/fake_api.py @@ -18,7 +18,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class FakeApi(object): @@ -30,6 +30,7 @@ class FakeApi(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/client/petstore/python/petstore_api/api/another_fake_api.py b/samples/client/petstore/python/petstore_api/api/another_fake_api.py index 9fd3f816b9ca..650a28a81795 100644 --- a/samples/client/petstore/python/petstore_api/api/another_fake_api.py +++ b/samples/client/petstore/python/petstore_api/api/another_fake_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class AnotherFakeApi(object): @@ -29,6 +29,7 @@ class AnotherFakeApi(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/client/petstore/python/petstore_api/api/fake_api.py b/samples/client/petstore/python/petstore_api/api/fake_api.py index c7405e51c381..5ba60bce7e31 100644 --- a/samples/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/client/petstore/python/petstore_api/api/fake_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class FakeApi(object): @@ -29,6 +29,7 @@ class FakeApi(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/client/petstore/python/petstore_api/api/fake_classname_tags_123_api.py b/samples/client/petstore/python/petstore_api/api/fake_classname_tags_123_api.py index dbf6ef3dfb37..c8ab93de808b 100644 --- a/samples/client/petstore/python/petstore_api/api/fake_classname_tags_123_api.py +++ b/samples/client/petstore/python/petstore_api/api/fake_classname_tags_123_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class FakeClassnameTags123Api(object): @@ -29,6 +29,7 @@ class FakeClassnameTags123Api(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/client/petstore/python/petstore_api/api/pet_api.py b/samples/client/petstore/python/petstore_api/api/pet_api.py index f29e7239666a..4f095c4df0a6 100644 --- a/samples/client/petstore/python/petstore_api/api/pet_api.py +++ b/samples/client/petstore/python/petstore_api/api/pet_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class PetApi(object): @@ -29,6 +29,7 @@ class PetApi(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/client/petstore/python/petstore_api/api/store_api.py b/samples/client/petstore/python/petstore_api/api/store_api.py index bd2677ef92bc..d055f3db2ce2 100644 --- a/samples/client/petstore/python/petstore_api/api/store_api.py +++ b/samples/client/petstore/python/petstore_api/api/store_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class StoreApi(object): @@ -29,6 +29,7 @@ class StoreApi(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/client/petstore/python/petstore_api/api/user_api.py b/samples/client/petstore/python/petstore_api/api/user_api.py index c27299309a6d..692ff6834aeb 100644 --- a/samples/client/petstore/python/petstore_api/api/user_api.py +++ b/samples/client/petstore/python/petstore_api/api/user_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class UserApi(object): @@ -29,6 +29,7 @@ class UserApi(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py index 782f7fd07b35..aa8eaa21891c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class AnotherFakeApi(object): @@ -29,6 +29,7 @@ class AnotherFakeApi(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py index 035f2697a667..90917b2a2b19 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class DefaultApi(object): @@ -29,6 +29,7 @@ class DefaultApi(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index 7dbc1cdfc111..3f2b35b867d3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class FakeApi(object): @@ -29,6 +29,7 @@ class FakeApi(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags_123_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags_123_api.py index 80e03e6626ee..98b147980d0d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags_123_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags_123_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class FakeClassnameTags123Api(object): @@ -29,6 +29,7 @@ class FakeClassnameTags123Api(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py index 401ebb237209..a0eaf3b7a950 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class PetApi(object): @@ -29,6 +29,7 @@ class PetApi(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py index 5ef48fac2a78..164e76914ef1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class StoreApi(object): @@ -29,6 +29,7 @@ class StoreApi(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py index bb02a2a472cb..d2c07f75e968 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py @@ -17,7 +17,7 @@ # python 2 and python 3 compatibility library import six -from petstore_api.api_client import ApiClient + class UserApi(object): @@ -29,6 +29,7 @@ class UserApi(object): def __init__(self, api_client=None): if api_client is None: + from petstore_api.api_client import ApiClient api_client = ApiClient() self.api_client = api_client