mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-10 15:02:48 +00:00
Fix/remove support python2 option in flask aiohttp generators (#13585)
* fix: remove option supportPython2.
[python-flask][python-aiohttp][python-blueplanet]
* fix: update samples
* test only python servers
* fix(tests): downgrade pytest version to ensure compatibility with python3.6 [python-flask][python-aiohttp]
* Revert "fix(tests): downgrade pytest version to ensure compatibility with python3.6 [python-flask][python-aiohttp]"
This reverts commit 9f47db2f87.
* test in circlei
* run commands directly
* test in node 1
* update makefile
* fix Makefile
* fix test
* revert some changes, remove python server tests from travis
Co-authored-by: Kevin Bannier <kevinbannier1@gmail.com>
This commit is contained in:
@@ -34,7 +34,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|serverPort|TCP port to listen to in app.run| |8080|
|
|serverPort|TCP port to listen to in app.run| |8080|
|
||||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||||
|supportPython2|support python2. This option has been deprecated and will be removed in the 5.x release.| |false|
|
|
||||||
|testsUsePythonSrcRoot|generates test under the pythonSrcRoot folder.| |false|
|
|testsUsePythonSrcRoot|generates test under the pythonSrcRoot folder.| |false|
|
||||||
|useNose|use the nose test framework| |false|
|
|useNose|use the nose test framework| |false|
|
||||||
|usePythonSrcRootInImports|include pythonSrcRoot in import namespaces.| |false|
|
|usePythonSrcRootInImports|include pythonSrcRoot in import namespaces.| |false|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ title: Documentation for the python-blueplanet Generator
|
|||||||
| generator stability | STABLE | |
|
| generator stability | STABLE | |
|
||||||
| generator type | SERVER | |
|
| generator type | SERVER | |
|
||||||
| generator language | Python | |
|
| generator language | Python | |
|
||||||
| generator language version | 2.7+ and 3.5.2+ | |
|
| generator language version | 3.5.2+ | |
|
||||||
| generator default templating engine | mustache | |
|
| generator default templating engine | mustache | |
|
||||||
| helpTxt | Generates a Python server library using the Connexion project. By default, it will also generate service classes -- which you can disable with the `-Dnoservice` environment variable. | |
|
| helpTxt | Generates a Python server library using the Connexion project. By default, it will also generate service classes -- which you can disable with the `-Dnoservice` environment variable. | |
|
||||||
|
|
||||||
@@ -34,7 +34,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|serverPort|TCP port to listen to in app.run| |8080|
|
|serverPort|TCP port to listen to in app.run| |8080|
|
||||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||||
|supportPython2|support python2. This option has been deprecated and will be removed in the 5.x release.| |false|
|
|
||||||
|testsUsePythonSrcRoot|generates test under the pythonSrcRoot folder.| |false|
|
|testsUsePythonSrcRoot|generates test under the pythonSrcRoot folder.| |false|
|
||||||
|useNose|use the nose test framework| |false|
|
|useNose|use the nose test framework| |false|
|
||||||
|usePythonSrcRootInImports|include pythonSrcRoot in import namespaces.| |false|
|
|usePythonSrcRootInImports|include pythonSrcRoot in import namespaces.| |false|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ title: Documentation for the python-flask Generator
|
|||||||
| generator stability | STABLE | |
|
| generator stability | STABLE | |
|
||||||
| generator type | SERVER | |
|
| generator type | SERVER | |
|
||||||
| generator language | Python | |
|
| generator language | Python | |
|
||||||
| generator language version | 2.7 and 3.5.2+ | |
|
| generator language version | 3.5.2+ | |
|
||||||
| generator default templating engine | mustache | |
|
| generator default templating engine | mustache | |
|
||||||
| helpTxt | Generates a Python server library using the Connexion project. By default, it will also generate service classes -- which you can disable with the `-Dnoservice` environment variable. | |
|
| helpTxt | Generates a Python server library using the Connexion project. By default, it will also generate service classes -- which you can disable with the `-Dnoservice` environment variable. | |
|
||||||
|
|
||||||
@@ -34,7 +34,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|serverPort|TCP port to listen to in app.run| |8080|
|
|serverPort|TCP port to listen to in app.run| |8080|
|
||||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||||
|supportPython2|support python2. This option has been deprecated and will be removed in the 5.x release.| |false|
|
|
||||||
|testsUsePythonSrcRoot|generates test under the pythonSrcRoot folder.| |false|
|
|testsUsePythonSrcRoot|generates test under the pythonSrcRoot folder.| |false|
|
||||||
|useNose|use the nose test framework| |false|
|
|useNose|use the nose test framework| |false|
|
||||||
|usePythonSrcRootInImports|include pythonSrcRoot in import namespaces.| |false|
|
|usePythonSrcRootInImports|include pythonSrcRoot in import namespaces.| |false|
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
|||||||
|
|
||||||
public static final String CONTROLLER_PACKAGE = "controllerPackage";
|
public static final String CONTROLLER_PACKAGE = "controllerPackage";
|
||||||
public static final String DEFAULT_CONTROLLER = "defaultController";
|
public static final String DEFAULT_CONTROLLER = "defaultController";
|
||||||
public static final String SUPPORT_PYTHON2 = "supportPython2";
|
|
||||||
public static final String FEATURE_CORS = "featureCORS";
|
public static final String FEATURE_CORS = "featureCORS";
|
||||||
// nose is a python testing framework, we use pytest if USE_NOSE is unset
|
// 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 USE_NOSE = "useNose";
|
||||||
@@ -152,8 +151,6 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
|||||||
defaultValue("controllers"));
|
defaultValue("controllers"));
|
||||||
cliOptions.add(new CliOption(DEFAULT_CONTROLLER, "default controller").
|
cliOptions.add(new CliOption(DEFAULT_CONTROLLER, "default controller").
|
||||||
defaultValue("default_controller"));
|
defaultValue("default_controller"));
|
||||||
cliOptions.add(new CliOption(SUPPORT_PYTHON2, "support python2. This option has been deprecated and will be removed in the 5.x release.").
|
|
||||||
defaultValue("false"));
|
|
||||||
cliOptions.add(new CliOption("serverPort", "TCP port to listen to in app.run").
|
cliOptions.add(new CliOption("serverPort", "TCP port to listen to in app.run").
|
||||||
defaultValue("8080"));
|
defaultValue("8080"));
|
||||||
cliOptions.add(CliOption.newBoolean(FEATURE_CORS, "use flask-cors for handling CORS requests").
|
cliOptions.add(CliOption.newBoolean(FEATURE_CORS, "use flask-cors for handling CORS requests").
|
||||||
@@ -200,10 +197,6 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
|||||||
this.defaultController = "default_controller";
|
this.defaultController = "default_controller";
|
||||||
additionalProperties.put(DEFAULT_CONTROLLER, this.defaultController);
|
additionalProperties.put(DEFAULT_CONTROLLER, this.defaultController);
|
||||||
}
|
}
|
||||||
if (Boolean.TRUE.equals(additionalProperties.get(SUPPORT_PYTHON2))) {
|
|
||||||
additionalProperties.put(SUPPORT_PYTHON2, Boolean.TRUE);
|
|
||||||
typeMapping.put("long", "long");
|
|
||||||
}
|
|
||||||
if (additionalProperties.containsKey(FEATURE_CORS)) {
|
if (additionalProperties.containsKey(FEATURE_CORS)) {
|
||||||
setFeatureCORS(String.valueOf(additionalProperties.get(FEATURE_CORS)));
|
setFeatureCORS(String.valueOf(additionalProperties.get(FEATURE_CORS)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,10 +101,6 @@ public class PythonBluePlanetServerCodegen extends AbstractPythonConnexionServer
|
|||||||
this.defaultController = "default_controller";
|
this.defaultController = "default_controller";
|
||||||
additionalProperties.put(DEFAULT_CONTROLLER, this.defaultController);
|
additionalProperties.put(DEFAULT_CONTROLLER, this.defaultController);
|
||||||
}
|
}
|
||||||
if (Boolean.TRUE.equals(additionalProperties.get(SUPPORT_PYTHON2))) {
|
|
||||||
additionalProperties.put(SUPPORT_PYTHON2, Boolean.TRUE);
|
|
||||||
typeMapping.put("long", "long");
|
|
||||||
}
|
|
||||||
|
|
||||||
String APP_PATH = "app" + File.separatorChar;
|
String APP_PATH = "app" + File.separatorChar;
|
||||||
String APP_PACKAGE_PATH = APP_PATH + packageName;
|
String APP_PACKAGE_PATH = APP_PATH + packageName;
|
||||||
@@ -266,5 +262,5 @@ public class PythonBluePlanetServerCodegen extends AbstractPythonConnexionServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generatorLanguageVersion() { return "2.7+ and 3.5.2+"; };
|
public String generatorLanguageVersion() { return "3.5.2+"; };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,5 +56,5 @@ public class PythonFlaskConnexionServerCodegen extends AbstractPythonConnexionSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generatorLanguageVersion() { return "2.7 and 3.5.2+"; };
|
public String generatorLanguageVersion() { return "3.5.2+"; };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ connexion[aiohttp,swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=
|
|||||||
# we must peg werkzeug versions below to fix connexion
|
# we must peg werkzeug versions below to fix connexion
|
||||||
# https://github.com/zalando/connexion/pull/1044
|
# https://github.com/zalando/connexion/pull/1044
|
||||||
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
|
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
|
||||||
swagger-ui-bundle == 0.0.6
|
swagger-ui-bundle == 0.0.9
|
||||||
aiohttp_jinja2 == 1.2.0
|
aiohttp_jinja2 == 1.5.0
|
||||||
{{#featureCORS}}
|
{{#featureCORS}}
|
||||||
aiohttp_cors >= 0.7.0
|
aiohttp_cors >= 0.7.0
|
||||||
{{/featureCORS}}
|
{{/featureCORS}}
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ VERSION = "{{packageVersion}}"
|
|||||||
# http://pypi.python.org/pypi/setuptools
|
# http://pypi.python.org/pypi/setuptools
|
||||||
|
|
||||||
REQUIRES = [
|
REQUIRES = [
|
||||||
"connexion==2.6.0",
|
"connexion==2.14.1",
|
||||||
"swagger-ui-bundle==0.0.6",
|
"swagger-ui-bundle==0.0.9",
|
||||||
"aiohttp_jinja2==1.2.0",
|
"aiohttp_jinja2==1.5.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ py>=1.4.31
|
|||||||
randomize>=0.13
|
randomize>=0.13
|
||||||
{{/useNose}}
|
{{/useNose}}
|
||||||
{{^useNose}}
|
{{^useNose}}
|
||||||
pytest~=4.6.7 # needed for python 2.7+3.4
|
pytest~=7.1.0
|
||||||
pytest-cov>=2.8.1
|
pytest-cov>=2.8.1
|
||||||
pytest-randomly==1.2.3 # needed for python 2.7+3.4
|
pytest-randomly>=1.2.3
|
||||||
pytest-aiohttp>=0.3.0
|
pytest-aiohttp>=0.3.0
|
||||||
{{/useNose}}
|
{{/useNose}}
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
{{#supportPython2}}
|
|
||||||
FROM python:2-alpine
|
|
||||||
{{/supportPython2}}
|
|
||||||
{{^supportPython2}}
|
|
||||||
FROM python:3-alpine
|
FROM python:3-alpine
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
ARG GLTOKEN
|
ARG GLTOKEN
|
||||||
|
|
||||||
@@ -19,12 +14,7 @@ WORKDIR /bp2/src
|
|||||||
|
|
||||||
COPY requirements.txt /bp2/src
|
COPY requirements.txt /bp2/src
|
||||||
|
|
||||||
{{#supportPython2}}
|
|
||||||
RUN pip install --extra-index-url https://GLTOKEN:$GLTOKEN@pypi.blueplanet.com/simple --no-cache-dir -r requirements.txt
|
|
||||||
{{/supportPython2}}
|
|
||||||
{{^supportPython2}}
|
|
||||||
RUN pip3 install --extra-index-url https://GLTOKEN:$GLTOKEN@pypi.blueplanet.com/simple --no-cache-dir -r requirements.txt
|
RUN pip3 install --extra-index-url https://GLTOKEN:$GLTOKEN@pypi.blueplanet.com/simple --no-cache-dir -r requirements.txt
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
COPY . /bp2/src
|
COPY . /bp2/src
|
||||||
|
|
||||||
@@ -33,11 +23,6 @@ ENV SBIS=bpocore \
|
|||||||
|
|
||||||
EXPOSE {{serverPort}}
|
EXPOSE {{serverPort}}
|
||||||
|
|
||||||
{{#supportPython2}}
|
|
||||||
ENTRYPOINT ["python"]
|
|
||||||
{{/supportPython2}}
|
|
||||||
{{^supportPython2}}
|
|
||||||
ENTRYPOINT ["python3"]
|
ENTRYPOINT ["python3"]
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
CMD ["-B", "-m", "{{packageName}}"]
|
CMD ["-B", "-m", "{{packageName}}"]
|
||||||
|
|||||||
@@ -8,25 +8,14 @@ is an example of building a swagger-enabled Flask server.
|
|||||||
This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
|
This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
{{#supportPython2}}
|
|
||||||
Python 2.7+
|
|
||||||
{{/supportPython2}}
|
|
||||||
{{^supportPython2}}
|
|
||||||
Python 3.5.2+
|
Python 3.5.2+
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
To run the server, please execute the following from the root directory:
|
To run the server, please execute the following from the root directory:
|
||||||
|
|
||||||
```
|
```
|
||||||
{{#supportPython2}}
|
|
||||||
pip install -r requirements.txt
|
|
||||||
python -m {{packageName}}
|
|
||||||
{{/supportPython2}}
|
|
||||||
{{^supportPython2}}
|
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
python3 -m {{packageName}}
|
python3 -m {{packageName}}
|
||||||
{{/supportPython2}}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
and open your browser to here:
|
and open your browser to here:
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
connexion == 1.1.15
|
connexion == 1.1.15
|
||||||
python_dateutil == 2.6.0
|
python_dateutil == 2.6.0
|
||||||
{{#supportPython2}}
|
|
||||||
typing == 3.5.2.2
|
|
||||||
{{/supportPython2}}
|
|
||||||
setuptools >= 21.0.0
|
setuptools >= 21.0.0
|
||||||
bp2hookutil==3.3.0
|
bp2hookutil==3.3.0
|
||||||
plansdk
|
plansdk
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = {{#supportPython2}}py27, {{/supportPython2}}py35
|
envlist = py35
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps=-r{toxinidir}/requirements.txt
|
deps=-r{toxinidir}/requirements.txt
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
{{#supportPython2}}
|
|
||||||
#!/usr/bin/env python
|
|
||||||
{{/supportPython2}}
|
|
||||||
{{^supportPython2}}
|
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
import connexion
|
import connexion
|
||||||
{{#featureCORS}}
|
{{#featureCORS}}
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
import pprint
|
import pprint
|
||||||
|
|
||||||
import six
|
import six
|
||||||
{{^supportPython2}}
|
|
||||||
import typing
|
import typing
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
from {{packageName}} import util
|
from {{packageName}} import util
|
||||||
{{^supportPython2}}
|
|
||||||
|
|
||||||
T = typing.TypeVar('T')
|
T = typing.TypeVar('T')
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
|
|
||||||
class Model(object):
|
class Model(object):
|
||||||
@@ -22,7 +18,7 @@ class Model(object):
|
|||||||
attribute_map = {}
|
attribute_map = {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls{{^supportPython2}}: typing.Type[T]{{/supportPython2}}, dikt){{^supportPython2}} -> T{{/supportPython2}}:
|
def from_dict(cls: typing.Type[T], dikt) -> T:
|
||||||
"""Returns the dict as a model"""
|
"""Returns the dict as a model"""
|
||||||
return util.deserialize_model(dikt, cls)
|
return util.deserialize_model(dikt, cls)
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class {{classname}}(Model):
|
|||||||
{{/-last}}
|
{{/-last}}
|
||||||
{{/enumVars}}{{/allowableValues}}
|
{{/enumVars}}{{/allowableValues}}
|
||||||
|
|
||||||
def __init__(self{{#vars}}, {{name}}{{^supportPython2}}: {{datatype}}{{/supportPython2}}={{{defaultValue}}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501
|
def __init__(self{{#vars}}, {{name}}: {{datatype}}={{{defaultValue}}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501
|
||||||
"""{{classname}} - a model defined in Swagger
|
"""{{classname}} - a model defined in Swagger
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
@@ -52,7 +52,7 @@ class {{classname}}(Model):
|
|||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, dikt){{^supportPython2}} -> '{{classname}}'{{/supportPython2}}:
|
def from_dict(cls, dikt) -> '{{classname}}':
|
||||||
"""Returns the dict as a model
|
"""Returns the dict as a model
|
||||||
|
|
||||||
:param dikt: A dict.
|
:param dikt: A dict.
|
||||||
@@ -64,7 +64,7 @@ class {{classname}}(Model):
|
|||||||
|
|
||||||
{{/-first}}
|
{{/-first}}
|
||||||
@property
|
@property
|
||||||
def {{name}}(self){{^supportPython2}} -> {{datatype}}{{/supportPython2}}:
|
def {{name}}(self) -> {{datatype}}:
|
||||||
"""Gets the {{name}} of this {{classname}}.
|
"""Gets the {{name}} of this {{classname}}.
|
||||||
|
|
||||||
{{#description}}
|
{{#description}}
|
||||||
@@ -77,7 +77,7 @@ class {{classname}}(Model):
|
|||||||
return self._{{name}}
|
return self._{{name}}
|
||||||
|
|
||||||
@{{name}}.setter
|
@{{name}}.setter
|
||||||
def {{name}}(self, {{name}}{{^supportPython2}}: {{datatype}}{{/supportPython2}}):
|
def {{name}}(self, {{name}}: {{datatype}}):
|
||||||
"""Sets the {{name}} of this {{classname}}.
|
"""Sets the {{name}} of this {{classname}}.
|
||||||
|
|
||||||
{{#description}}
|
{{#description}}
|
||||||
|
|||||||
@@ -1,31 +1,16 @@
|
|||||||
{{#supportPython2}}
|
|
||||||
FROM python:2-alpine
|
|
||||||
{{/supportPython2}}
|
|
||||||
{{^supportPython2}}
|
|
||||||
FROM python:3-alpine
|
FROM python:3-alpine
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
RUN mkdir -p /usr/src/app
|
RUN mkdir -p /usr/src/app
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
COPY requirements.txt /usr/src/app/
|
COPY requirements.txt /usr/src/app/
|
||||||
|
|
||||||
{{#supportPython2}}
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
|
||||||
{{/supportPython2}}
|
|
||||||
{{^supportPython2}}
|
|
||||||
RUN pip3 install --no-cache-dir -r requirements.txt
|
RUN pip3 install --no-cache-dir -r requirements.txt
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
COPY . /usr/src/app
|
COPY . /usr/src/app
|
||||||
|
|
||||||
EXPOSE {{serverPort}}
|
EXPOSE {{serverPort}}
|
||||||
|
|
||||||
{{#supportPython2}}
|
|
||||||
ENTRYPOINT ["python"]
|
|
||||||
{{/supportPython2}}
|
|
||||||
{{^supportPython2}}
|
|
||||||
ENTRYPOINT ["python3"]
|
ENTRYPOINT ["python3"]
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
CMD ["-m", "{{packageName}}"]
|
CMD ["-m", "{{packageName}}"]
|
||||||
@@ -8,25 +8,14 @@ is an example of building a OpenAPI-enabled Flask server.
|
|||||||
This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
|
This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
{{#supportPython2}}
|
|
||||||
Python 2.7+
|
|
||||||
{{/supportPython2}}
|
|
||||||
{{^supportPython2}}
|
|
||||||
Python 3.5.2+
|
Python 3.5.2+
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
To run the server, please execute the following from the root directory:
|
To run the server, please execute the following from the root directory:
|
||||||
|
|
||||||
```
|
```
|
||||||
{{#supportPython2}}
|
|
||||||
pip install -r requirements.txt
|
|
||||||
python -m {{packageName}}
|
|
||||||
{{/supportPython2}}
|
|
||||||
{{^supportPython2}}
|
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
python3 -m {{packageName}}
|
python3 -m {{packageName}}
|
||||||
{{/supportPython2}}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
and open your browser to here:
|
and open your browser to here:
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
{{#supportPython2}}
|
|
||||||
#!/usr/bin/env python
|
|
||||||
{{/supportPython2}}
|
|
||||||
{{^supportPython2}}
|
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
import connexion
|
import connexion
|
||||||
{{#featureCORS}}
|
{{#featureCORS}}
|
||||||
|
|||||||
@@ -1,28 +1,24 @@
|
|||||||
import pprint
|
import pprint
|
||||||
|
|
||||||
import six
|
import six
|
||||||
{{^supportPython2}}
|
|
||||||
import typing
|
import typing
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
from {{packageName}} import util
|
from {{packageName}} import util
|
||||||
{{^supportPython2}}
|
|
||||||
|
|
||||||
T = typing.TypeVar('T')
|
T = typing.TypeVar('T')
|
||||||
{{/supportPython2}}
|
|
||||||
|
|
||||||
|
|
||||||
class Model({{#supportPython2}}object{{/supportPython2}}):
|
class Model(object):
|
||||||
# openapiTypes: The key is attribute name and the
|
# openapiTypes: The key is attribute name and the
|
||||||
# value is attribute type.
|
# value is attribute type.
|
||||||
openapi_types{{^supportPython2}}: typing.Dict[str, type]{{/supportPython2}} = {}
|
openapi_types: typing.Dict[str, type] = {}
|
||||||
|
|
||||||
# attributeMap: The key is attribute name and the
|
# attributeMap: The key is attribute name and the
|
||||||
# value is json key in definition.
|
# value is json key in definition.
|
||||||
attribute_map{{^supportPython2}}: typing.Dict[str, str]{{/supportPython2}} = {}
|
attribute_map: typing.Dict[str, str] = {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls{{^supportPython2}}: typing.Type[T]{{/supportPython2}}, dikt){{^supportPython2}} -> T{{/supportPython2}}:
|
def from_dict(cls: typing.Type[T], dikt) -> T:
|
||||||
"""Returns the dict as a model"""
|
"""Returns the dict as a model"""
|
||||||
return util.deserialize_model(dikt, cls)
|
return util.deserialize_model(dikt, cls)
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class {{classname}}(Model):
|
|||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, dikt){{^supportPython2}} -> '{{classname}}'{{/supportPython2}}:
|
def from_dict(cls, dikt) -> '{{classname}}':
|
||||||
"""Returns the dict as a model
|
"""Returns the dict as a model
|
||||||
|
|
||||||
:param dikt: A dict.
|
:param dikt: A dict.
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
connexion[swagger-ui] >= 2.6.0; python_version>="3.6"
|
connexion[swagger-ui] >= 2.6.0; python_version>="3.6"
|
||||||
# 2.3 is the last version that supports python 3.4-3.5
|
# 2.3 is the last version that supports python 3.4-3.5
|
||||||
connexion[swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=="3.4"
|
connexion[swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=="3.4"
|
||||||
{{#supportPython2}}
|
|
||||||
connexion[swagger-ui] == 2.4.0; python_version<="2.7"
|
|
||||||
{{/supportPython2}}
|
|
||||||
# connexion requires werkzeug but connexion < 2.4.0 does not install werkzeug
|
# connexion requires werkzeug but connexion < 2.4.0 does not install werkzeug
|
||||||
# we must peg werkzeug versions below to fix connexion
|
# we must peg werkzeug versions below to fix connexion
|
||||||
# https://github.com/zalando/connexion/pull/1044
|
# https://github.com/zalando/connexion/pull/1044
|
||||||
@@ -14,12 +11,5 @@ python_dateutil >= 2.6.0
|
|||||||
# should support both Python 2 and Python 3
|
# should support both Python 2 and Python 3
|
||||||
flask-cors >= 3.0.10
|
flask-cors >= 3.0.10
|
||||||
{{/featureCORS}}
|
{{/featureCORS}}
|
||||||
{{#supportPython2}}
|
|
||||||
typing >= 3.5.2.2
|
|
||||||
# For specs with timestamps, pyyaml 5.3 broke connexion's spec parsing in python 2.
|
|
||||||
# Connexion uses copy.deepcopy() on the spec, thus hitting this bug:
|
|
||||||
# https://github.com/yaml/pyyaml/issues/387
|
|
||||||
pyyaml < 5.3; python_version<="2.7"
|
|
||||||
{{/supportPython2}}
|
|
||||||
setuptools >= 21.0.0
|
setuptools >= 21.0.0
|
||||||
Flask == 1.1.2
|
Flask == 2.1.1
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ VERSION = "{{packageVersion}}"
|
|||||||
REQUIRES = [
|
REQUIRES = [
|
||||||
"connexion>=2.0.2",
|
"connexion>=2.0.2",
|
||||||
"swagger-ui-bundle>=0.0.2",
|
"swagger-ui-bundle>=0.0.2",
|
||||||
"python_dateutil>=2.6.0"{{#supportPython2}},
|
"python_dateutil>=2.6.0"
|
||||||
"typing>=3.5.2.2"{{/supportPython2}}
|
|
||||||
]
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ py>=1.4.31
|
|||||||
randomize>=0.13
|
randomize>=0.13
|
||||||
{{/useNose}}
|
{{/useNose}}
|
||||||
{{^useNose}}
|
{{^useNose}}
|
||||||
pytest~=4.6.7 # needed for python 2.7+3.4
|
pytest~=7.1.0
|
||||||
pytest-cov>=2.8.1
|
pytest-cov>=2.8.1
|
||||||
pytest-randomly==1.2.3 # needed for python 2.7+3.4
|
pytest-randomly>=1.2.3
|
||||||
{{/useNose}}
|
{{/useNose}}
|
||||||
Flask-Testing==0.8.0
|
Flask-Testing==0.8.1
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = {{#supportPython2}}py27, {{/supportPython2}}py3
|
envlist = py3
|
||||||
skipsdist=True
|
skipsdist=True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
# ref: https://docs.travis-ci.com/user/languages/python
|
# ref: https://docs.travis-ci.com/user/languages/python
|
||||||
language: python
|
language: python
|
||||||
python:
|
python:
|
||||||
{{#supportPython2}}
|
|
||||||
- "2.7"
|
|
||||||
{{/supportPython2}}
|
|
||||||
- "3.2"
|
- "3.2"
|
||||||
- "3.3"
|
- "3.3"
|
||||||
- "3.4"
|
- "3.4"
|
||||||
|
|||||||
9
pom.xml
9
pom.xml
@@ -1131,11 +1131,6 @@
|
|||||||
<module>samples/client/petstore/php/OpenAPIClient-php</module>
|
<module>samples/client/petstore/php/OpenAPIClient-php</module>
|
||||||
<!-- TODO: move to github action or circleci
|
<!-- TODO: move to github action or circleci
|
||||||
<module>samples/client/petstore/crystal</module>-->
|
<module>samples/client/petstore/crystal</module>-->
|
||||||
<!-- servers -->
|
|
||||||
<module>samples/server/petstore/python-aiohttp</module>
|
|
||||||
<module>samples/server/petstore/python-aiohttp-srclayout</module>
|
|
||||||
<module>samples/server/petstore/python-fastapi</module>
|
|
||||||
<module>samples/server/petstore/python-flask</module>
|
|
||||||
<!-- TODO: will move these to Github action
|
<!-- TODO: will move these to Github action
|
||||||
<module>samples/server/petstore/php-slim4</module>
|
<module>samples/server/petstore/php-slim4</module>
|
||||||
<module>samples/server/petstore/php-laravel</module>
|
<module>samples/server/petstore/php-laravel</module>
|
||||||
@@ -1171,6 +1166,10 @@
|
|||||||
</activation>
|
</activation>
|
||||||
<modules>
|
<modules>
|
||||||
<!-- servers -->
|
<!-- servers -->
|
||||||
|
<module>samples/server/petstore/python-aiohttp</module>
|
||||||
|
<module>samples/server/petstore/python-aiohttp-srclayout</module>
|
||||||
|
<module>samples/server/petstore/python-fastapi</module>
|
||||||
|
<module>samples/server/petstore/python-flask</module>
|
||||||
<module>samples/server/petstore/java-camel</module>
|
<module>samples/server/petstore/java-camel</module>
|
||||||
<module>samples/server/petstore/java-vertx-web</module>
|
<module>samples/server/petstore/java-vertx-web</module>
|
||||||
<module>samples/server/petstore/java-inflector</module>
|
<module>samples/server/petstore/java-inflector</module>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ clean:
|
|||||||
find . -name "__pycache__" -delete
|
find . -name "__pycache__" -delete
|
||||||
|
|
||||||
venv:
|
venv:
|
||||||
python -m venv $(VENV)
|
python3 -m venv $(VENV)
|
||||||
|
|
||||||
test: clean venv
|
test: clean venv
|
||||||
bash ./test_python3.sh
|
bash ./test_python3.sh
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ connexion[aiohttp,swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=
|
|||||||
# we must peg werkzeug versions below to fix connexion
|
# we must peg werkzeug versions below to fix connexion
|
||||||
# https://github.com/zalando/connexion/pull/1044
|
# https://github.com/zalando/connexion/pull/1044
|
||||||
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
|
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
|
||||||
swagger-ui-bundle == 0.0.6
|
swagger-ui-bundle == 0.0.9
|
||||||
aiohttp_jinja2 == 1.2.0
|
aiohttp_jinja2 == 1.5.0
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ VERSION = "1.0.0"
|
|||||||
# http://pypi.python.org/pypi/setuptools
|
# http://pypi.python.org/pypi/setuptools
|
||||||
|
|
||||||
REQUIRES = [
|
REQUIRES = [
|
||||||
"connexion==2.6.0",
|
"connexion==2.14.1",
|
||||||
"swagger-ui-bundle==0.0.6",
|
"swagger-ui-bundle==0.0.9",
|
||||||
"aiohttp_jinja2==1.2.0",
|
"aiohttp_jinja2==1.5.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
pytest~=4.6.7 # needed for python 2.7+3.4
|
pytest~=7.1.0
|
||||||
pytest-cov>=2.8.1
|
pytest-cov>=2.8.1
|
||||||
pytest-randomly==1.2.3 # needed for python 2.7+3.4
|
pytest-randomly>=1.2.3
|
||||||
pytest-aiohttp>=0.3.0
|
pytest-aiohttp>=0.3.0
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ clean:
|
|||||||
find . -name "__pycache__" -delete
|
find . -name "__pycache__" -delete
|
||||||
|
|
||||||
venv:
|
venv:
|
||||||
python -m venv $(VENV)
|
python3 -m venv $(VENV)
|
||||||
|
|
||||||
test: clean venv
|
test: clean venv
|
||||||
bash ./test_python3.sh
|
bash ./test_python3.sh
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ connexion[aiohttp,swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=
|
|||||||
# we must peg werkzeug versions below to fix connexion
|
# we must peg werkzeug versions below to fix connexion
|
||||||
# https://github.com/zalando/connexion/pull/1044
|
# https://github.com/zalando/connexion/pull/1044
|
||||||
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
|
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
|
||||||
swagger-ui-bundle == 0.0.6
|
swagger-ui-bundle == 0.0.9
|
||||||
aiohttp_jinja2 == 1.2.0
|
aiohttp_jinja2 == 1.5.0
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ VERSION = "1.0.0"
|
|||||||
# http://pypi.python.org/pypi/setuptools
|
# http://pypi.python.org/pypi/setuptools
|
||||||
|
|
||||||
REQUIRES = [
|
REQUIRES = [
|
||||||
"connexion==2.6.0",
|
"connexion==2.14.1",
|
||||||
"swagger-ui-bundle==0.0.6",
|
"swagger-ui-bundle==0.0.9",
|
||||||
"aiohttp_jinja2==1.2.0",
|
"aiohttp_jinja2==1.5.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
pytest~=4.6.7 # needed for python 2.7+3.4
|
pytest~=7.1.0
|
||||||
pytest-cov>=2.8.1
|
pytest-cov>=2.8.1
|
||||||
pytest-randomly==1.2.3 # needed for python 2.7+3.4
|
pytest-randomly>=1.2.3
|
||||||
pytest-aiohttp>=0.3.0
|
pytest-aiohttp>=0.3.0
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from openapi_server.models.api_response import ApiResponse
|
|||||||
from openapi_server.models.pet import Pet
|
from openapi_server.models.pet import Pet
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip("Connexion does not support multiple consummes. See https://github.com/zalando/connexion/pull/760")
|
@pytest.mark.skip("Connexion does not support multiple consumes. See https://github.com/zalando/connexion/pull/760")
|
||||||
async def test_add_pet(client):
|
async def test_add_pet(client):
|
||||||
"""Test case for add_pet
|
"""Test case for add_pet
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ async def test_find_pets_by_status(client):
|
|||||||
|
|
||||||
Finds Pets by status
|
Finds Pets by status
|
||||||
"""
|
"""
|
||||||
params = [('status', 'available')]
|
params = [('status', ['available'])]
|
||||||
headers = {
|
headers = {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Authorization': 'Bearer special-key',
|
'Authorization': 'Bearer special-key',
|
||||||
@@ -86,7 +86,7 @@ async def test_find_pets_by_tags(client):
|
|||||||
|
|
||||||
Finds Pets by tags
|
Finds Pets by tags
|
||||||
"""
|
"""
|
||||||
params = [('tags', 'tags_example')]
|
params = [('tags', ['tags_example'])]
|
||||||
headers = {
|
headers = {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Authorization': 'Bearer special-key',
|
'Authorization': 'Bearer special-key',
|
||||||
@@ -117,7 +117,7 @@ async def test_get_pet_by_id(client):
|
|||||||
assert response.status == 200, 'Response body is : ' + (await response.read()).decode('utf-8')
|
assert response.status == 200, 'Response body is : ' + (await response.read()).decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip("Connexion does not support multiple consummes. See https://github.com/zalando/connexion/pull/760")
|
@pytest.mark.skip("Connexion does not support multiple consumes. See https://github.com/zalando/connexion/pull/760")
|
||||||
async def test_update_pet(client):
|
async def test_update_pet(client):
|
||||||
"""Test case for update_pet
|
"""Test case for update_pet
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ async def test_upload_file(client):
|
|||||||
}
|
}
|
||||||
data = FormData()
|
data = FormData()
|
||||||
data.add_field('additional_metadata', 'additional_metadata_example')
|
data.add_field('additional_metadata', 'additional_metadata_example')
|
||||||
data.add_field('file', (BytesIO(b'some file data'), 'file.txt'))
|
data.add_field('file', '/path/to/file')
|
||||||
response = await client.request(
|
response = await client.request(
|
||||||
method='POST',
|
method='POST',
|
||||||
path='/v2/pet/{pet_id}/uploadImage'.format(pet_id=56),
|
path='/v2/pet/{pet_id}/uploadImage'.format(pet_id=56),
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ async def test_get_order_by_id(client):
|
|||||||
}
|
}
|
||||||
response = await client.request(
|
response = await client.request(
|
||||||
method='GET',
|
method='GET',
|
||||||
path='/v2/store/order/{order_id}'.format(order_id=5),
|
path='/v2/store/order/{order_id}'.format(order_id=1),
|
||||||
headers=headers,
|
headers=headers,
|
||||||
)
|
)
|
||||||
assert response.status == 200, 'Response body is : ' + (await response.read()).decode('utf-8')
|
assert response.status == 200, 'Response body is : ' + (await response.read()).decode('utf-8')
|
||||||
@@ -61,7 +61,7 @@ async def test_place_order(client):
|
|||||||
|
|
||||||
Place an order for a pet
|
Place an order for a pet
|
||||||
"""
|
"""
|
||||||
body = {}
|
body = openapi_server.Order()
|
||||||
headers = {
|
headers = {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ async def test_create_user(client):
|
|||||||
|
|
||||||
Create user
|
Create user
|
||||||
"""
|
"""
|
||||||
body = {}
|
body = openapi_server.User()
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ async def test_create_users_with_array_input(client):
|
|||||||
|
|
||||||
Creates list of users with given input array
|
Creates list of users with given input array
|
||||||
"""
|
"""
|
||||||
body = [{}]
|
body = [openapi_server.User()]
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ async def test_create_users_with_list_input(client):
|
|||||||
|
|
||||||
Creates list of users with given input array
|
Creates list of users with given input array
|
||||||
"""
|
"""
|
||||||
body = [{}]
|
body = [openapi_server.User()]
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ async def test_update_user(client):
|
|||||||
|
|
||||||
Updated user
|
Updated user
|
||||||
"""
|
"""
|
||||||
body = {}
|
body = openapi_server.User()
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class TestPetController(BaseTestCase):
|
|||||||
|
|
||||||
Finds Pets by status
|
Finds Pets by status
|
||||||
"""
|
"""
|
||||||
query_string = [('status', 'available')]
|
query_string = [('status', ['available'])]
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet/findByStatus',
|
'/v2/pet/findByStatus',
|
||||||
method='GET',
|
method='GET',
|
||||||
@@ -74,7 +74,7 @@ class TestPetController(BaseTestCase):
|
|||||||
|
|
||||||
Finds Pets by tags
|
Finds Pets by tags
|
||||||
"""
|
"""
|
||||||
query_string = [('tags', 'tags_example')]
|
query_string = [('tags', ['tags_example'])]
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet/findByTags',
|
'/v2/pet/findByTags',
|
||||||
method='GET',
|
method='GET',
|
||||||
@@ -144,7 +144,7 @@ class TestPetController(BaseTestCase):
|
|||||||
uploads an image
|
uploads an image
|
||||||
"""
|
"""
|
||||||
data = dict(additional_metadata='additional_metadata_example',
|
data = dict(additional_metadata='additional_metadata_example',
|
||||||
file=(BytesIO(b'some file data'), 'file.txt'))
|
file='/path/to/file')
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet/{pet_id}/uploadImage'.format(pet_id=56),
|
'/v2/pet/{pet_id}/uploadImage'.format(pet_id=56),
|
||||||
method='POST',
|
method='POST',
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class TestStoreController(BaseTestCase):
|
|||||||
Find purchase order by ID
|
Find purchase order by ID
|
||||||
"""
|
"""
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/store/order/{order_id}'.format(order_id=5),
|
'/v2/store/order/{order_id}'.format(order_id=1),
|
||||||
method='GET')
|
method='GET')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@@ -50,7 +50,7 @@ class TestStoreController(BaseTestCase):
|
|||||||
|
|
||||||
Place an order for a pet
|
Place an order for a pet
|
||||||
"""
|
"""
|
||||||
body = {}
|
body = openapi_server.Order()
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/store/order',
|
'/v2/store/order',
|
||||||
method='POST',
|
method='POST',
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Create user
|
Create user
|
||||||
"""
|
"""
|
||||||
body = {}
|
body = openapi_server.User()
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/user',
|
'/v2/user',
|
||||||
method='POST',
|
method='POST',
|
||||||
@@ -31,7 +31,7 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Creates list of users with given input array
|
Creates list of users with given input array
|
||||||
"""
|
"""
|
||||||
body = []
|
body = [openapi_server.User()]
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/user/createWithArray',
|
'/v2/user/createWithArray',
|
||||||
method='POST',
|
method='POST',
|
||||||
@@ -45,7 +45,7 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Creates list of users with given input array
|
Creates list of users with given input array
|
||||||
"""
|
"""
|
||||||
body = []
|
body = [openapi_server.User()]
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/user/createWithList',
|
'/v2/user/createWithList',
|
||||||
method='POST',
|
method='POST',
|
||||||
@@ -106,7 +106,7 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Updated user
|
Updated user
|
||||||
"""
|
"""
|
||||||
body = {}
|
body = openapi_server.User()
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/user/{username}'.format(username='username_example'),
|
'/v2/user/{username}'.format(username='username_example'),
|
||||||
method='PUT',
|
method='PUT',
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from openapi_server import util
|
|||||||
T = typing.TypeVar('T')
|
T = typing.TypeVar('T')
|
||||||
|
|
||||||
|
|
||||||
class Model():
|
class Model(object):
|
||||||
# openapiTypes: The key is attribute name and the
|
# openapiTypes: The key is attribute name and the
|
||||||
# value is attribute type.
|
# value is attribute type.
|
||||||
openapi_types: typing.Dict[str, type] = {}
|
openapi_types: typing.Dict[str, type] = {}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from openapi_server.test import BaseTestCase
|
|||||||
class TestPetController(BaseTestCase):
|
class TestPetController(BaseTestCase):
|
||||||
"""PetController integration test stubs"""
|
"""PetController integration test stubs"""
|
||||||
|
|
||||||
@unittest.skip("Connexion does not support multiple consummes. See https://github.com/zalando/connexion/pull/760")
|
@unittest.skip("Connexion does not support multiple consumes. See https://github.com/zalando/connexion/pull/760")
|
||||||
def test_add_pet(self):
|
def test_add_pet(self):
|
||||||
"""Test case for add_pet
|
"""Test case for add_pet
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ class TestPetController(BaseTestCase):
|
|||||||
|
|
||||||
Finds Pets by tags
|
Finds Pets by tags
|
||||||
"""
|
"""
|
||||||
query_string = [('tags', 'tags_example')]
|
query_string = [('tags', ['tags_example'])]
|
||||||
headers = {
|
headers = {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Authorization': 'Bearer special-key',
|
'Authorization': 'Bearer special-key',
|
||||||
@@ -118,7 +118,7 @@ class TestPetController(BaseTestCase):
|
|||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
|
|
||||||
@unittest.skip("Connexion does not support multiple consummes. See https://github.com/zalando/connexion/pull/760")
|
@unittest.skip("Connexion does not support multiple consumes. See https://github.com/zalando/connexion/pull/760")
|
||||||
def test_update_pet(self):
|
def test_update_pet(self):
|
||||||
"""Test case for update_pet
|
"""Test case for update_pet
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ class TestPetController(BaseTestCase):
|
|||||||
'Authorization': 'Bearer special-key',
|
'Authorization': 'Bearer special-key',
|
||||||
}
|
}
|
||||||
data = dict(additional_metadata='additional_metadata_example',
|
data = dict(additional_metadata='additional_metadata_example',
|
||||||
file=(BytesIO(b'some file data'), 'file.txt'))
|
file='/path/to/file')
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet/{pet_id}/uploadImage'.format(pet_id=56),
|
'/v2/pet/{pet_id}/uploadImage'.format(pet_id=56),
|
||||||
method='POST',
|
method='POST',
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class TestStoreController(BaseTestCase):
|
|||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
}
|
}
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/store/order/{order_id}'.format(order_id=5),
|
'/v2/store/order/{order_id}'.format(order_id=1),
|
||||||
method='GET',
|
method='GET',
|
||||||
headers=headers)
|
headers=headers)
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
@@ -64,7 +64,7 @@ class TestStoreController(BaseTestCase):
|
|||||||
|
|
||||||
Place an order for a pet
|
Place an order for a pet
|
||||||
"""
|
"""
|
||||||
body = {}
|
body = openapi_server.Order()
|
||||||
headers = {
|
headers = {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Create user
|
Create user
|
||||||
"""
|
"""
|
||||||
body = {}
|
body = openapi_server.User()
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Creates list of users with given input array
|
Creates list of users with given input array
|
||||||
"""
|
"""
|
||||||
body = [{}]
|
body = [openapi_server.User()]
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,7 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Creates list of users with given input array
|
Creates list of users with given input array
|
||||||
"""
|
"""
|
||||||
body = [{}]
|
body = [openapi_server.User()]
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ class TestUserController(BaseTestCase):
|
|||||||
|
|
||||||
Updated user
|
Updated user
|
||||||
"""
|
"""
|
||||||
body = {}
|
body = openapi_server.User()
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
|
|||||||
swagger-ui-bundle >= 0.0.2
|
swagger-ui-bundle >= 0.0.2
|
||||||
python_dateutil >= 2.6.0
|
python_dateutil >= 2.6.0
|
||||||
setuptools >= 21.0.0
|
setuptools >= 21.0.0
|
||||||
Flask == 1.1.2
|
Flask == 2.1.1
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
pytest~=4.6.7 # needed for python 2.7+3.4
|
pytest~=7.1.0
|
||||||
pytest-cov>=2.8.1
|
pytest-cov>=2.8.1
|
||||||
pytest-randomly==1.2.3 # needed for python 2.7+3.4
|
pytest-randomly>=1.2.3
|
||||||
Flask-Testing==0.8.0
|
Flask-Testing==0.8.1
|
||||||
|
|||||||
Reference in New Issue
Block a user