mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 11:32:44 +00:00
added python 2.7 and python 3.4 test environments
This commit is contained in:
@@ -70,6 +70,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
supportingFiles.add(new SupportingFile("setup.mustache", eggPackage, "setup.py"));
|
||||
supportingFiles.add(new SupportingFile("swagger.mustache", invokerPackage, "swagger.py"));
|
||||
supportingFiles.add(new SupportingFile("rest.mustache", invokerPackage, "rest.py"));
|
||||
supportingFiles.add(new SupportingFile("util.mustache", invokerPackage, "util.py"));
|
||||
supportingFiles.add(new SupportingFile("__init__package.mustache", invokerPackage, "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("__init__model.mustache", modelPackage.replace('.', File.separatorChar), "__init__.py"));
|
||||
supportingFiles.add(new SupportingFile("__init__api.mustache", apiPackage.replace('.', File.separatorChar), "__init__.py"));
|
||||
|
||||
@@ -38,5 +38,22 @@ TODO
|
||||
|
||||
## Tests
|
||||
|
||||
TODO
|
||||
We use some external dependencies, multiple interpreters and code coverage analysis while running test suite.
|
||||
Our Makefile handles much of this for you as long as you're running it inside of a [virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/):
|
||||
|
||||
```sh
|
||||
$ make test
|
||||
[... magically installs dependencies and runs tests on your virtualenv]
|
||||
Ran 182 tests in 1.633s
|
||||
OK (SKIP=6)
|
||||
```
|
||||
|
||||
You can test in various python versions using:
|
||||
|
||||
```sh
|
||||
$ make test-all
|
||||
[... tox creates a virtualenv for every platform and runs tests inside of each]
|
||||
py27: commands succeeded
|
||||
py34: commands succeeded
|
||||
```
|
||||
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
"""Add all of the modules in the current directory to __all__"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
|
||||
{{#apiInfo}}{{#apis}}
|
||||
from .{{classVarName}} import {{classname}}
|
||||
# import apis into api package
|
||||
{{#apiInfo}}{{#apis}}from .{{classVarName}} import {{classname}}
|
||||
{{/apis}}{{/apiInfo}}
|
||||
|
||||
__all__ = []
|
||||
|
||||
for module in os.listdir(os.path.dirname(__file__)):
|
||||
if module != '__init__.py' and module[-3:] == '.py':
|
||||
__all__.append(module[:-3])
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
"""Add all of the modules in the current directory to __all__"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
|
||||
{{#models}}{{#model}}
|
||||
from .{{classVarName}} import {{classname}}
|
||||
# import models into model package
|
||||
{{#models}}{{#model}}from .{{classVarName}} import {{classname}}
|
||||
{{/model}}{{/models}}
|
||||
|
||||
__all__ = []
|
||||
|
||||
for module in os.listdir(os.path.dirname(__file__)):
|
||||
if module != '__init__.py' and module[-3:] == '.py':
|
||||
__all__.append(module[:-3])
|
||||
|
||||
@@ -1,24 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
"""Add all of the modules in the current directory to __all__"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
|
||||
# import models into package
|
||||
{{#models}}{{#model}}
|
||||
from .models.{{classVarName}} import {{classname}}
|
||||
# import models into sdk package
|
||||
{{#models}}{{#model}}from .models.{{classVarName}} import {{classname}}
|
||||
{{/model}}{{/models}}
|
||||
|
||||
# import apis into package
|
||||
{{#apiInfo}}{{#apis}}
|
||||
from .apis.{{classVarName}} import {{classname}}
|
||||
# import apis into sdk package
|
||||
{{#apiInfo}}{{#apis}}from .apis.{{classVarName}} import {{classname}}
|
||||
{{/apis}}{{/apiInfo}}
|
||||
|
||||
# import ApiClient
|
||||
from .swagger import ApiClient
|
||||
|
||||
__all__ = []
|
||||
|
||||
for module in os.listdir(os.path.dirname(__file__)):
|
||||
if module != '__init__.py' and module[-3:] == '.py':
|
||||
__all__.append(module[:-3])
|
||||
|
||||
@@ -19,31 +19,36 @@ Copyright 2015 Reverb Technologies, Inc.
|
||||
|
||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
# python 2 and python 3 compatibility library
|
||||
from six import iteritems
|
||||
|
||||
from ..util import remove_none
|
||||
|
||||
{{#operations}}
|
||||
class {{classname}}(object):
|
||||
|
||||
def __init__(self, api_client):
|
||||
self.api_client = api_client
|
||||
|
||||
self.api_client = api_client
|
||||
{{#operation}}
|
||||
def {{nickname}}(self, {{#requiredParams}}{{paramName}}{{#defaultValue}} = None{{/defaultValue}}, {{/requiredParams}}**kwargs):
|
||||
def {{nickname}}(self, {{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}**kwargs):
|
||||
"""
|
||||
{{{summary}}}
|
||||
{{{notes}}}
|
||||
|
||||
{{#allParams}}
|
||||
:param {{dataType}} {{paramName}}: {{{description}}} {{^optional}}(required){{/optional}}{{#optional}}(optional){{/optional}}
|
||||
{{#allParams}}:param {{dataType}} {{paramName}}: {{{description}}} {{#required}}(required){{/required}}{{#optional}}(optional){{/optional}}
|
||||
{{/allParams}}
|
||||
|
||||
:return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}
|
||||
"""
|
||||
|
||||
{{#allParams}}{{#required}}
|
||||
# verify the required parameter '{{paramName}}' is set
|
||||
if {{paramName}} is None:
|
||||
raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{nickname}}`")
|
||||
{{/required}}{{/allParams}}
|
||||
all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}]
|
||||
|
||||
params = locals()
|
||||
@@ -56,16 +61,11 @@ class {{classname}}(object):
|
||||
resource_path = '{{path}}'.replace('{format}', 'json')
|
||||
method = '{{httpMethod}}'
|
||||
|
||||
path_params = dict({{#pathParams}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/pathParams}})
|
||||
path_params = {k: v for k, v in iteritems(path_params) if v}
|
||||
query_params = dict({{#queryParams}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/queryParams}})
|
||||
query_params = {k: v for k, v in iteritems(query_params) if v}
|
||||
header_params = dict({{#headerParams}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/headerParams}})
|
||||
header_params = {k: v for k, v in iteritems(header_params) if v}
|
||||
form_params = dict({{#formParams}}{{^isFile}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/isFile}}{{/formParams}})
|
||||
form_params = {k: v for k, v in iteritems(form_params) if v}
|
||||
files = dict({{#formParams}}{{#isFile}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/isFile}}{{/formParams}})
|
||||
files = {k: v for k, v in iteritems(files) if v}
|
||||
path_params = remove_none(dict({{#pathParams}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/pathParams}}))
|
||||
query_params = remove_none(dict({{#queryParams}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/queryParams}}))
|
||||
header_params = remove_none(dict({{#headerParams}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/headerParams}}))
|
||||
form_params = remove_none(dict({{#formParams}}{{^isFile}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/isFile}}{{/formParams}}))
|
||||
files = remove_none(dict({{#formParams}}{{#isFile}}{{baseName}}=params.get('{{paramName}}'){{#hasMore}}, {{/hasMore}}{{/isFile}}{{/formParams}}))
|
||||
body_params = {{#bodyParam}}params.get('{{paramName}}'){{/bodyParam}}{{^bodyParam}}None{{/bodyParam}}
|
||||
|
||||
accepts = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
|
||||
@@ -79,7 +79,14 @@ class {{classname}}(object):
|
||||
response={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}})
|
||||
{{#returnType}}
|
||||
return response
|
||||
{{/returnType}}
|
||||
{{/operation}}
|
||||
{{/returnType}}{{/operation}}
|
||||
{{/operations}}
|
||||
{{newline}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ class {{classname}}(object):
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Swagger model
|
||||
@@ -34,22 +33,19 @@ class {{classname}}(object):
|
||||
:param dict attributeMap: The key is attribute name and the value is json key in definition.
|
||||
"""
|
||||
self.swagger_types = {
|
||||
{{#vars}}
|
||||
'{{name}}': '{{{datatype}}}'{{#hasMore}},
|
||||
{{/hasMore}}
|
||||
{{/vars}}{{newline}}
|
||||
{{#vars}}'{{name}}': '{{{datatype}}}'{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
}
|
||||
|
||||
self.attribute_map = {
|
||||
{{#vars}}
|
||||
'{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}}
|
||||
{{/vars}}
|
||||
{{#vars}}'{{name}}': '{{baseName}}'{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
}
|
||||
|
||||
{{#vars}}
|
||||
{{#description}}#{{description}}
|
||||
{{/description}}
|
||||
self.{{name}} = None # {{{datatype}}}
|
||||
{{#description}}# {{description}}{{/description}}
|
||||
self.{{name}} = None # {{{datatype}}}
|
||||
{{/vars}}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
||||
|
||||
|
||||
@@ -30,3 +30,11 @@ setup(
|
||||
)
|
||||
|
||||
{{/hasMore}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
from six import iteritems
|
||||
|
||||
def remove_none(obj):
|
||||
if isinstance(obj, (list, tuple, set)):
|
||||
return type(obj)(remove_none(x) for x in obj if x is not None)
|
||||
elif isinstance(obj, dict):
|
||||
return type(obj)((remove_none(k), remove_none(v))
|
||||
for k, v in iteritems(obj) if k is not None and v is not None)
|
||||
else:
|
||||
return obj
|
||||
|
||||
|
||||
def inspect_vars(obj):
|
||||
if not hasattr(obj, '__dict__'):
|
||||
return obj
|
||||
else:
|
||||
return {k: inspect_vars(getattr(obj, k)) for k in dir(obj)}
|
||||
Reference in New Issue
Block a user