Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/remove support python2 option in flask aiohttp generators #13585

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/generators/python-aiohttp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|
|sortModelPropertiesByRequiredFlag|Sort model properties 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|
|useNose|use the nose test framework| |false|
|usePythonSrcRootInImports|include pythonSrcRoot in import namespaces.| |false|
Expand Down
3 changes: 1 addition & 2 deletions docs/generators/python-blueplanet.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ title: Documentation for the python-blueplanet Generator
| generator stability | STABLE | |
| generator type | SERVER | |
| generator language | Python | |
| generator language version | 2.7+ and 3.5.2+ | |
| generator language version | 3.5.2+ | |
| 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. | |

Expand All @@ -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|
|sortModelPropertiesByRequiredFlag|Sort model properties 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|
|useNose|use the nose test framework| |false|
|usePythonSrcRootInImports|include pythonSrcRoot in import namespaces.| |false|
Expand Down
3 changes: 1 addition & 2 deletions docs/generators/python-flask.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ title: Documentation for the python-flask Generator
| generator stability | STABLE | |
| generator type | SERVER | |
| generator language | Python | |
| generator language version | 2.7 and 3.5.2+ | |
| generator language version | 3.5.2+ | |
| 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. | |

Expand All @@ -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|
|sortModelPropertiesByRequiredFlag|Sort model properties 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|
|useNose|use the nose test framework| |false|
|usePythonSrcRootInImports|include pythonSrcRoot in import namespaces.| |false|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public void serialize(Boolean value, JsonGenerator gen, SerializerProvider seria

public static final String CONTROLLER_PACKAGE = "controllerPackage";
public static final String DEFAULT_CONTROLLER = "defaultController";
public static final String SUPPORT_PYTHON2 = "supportPython2";
public static final String FEATURE_CORS = "featureCORS";
// nose is a python testing framework, we use pytest if USE_NOSE is unset
public static final String USE_NOSE = "useNose";
Expand Down Expand Up @@ -152,8 +151,6 @@ public AbstractPythonConnexionServerCodegen(String templateDirectory, boolean fi
defaultValue("controllers"));
cliOptions.add(new CliOption(DEFAULT_CONTROLLER, "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").
defaultValue("8080"));
cliOptions.add(CliOption.newBoolean(FEATURE_CORS, "use flask-cors for handling CORS requests").
Expand Down Expand Up @@ -200,10 +197,6 @@ public void processOpts() {
this.defaultController = "default_controller";
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)) {
setFeatureCORS(String.valueOf(additionalProperties.get(FEATURE_CORS)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ public void processOpts() {
this.defaultController = "default_controller";
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_PACKAGE_PATH = APP_PATH + packageName;
Expand Down Expand Up @@ -266,5 +262,5 @@ public String apiFileFolder() {
}

@Override
public String generatorLanguageVersion() { return "2.7+ and 3.5.2+"; };
public String generatorLanguageVersion() { return "3.5.2+"; };
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ protected void addSupportingFiles() {
}

@Override
public String generatorLanguageVersion() { return "2.7 and 3.5.2+"; };
public String generatorLanguageVersion() { return "3.5.2+"; };
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
# https://github.com/zalando/connexion/pull/1044
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
swagger-ui-bundle == 0.0.6
aiohttp_jinja2 == 1.2.0
swagger-ui-bundle == 0.0.9
aiohttp_jinja2 == 1.5.0
{{#featureCORS}}
aiohttp_cors >= 0.7.0
{{/featureCORS}}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ VERSION = "{{packageVersion}}"
# http://pypi.python.org/pypi/setuptools

REQUIRES = [
"connexion==2.6.0",
"swagger-ui-bundle==0.0.6",
"aiohttp_jinja2==1.2.0",
"connexion==2.14.1",
"swagger-ui-bundle==0.0.9",
"aiohttp_jinja2==1.5.0",
]

setup(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ py>=1.4.31
randomize>=0.13
{{/useNose}}
{{^useNose}}
pytest~=4.6.7 # needed for python 2.7+3.4
pytest~=7.1.0
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
{{/useNose}}
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{{#supportPython2}}
FROM python:2-alpine
{{/supportPython2}}
{{^supportPython2}}
FROM python:3-alpine
{{/supportPython2}}

ARG GLTOKEN

Expand All @@ -19,12 +14,7 @@ WORKDIR /bp2/src

COPY requirements.txt /bp2/src

{{#supportPython2}}
RUN pip install --extra-index-url https://GLTOKEN:[email protected]/simple --no-cache-dir -r requirements.txt
{{/supportPython2}}
{{^supportPython2}}
RUN pip3 install --extra-index-url https://GLTOKEN:[email protected]/simple --no-cache-dir -r requirements.txt
{{/supportPython2}}

COPY . /bp2/src

Expand All @@ -33,11 +23,6 @@ ENV SBIS=bpocore \

EXPOSE {{serverPort}}

{{#supportPython2}}
ENTRYPOINT ["python"]
{{/supportPython2}}
{{^supportPython2}}
ENTRYPOINT ["python3"]
{{/supportPython2}}

CMD ["-B", "-m", "{{packageName}}"]
Original file line number Diff line number Diff line change
Expand Up @@ -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.

## Requirements
{{#supportPython2}}
Python 2.7+
{{/supportPython2}}
{{^supportPython2}}
Python 3.5.2+
{{/supportPython2}}

## Usage
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
python3 -m {{packageName}}
{{/supportPython2}}
```

and open your browser to here:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
connexion == 1.1.15
python_dateutil == 2.6.0
{{#supportPython2}}
typing == 3.5.2.2
{{/supportPython2}}
setuptools >= 21.0.0
bp2hookutil==3.3.0
plansdk
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = {{#supportPython2}}py27, {{/supportPython2}}py35
envlist = py35

[testenv]
deps=-r{toxinidir}/requirements.txt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{{#supportPython2}}
#!/usr/bin/env python
{{/supportPython2}}
{{^supportPython2}}
#!/usr/bin/env python3
{{/supportPython2}}

import connexion
{{#featureCORS}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import pprint

import six
{{^supportPython2}}
import typing
{{/supportPython2}}

from {{packageName}} import util
{{^supportPython2}}

T = typing.TypeVar('T')
{{/supportPython2}}


class Model(object):
Expand All @@ -22,7 +18,7 @@ class Model(object):
attribute_map = {}

@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"""
return util.deserialize_model(dikt, cls)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class {{classname}}(Model):
{{/-last}}
{{/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

{{#vars}}
Expand All @@ -52,7 +52,7 @@ class {{classname}}(Model):
{{/vars}}

@classmethod
def from_dict(cls, dikt){{^supportPython2}} -> '{{classname}}'{{/supportPython2}}:
def from_dict(cls, dikt) -> '{{classname}}':
"""Returns the dict as a model

:param dikt: A dict.
Expand All @@ -64,7 +64,7 @@ class {{classname}}(Model):

{{/-first}}
@property
def {{name}}(self){{^supportPython2}} -> {{datatype}}{{/supportPython2}}:
def {{name}}(self) -> {{datatype}}:
"""Gets the {{name}} of this {{classname}}.

{{#description}}
Expand All @@ -77,7 +77,7 @@ class {{classname}}(Model):
return self._{{name}}

@{{name}}.setter
def {{name}}(self, {{name}}{{^supportPython2}}: {{datatype}}{{/supportPython2}}):
def {{name}}(self, {{name}}: {{datatype}}):
"""Sets the {{name}} of this {{classname}}.

{{#description}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
{{#supportPython2}}
FROM python:2-alpine
{{/supportPython2}}
{{^supportPython2}}
FROM python:3-alpine
{{/supportPython2}}

RUN mkdir -p /usr/src/app
WORKDIR /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
{{/supportPython2}}

COPY . /usr/src/app

EXPOSE {{serverPort}}

{{#supportPython2}}
ENTRYPOINT ["python"]
{{/supportPython2}}
{{^supportPython2}}
ENTRYPOINT ["python3"]
{{/supportPython2}}

CMD ["-m", "{{packageName}}"]
Original file line number Diff line number Diff line change
Expand Up @@ -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.

## Requirements
{{#supportPython2}}
Python 2.7+
{{/supportPython2}}
{{^supportPython2}}
Python 3.5.2+
{{/supportPython2}}

## Usage
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
python3 -m {{packageName}}
{{/supportPython2}}
```

and open your browser to here:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{{#supportPython2}}
#!/usr/bin/env python
{{/supportPython2}}
{{^supportPython2}}
#!/usr/bin/env python3
{{/supportPython2}}

import connexion
{{#featureCORS}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import pprint

import six
{{^supportPython2}}
import typing
{{/supportPython2}}

from {{packageName}} import util
{{^supportPython2}}

T = typing.TypeVar('T')
{{/supportPython2}}


class Model({{#supportPython2}}object{{/supportPython2}}):
class Model(object):
# openapiTypes: The key is attribute name and the
# 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
# value is json key in definition.
attribute_map{{^supportPython2}}: typing.Dict[str, str]{{/supportPython2}} = {}
attribute_map: typing.Dict[str, str] = {}

@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"""
return util.deserialize_model(dikt, cls)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class {{classname}}(Model):
{{/vars}}

@classmethod
def from_dict(cls, dikt){{^supportPython2}} -> '{{classname}}'{{/supportPython2}}:
def from_dict(cls, dikt) -> '{{classname}}':
"""Returns the dict as a model

:param dikt: A dict.
Expand Down
Loading