From 085e1e58e5efbe7f259cf6689819ed0fa357dd56 Mon Sep 17 00:00:00 2001
From: William Cheng <wing328hk@gmail.com>
Date: Tue, 4 Oct 2022 15:24:26 +0800
Subject: [PATCH] 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 9f47db2f87d1faea6863f4fa5f7c97ddba985879.

* 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>
---
 docs/generators/python-aiohttp.md                 |  1 -
 docs/generators/python-blueplanet.md              |  3 +--
 docs/generators/python-flask.md                   |  3 +--
 .../AbstractPythonConnexionServerCodegen.java     |  7 -------
 .../languages/PythonBluePlanetServerCodegen.java  |  6 +-----
 .../PythonFlaskConnexionServerCodegen.java        |  2 +-
 .../python-aiohttp/requirements.mustache          |  4 ++--
 .../main/resources/python-aiohttp/setup.mustache  |  6 +++---
 .../python-aiohttp/test-requirements.mustache     |  4 ++--
 .../python-blueplanet/app/Dockerfile.mustache     | 15 ---------------
 .../python-blueplanet/app/README.mustache         | 11 -----------
 .../python-blueplanet/app/requirements.mustache   |  3 ---
 .../resources/python-blueplanet/app/tox.mustache  |  2 +-
 .../app/{{packageName}}/__main__.mustache         |  5 -----
 .../{{packageName}}/models/base_model_.mustache   |  6 +-----
 .../app/{{packageName}}/models/model.mustache     |  8 ++++----
 .../resources/python-flask/Dockerfile.mustache    | 15 ---------------
 .../main/resources/python-flask/README.mustache   | 11 -----------
 .../main/resources/python-flask/__main__.mustache |  5 -----
 .../resources/python-flask/base_model_.mustache   | 12 ++++--------
 .../main/resources/python-flask/model.mustache    |  2 +-
 .../resources/python-flask/requirements.mustache  | 12 +-----------
 .../main/resources/python-flask/setup.mustache    |  3 +--
 .../python-flask/test-requirements.mustache       |  6 +++---
 .../src/main/resources/python-flask/tox.mustache  |  2 +-
 .../main/resources/python-flask/travis.mustache   |  3 ---
 pom.xml                                           |  9 ++++-----
 .../petstore/python-aiohttp-srclayout/Makefile    |  2 +-
 .../python-aiohttp-srclayout/requirements.txt     |  4 ++--
 .../petstore/python-aiohttp-srclayout/setup.py    |  6 +++---
 .../test-requirements.txt                         |  4 ++--
 samples/server/petstore/python-aiohttp/Makefile   |  2 +-
 .../petstore/python-aiohttp/requirements.txt      |  4 ++--
 samples/server/petstore/python-aiohttp/setup.py   |  6 +++---
 .../petstore/python-aiohttp/test-requirements.txt |  4 ++--
 .../python-aiohttp/tests/test_pet_controller.py   | 10 +++++-----
 .../python-aiohttp/tests/test_store_controller.py |  4 ++--
 .../python-aiohttp/tests/test_user_controller.py  |  8 ++++----
 .../openapi_server/test/test_pet_controller.py    |  6 +++---
 .../openapi_server/test/test_store_controller.py  |  4 ++--
 .../openapi_server/test/test_user_controller.py   |  8 ++++----
 .../openapi_server/models/base_model_.py          |  2 +-
 .../openapi_server/test/test_pet_controller.py    |  8 ++++----
 .../openapi_server/test/test_store_controller.py  |  4 ++--
 .../openapi_server/test/test_user_controller.py   |  8 ++++----
 .../server/petstore/python-flask/requirements.txt |  2 +-
 .../petstore/python-flask/test-requirements.txt   |  6 +++---
 47 files changed, 83 insertions(+), 185 deletions(-)

diff --git a/docs/generators/python-aiohttp.md b/docs/generators/python-aiohttp.md
index d2ba3f9ec025..2f6f7e4e5103 100644
--- a/docs/generators/python-aiohttp.md
+++ b/docs/generators/python-aiohttp.md
@@ -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|
diff --git a/docs/generators/python-blueplanet.md b/docs/generators/python-blueplanet.md
index 9e10d91343f9..ce4b7ae98dd9 100644
--- a/docs/generators/python-blueplanet.md
+++ b/docs/generators/python-blueplanet.md
@@ -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. | |
 
@@ -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|
diff --git a/docs/generators/python-flask.md b/docs/generators/python-flask.md
index 2c82d539007d..5624ecb8a040 100644
--- a/docs/generators/python-flask.md
+++ b/docs/generators/python-flask.md
@@ -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. | |
 
@@ -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|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonConnexionServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonConnexionServerCodegen.java
index 38cd718f857f..5f0f932c8d9e 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonConnexionServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonConnexionServerCodegen.java
@@ -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";
@@ -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").
@@ -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)));
         }
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonBluePlanetServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonBluePlanetServerCodegen.java
index fd381e52974b..5f5b8852e199 100755
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonBluePlanetServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonBluePlanetServerCodegen.java
@@ -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;
@@ -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+"; };
 }
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFlaskConnexionServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFlaskConnexionServerCodegen.java
index a9358b4007ad..f667f7b6fca2 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFlaskConnexionServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFlaskConnexionServerCodegen.java
@@ -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+"; };
 }
diff --git a/modules/openapi-generator/src/main/resources/python-aiohttp/requirements.mustache b/modules/openapi-generator/src/main/resources/python-aiohttp/requirements.mustache
index b828c50f4a24..e2ef30b1d41e 100644
--- a/modules/openapi-generator/src/main/resources/python-aiohttp/requirements.mustache
+++ b/modules/openapi-generator/src/main/resources/python-aiohttp/requirements.mustache
@@ -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}}
diff --git a/modules/openapi-generator/src/main/resources/python-aiohttp/setup.mustache b/modules/openapi-generator/src/main/resources/python-aiohttp/setup.mustache
index 364384593d97..706eab4f5055 100644
--- a/modules/openapi-generator/src/main/resources/python-aiohttp/setup.mustache
+++ b/modules/openapi-generator/src/main/resources/python-aiohttp/setup.mustache
@@ -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(
diff --git a/modules/openapi-generator/src/main/resources/python-aiohttp/test-requirements.mustache b/modules/openapi-generator/src/main/resources/python-aiohttp/test-requirements.mustache
index 16ba4a48111d..a408e178b362 100644
--- a/modules/openapi-generator/src/main/resources/python-aiohttp/test-requirements.mustache
+++ b/modules/openapi-generator/src/main/resources/python-aiohttp/test-requirements.mustache
@@ -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}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/python-blueplanet/app/Dockerfile.mustache b/modules/openapi-generator/src/main/resources/python-blueplanet/app/Dockerfile.mustache
index d96f8f2cc399..f93e04526056 100644
--- a/modules/openapi-generator/src/main/resources/python-blueplanet/app/Dockerfile.mustache
+++ b/modules/openapi-generator/src/main/resources/python-blueplanet/app/Dockerfile.mustache
@@ -1,9 +1,4 @@
-{{#supportPython2}}
-FROM python:2-alpine
-{{/supportPython2}}
-{{^supportPython2}}
 FROM python:3-alpine
-{{/supportPython2}}
 
 ARG GLTOKEN
 
@@ -19,12 +14,7 @@ WORKDIR /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
-{{/supportPython2}}
 
 COPY . /bp2/src
 
@@ -33,11 +23,6 @@ ENV SBIS=bpocore \
 
 EXPOSE {{serverPort}}
 
-{{#supportPython2}}
-ENTRYPOINT ["python"]
-{{/supportPython2}}
-{{^supportPython2}}
 ENTRYPOINT ["python3"]
-{{/supportPython2}}
 
 CMD ["-B", "-m", "{{packageName}}"]
diff --git a/modules/openapi-generator/src/main/resources/python-blueplanet/app/README.mustache b/modules/openapi-generator/src/main/resources/python-blueplanet/app/README.mustache
index b73b9e311b07..2c62f0f01a6d 100644
--- a/modules/openapi-generator/src/main/resources/python-blueplanet/app/README.mustache
+++ b/modules/openapi-generator/src/main/resources/python-blueplanet/app/README.mustache
@@ -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:
diff --git a/modules/openapi-generator/src/main/resources/python-blueplanet/app/requirements.mustache b/modules/openapi-generator/src/main/resources/python-blueplanet/app/requirements.mustache
index 275787f38cc3..5989d62ff723 100644
--- a/modules/openapi-generator/src/main/resources/python-blueplanet/app/requirements.mustache
+++ b/modules/openapi-generator/src/main/resources/python-blueplanet/app/requirements.mustache
@@ -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
diff --git a/modules/openapi-generator/src/main/resources/python-blueplanet/app/tox.mustache b/modules/openapi-generator/src/main/resources/python-blueplanet/app/tox.mustache
index d774cfd8dbdc..9391d6aafac4 100644
--- a/modules/openapi-generator/src/main/resources/python-blueplanet/app/tox.mustache
+++ b/modules/openapi-generator/src/main/resources/python-blueplanet/app/tox.mustache
@@ -1,5 +1,5 @@
 [tox]
-envlist = {{#supportPython2}}py27, {{/supportPython2}}py35
+envlist = py35
 
 [testenv]
 deps=-r{toxinidir}/requirements.txt
diff --git a/modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/__main__.mustache b/modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/__main__.mustache
index ab6835dac859..f558123c30a4 100644
--- a/modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/__main__.mustache
+++ b/modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/__main__.mustache
@@ -1,9 +1,4 @@
-{{#supportPython2}}
-#!/usr/bin/env python
-{{/supportPython2}}
-{{^supportPython2}}
 #!/usr/bin/env python3
-{{/supportPython2}}
 
 import connexion
 {{#featureCORS}}
diff --git a/modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/models/base_model_.mustache b/modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/models/base_model_.mustache
index 54517a06d53a..888fa9896461 100644
--- a/modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/models/base_model_.mustache
+++ b/modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/models/base_model_.mustache
@@ -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):
@@ -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)
 
diff --git a/modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/models/model.mustache b/modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/models/model.mustache
index 587589e60011..d9aa9bfd34d7 100644
--- a/modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/models/model.mustache
+++ b/modules/openapi-generator/src/main/resources/python-blueplanet/app/{{packageName}}/models/model.mustache
@@ -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}}
@@ -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.
@@ -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}}
@@ -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}}
diff --git a/modules/openapi-generator/src/main/resources/python-flask/Dockerfile.mustache b/modules/openapi-generator/src/main/resources/python-flask/Dockerfile.mustache
index f040d41ad6ce..465eff45c585 100644
--- a/modules/openapi-generator/src/main/resources/python-flask/Dockerfile.mustache
+++ b/modules/openapi-generator/src/main/resources/python-flask/Dockerfile.mustache
@@ -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}}"]
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/python-flask/README.mustache b/modules/openapi-generator/src/main/resources/python-flask/README.mustache
index 3612c2617dc9..f36875e45045 100644
--- a/modules/openapi-generator/src/main/resources/python-flask/README.mustache
+++ b/modules/openapi-generator/src/main/resources/python-flask/README.mustache
@@ -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:
diff --git a/modules/openapi-generator/src/main/resources/python-flask/__main__.mustache b/modules/openapi-generator/src/main/resources/python-flask/__main__.mustache
index b6018a3af051..4dfeb86aeef1 100644
--- a/modules/openapi-generator/src/main/resources/python-flask/__main__.mustache
+++ b/modules/openapi-generator/src/main/resources/python-flask/__main__.mustache
@@ -1,9 +1,4 @@
-{{#supportPython2}}
-#!/usr/bin/env python
-{{/supportPython2}}
-{{^supportPython2}}
 #!/usr/bin/env python3
-{{/supportPython2}}
 
 import connexion
 {{#featureCORS}}
diff --git a/modules/openapi-generator/src/main/resources/python-flask/base_model_.mustache b/modules/openapi-generator/src/main/resources/python-flask/base_model_.mustache
index e2a33d46b8e7..c771c9e58d5c 100644
--- a/modules/openapi-generator/src/main/resources/python-flask/base_model_.mustache
+++ b/modules/openapi-generator/src/main/resources/python-flask/base_model_.mustache
@@ -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)
 
diff --git a/modules/openapi-generator/src/main/resources/python-flask/model.mustache b/modules/openapi-generator/src/main/resources/python-flask/model.mustache
index 3438bccfa59b..300938389a1e 100644
--- a/modules/openapi-generator/src/main/resources/python-flask/model.mustache
+++ b/modules/openapi-generator/src/main/resources/python-flask/model.mustache
@@ -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.
diff --git a/modules/openapi-generator/src/main/resources/python-flask/requirements.mustache b/modules/openapi-generator/src/main/resources/python-flask/requirements.mustache
index 2d1a20a01902..8161173186d2 100644
--- a/modules/openapi-generator/src/main/resources/python-flask/requirements.mustache
+++ b/modules/openapi-generator/src/main/resources/python-flask/requirements.mustache
@@ -1,9 +1,6 @@
 connexion[swagger-ui] >= 2.6.0; python_version>="3.6"
 # 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"
-{{#supportPython2}}
-connexion[swagger-ui] == 2.4.0; python_version<="2.7"
-{{/supportPython2}}
 # connexion requires werkzeug but connexion < 2.4.0 does not install werkzeug
 # we must peg werkzeug versions below to fix connexion
 # https://github.com/zalando/connexion/pull/1044
@@ -14,12 +11,5 @@ python_dateutil >= 2.6.0
 # should support both Python 2 and Python 3
 flask-cors >= 3.0.10
 {{/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
-Flask == 1.1.2
+Flask == 2.1.1
diff --git a/modules/openapi-generator/src/main/resources/python-flask/setup.mustache b/modules/openapi-generator/src/main/resources/python-flask/setup.mustache
index 722f43969c32..ec06a7798b2e 100644
--- a/modules/openapi-generator/src/main/resources/python-flask/setup.mustache
+++ b/modules/openapi-generator/src/main/resources/python-flask/setup.mustache
@@ -16,8 +16,7 @@ VERSION = "{{packageVersion}}"
 REQUIRES = [
     "connexion>=2.0.2",
     "swagger-ui-bundle>=0.0.2",
-    "python_dateutil>=2.6.0"{{#supportPython2}},
-    "typing>=3.5.2.2"{{/supportPython2}}
+    "python_dateutil>=2.6.0"
 ]
 
 setup(
diff --git a/modules/openapi-generator/src/main/resources/python-flask/test-requirements.mustache b/modules/openapi-generator/src/main/resources/python-flask/test-requirements.mustache
index 7157c73aa34b..1de59f85590f 100644
--- a/modules/openapi-generator/src/main/resources/python-flask/test-requirements.mustache
+++ b/modules/openapi-generator/src/main/resources/python-flask/test-requirements.mustache
@@ -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
 {{/useNose}}
-Flask-Testing==0.8.0
+Flask-Testing==0.8.1
diff --git a/modules/openapi-generator/src/main/resources/python-flask/tox.mustache b/modules/openapi-generator/src/main/resources/python-flask/tox.mustache
index d342cd5f573c..76e368c23931 100644
--- a/modules/openapi-generator/src/main/resources/python-flask/tox.mustache
+++ b/modules/openapi-generator/src/main/resources/python-flask/tox.mustache
@@ -1,5 +1,5 @@
 [tox]
-envlist = {{#supportPython2}}py27, {{/supportPython2}}py3
+envlist = py3
 skipsdist=True
 
 [testenv]
diff --git a/modules/openapi-generator/src/main/resources/python-flask/travis.mustache b/modules/openapi-generator/src/main/resources/python-flask/travis.mustache
index e03b816ecc01..ad71ee5ca083 100644
--- a/modules/openapi-generator/src/main/resources/python-flask/travis.mustache
+++ b/modules/openapi-generator/src/main/resources/python-flask/travis.mustache
@@ -1,9 +1,6 @@
 # ref: https://docs.travis-ci.com/user/languages/python
 language: python
 python:
-{{#supportPython2}}
-  - "2.7"
-{{/supportPython2}}
   - "3.2"
   - "3.3"
   - "3.4"
diff --git a/pom.xml b/pom.xml
index 6a24e4614afb..86be53812d30 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1131,11 +1131,6 @@
                 <module>samples/client/petstore/php/OpenAPIClient-php</module>
                 <!-- TODO: move to github action or circleci
                 <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
                 <module>samples/server/petstore/php-slim4</module>
                 <module>samples/server/petstore/php-laravel</module>
@@ -1171,6 +1166,10 @@
             </activation>
             <modules>
                 <!-- 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-vertx-web</module>
                 <module>samples/server/petstore/java-inflector</module>
diff --git a/samples/server/petstore/python-aiohttp-srclayout/Makefile b/samples/server/petstore/python-aiohttp-srclayout/Makefile
index e73e0b9b3075..4e8fafc39bfc 100644
--- a/samples/server/petstore/python-aiohttp-srclayout/Makefile
+++ b/samples/server/petstore/python-aiohttp-srclayout/Makefile
@@ -12,7 +12,7 @@ clean:
 		find . -name "__pycache__" -delete
 
 venv: 
-		python -m venv $(VENV)
+		python3 -m venv $(VENV)
 
 test: clean venv
 		bash ./test_python3.sh
diff --git a/samples/server/petstore/python-aiohttp-srclayout/requirements.txt b/samples/server/petstore/python-aiohttp-srclayout/requirements.txt
index e0dd796ca9fb..70c264978d3b 100644
--- a/samples/server/petstore/python-aiohttp-srclayout/requirements.txt
+++ b/samples/server/petstore/python-aiohttp-srclayout/requirements.txt
@@ -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
 # 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
diff --git a/samples/server/petstore/python-aiohttp-srclayout/setup.py b/samples/server/petstore/python-aiohttp-srclayout/setup.py
index 6f62aec44149..5cfff33cdbe3 100644
--- a/samples/server/petstore/python-aiohttp-srclayout/setup.py
+++ b/samples/server/petstore/python-aiohttp-srclayout/setup.py
@@ -14,9 +14,9 @@
 # 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(
diff --git a/samples/server/petstore/python-aiohttp-srclayout/test-requirements.txt b/samples/server/petstore/python-aiohttp-srclayout/test-requirements.txt
index 31b28baaf284..bb7df90d4b2c 100644
--- a/samples/server/petstore/python-aiohttp-srclayout/test-requirements.txt
+++ b/samples/server/petstore/python-aiohttp-srclayout/test-requirements.txt
@@ -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-randomly==1.2.3 # needed for python 2.7+3.4
+pytest-randomly>=1.2.3
 pytest-aiohttp>=0.3.0
diff --git a/samples/server/petstore/python-aiohttp/Makefile b/samples/server/petstore/python-aiohttp/Makefile
index e73e0b9b3075..4e8fafc39bfc 100644
--- a/samples/server/petstore/python-aiohttp/Makefile
+++ b/samples/server/petstore/python-aiohttp/Makefile
@@ -12,7 +12,7 @@ clean:
 		find . -name "__pycache__" -delete
 
 venv: 
-		python -m venv $(VENV)
+		python3 -m venv $(VENV)
 
 test: clean venv
 		bash ./test_python3.sh
diff --git a/samples/server/petstore/python-aiohttp/requirements.txt b/samples/server/petstore/python-aiohttp/requirements.txt
index e0dd796ca9fb..70c264978d3b 100644
--- a/samples/server/petstore/python-aiohttp/requirements.txt
+++ b/samples/server/petstore/python-aiohttp/requirements.txt
@@ -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
 # 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
diff --git a/samples/server/petstore/python-aiohttp/setup.py b/samples/server/petstore/python-aiohttp/setup.py
index b6a25d8966e5..d464315706af 100644
--- a/samples/server/petstore/python-aiohttp/setup.py
+++ b/samples/server/petstore/python-aiohttp/setup.py
@@ -14,9 +14,9 @@
 # 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(
diff --git a/samples/server/petstore/python-aiohttp/test-requirements.txt b/samples/server/petstore/python-aiohttp/test-requirements.txt
index 31b28baaf284..bb7df90d4b2c 100644
--- a/samples/server/petstore/python-aiohttp/test-requirements.txt
+++ b/samples/server/petstore/python-aiohttp/test-requirements.txt
@@ -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-randomly==1.2.3 # needed for python 2.7+3.4
+pytest-randomly>=1.2.3
 pytest-aiohttp>=0.3.0
diff --git a/samples/server/petstore/python-aiohttp/tests/test_pet_controller.py b/samples/server/petstore/python-aiohttp/tests/test_pet_controller.py
index 5f6384a34f67..de3d3eeb82e9 100644
--- a/samples/server/petstore/python-aiohttp/tests/test_pet_controller.py
+++ b/samples/server/petstore/python-aiohttp/tests/test_pet_controller.py
@@ -9,7 +9,7 @@
 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):
     """Test case for add_pet
 
@@ -67,7 +67,7 @@ async def test_find_pets_by_status(client):
 
     Finds Pets by status
     """
-    params = [('status', 'available')]
+    params = [('status', ['available'])]
     headers = { 
         'Accept': 'application/json',
         'Authorization': 'Bearer special-key',
@@ -86,7 +86,7 @@ async def test_find_pets_by_tags(client):
 
     Finds Pets by tags
     """
-    params = [('tags', 'tags_example')]
+    params = [('tags', ['tags_example'])]
     headers = { 
         'Accept': 'application/json',
         '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')
 
 
-@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):
     """Test case for update_pet
 
@@ -189,7 +189,7 @@ async def test_upload_file(client):
     }
     data = FormData()
     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(
         method='POST',
         path='/v2/pet/{pet_id}/uploadImage'.format(pet_id=56),
diff --git a/samples/server/petstore/python-aiohttp/tests/test_store_controller.py b/samples/server/petstore/python-aiohttp/tests/test_store_controller.py
index 9d376a5f7a5b..9625a8b35e62 100644
--- a/samples/server/petstore/python-aiohttp/tests/test_store_controller.py
+++ b/samples/server/petstore/python-aiohttp/tests/test_store_controller.py
@@ -49,7 +49,7 @@ async def test_get_order_by_id(client):
     }
     response = await client.request(
         method='GET',
-        path='/v2/store/order/{order_id}'.format(order_id=5),
+        path='/v2/store/order/{order_id}'.format(order_id=1),
         headers=headers,
         )
     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
     """
-    body = {}
+    body = openapi_server.Order()
     headers = { 
         'Accept': 'application/json',
         'Content-Type': 'application/json',
diff --git a/samples/server/petstore/python-aiohttp/tests/test_user_controller.py b/samples/server/petstore/python-aiohttp/tests/test_user_controller.py
index 6564329315ed..c695e4f0c951 100644
--- a/samples/server/petstore/python-aiohttp/tests/test_user_controller.py
+++ b/samples/server/petstore/python-aiohttp/tests/test_user_controller.py
@@ -13,7 +13,7 @@ async def test_create_user(client):
 
     Create user
     """
-    body = {}
+    body = openapi_server.User()
     headers = { 
         '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
     """
-    body = [{}]
+    body = [openapi_server.User()]
     headers = { 
         '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
     """
-    body = [{}]
+    body = [openapi_server.User()]
     headers = { 
         'Content-Type': 'application/json',
     }
@@ -135,7 +135,7 @@ async def test_update_user(client):
 
     Updated user
     """
-    body = {}
+    body = openapi_server.User()
     headers = { 
         'Content-Type': 'application/json',
     }
diff --git a/samples/server/petstore/python-blueplanet/app/openapi_server/test/test_pet_controller.py b/samples/server/petstore/python-blueplanet/app/openapi_server/test/test_pet_controller.py
index 34b8e534e666..70ce6ad26abb 100644
--- a/samples/server/petstore/python-blueplanet/app/openapi_server/test/test_pet_controller.py
+++ b/samples/server/petstore/python-blueplanet/app/openapi_server/test/test_pet_controller.py
@@ -61,7 +61,7 @@ def test_find_pets_by_status(self):
 
         Finds Pets by status
         """
-        query_string = [('status', 'available')]
+        query_string = [('status', ['available'])]
         response = self.client.open(
             '/v2/pet/findByStatus',
             method='GET',
@@ -74,7 +74,7 @@ def test_find_pets_by_tags(self):
 
         Finds Pets by tags
         """
-        query_string = [('tags', 'tags_example')]
+        query_string = [('tags', ['tags_example'])]
         response = self.client.open(
             '/v2/pet/findByTags',
             method='GET',
@@ -144,7 +144,7 @@ def test_upload_file(self):
         uploads an image
         """
         data = dict(additional_metadata='additional_metadata_example',
-                    file=(BytesIO(b'some file data'), 'file.txt'))
+                    file='/path/to/file')
         response = self.client.open(
             '/v2/pet/{pet_id}/uploadImage'.format(pet_id=56),
             method='POST',
diff --git a/samples/server/petstore/python-blueplanet/app/openapi_server/test/test_store_controller.py b/samples/server/petstore/python-blueplanet/app/openapi_server/test/test_store_controller.py
index 3695ff4a3b3a..57bd3fa8f86f 100644
--- a/samples/server/petstore/python-blueplanet/app/openapi_server/test/test_store_controller.py
+++ b/samples/server/petstore/python-blueplanet/app/openapi_server/test/test_store_controller.py
@@ -40,7 +40,7 @@ def test_get_order_by_id(self):
         Find purchase order by ID
         """
         response = self.client.open(
-            '/v2/store/order/{order_id}'.format(order_id=5),
+            '/v2/store/order/{order_id}'.format(order_id=1),
             method='GET')
         self.assert200(response,
                        'Response body is : ' + response.data.decode('utf-8'))
@@ -50,7 +50,7 @@ def test_place_order(self):
 
         Place an order for a pet
         """
-        body = {}
+        body = openapi_server.Order()
         response = self.client.open(
             '/v2/store/order',
             method='POST',
diff --git a/samples/server/petstore/python-blueplanet/app/openapi_server/test/test_user_controller.py b/samples/server/petstore/python-blueplanet/app/openapi_server/test/test_user_controller.py
index 1ef108621bdf..e96791b1cc0f 100644
--- a/samples/server/petstore/python-blueplanet/app/openapi_server/test/test_user_controller.py
+++ b/samples/server/petstore/python-blueplanet/app/openapi_server/test/test_user_controller.py
@@ -17,7 +17,7 @@ def test_create_user(self):
 
         Create user
         """
-        body = {}
+        body = openapi_server.User()
         response = self.client.open(
             '/v2/user',
             method='POST',
@@ -31,7 +31,7 @@ def test_create_users_with_array_input(self):
 
         Creates list of users with given input array
         """
-        body = []
+        body = [openapi_server.User()]
         response = self.client.open(
             '/v2/user/createWithArray',
             method='POST',
@@ -45,7 +45,7 @@ def test_create_users_with_list_input(self):
 
         Creates list of users with given input array
         """
-        body = []
+        body = [openapi_server.User()]
         response = self.client.open(
             '/v2/user/createWithList',
             method='POST',
@@ -106,7 +106,7 @@ def test_update_user(self):
 
         Updated user
         """
-        body = {}
+        body = openapi_server.User()
         response = self.client.open(
             '/v2/user/{username}'.format(username='username_example'),
             method='PUT',
diff --git a/samples/server/petstore/python-flask/openapi_server/models/base_model_.py b/samples/server/petstore/python-flask/openapi_server/models/base_model_.py
index 961abbf32231..916e582ec27f 100644
--- a/samples/server/petstore/python-flask/openapi_server/models/base_model_.py
+++ b/samples/server/petstore/python-flask/openapi_server/models/base_model_.py
@@ -8,7 +8,7 @@
 T = typing.TypeVar('T')
 
 
-class Model():
+class Model(object):
     # openapiTypes: The key is attribute name and the
     # value is attribute type.
     openapi_types: typing.Dict[str, type] = {}
diff --git a/samples/server/petstore/python-flask/openapi_server/test/test_pet_controller.py b/samples/server/petstore/python-flask/openapi_server/test/test_pet_controller.py
index f29ac97214ba..d1eb1d326681 100644
--- a/samples/server/petstore/python-flask/openapi_server/test/test_pet_controller.py
+++ b/samples/server/petstore/python-flask/openapi_server/test/test_pet_controller.py
@@ -14,7 +14,7 @@
 class TestPetController(BaseTestCase):
     """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):
         """Test case for add_pet
 
@@ -89,7 +89,7 @@ def test_find_pets_by_tags(self):
 
         Finds Pets by tags
         """
-        query_string = [('tags', 'tags_example')]
+        query_string = [('tags', ['tags_example'])]
         headers = { 
             'Accept': 'application/json',
             'Authorization': 'Bearer special-key',
@@ -118,7 +118,7 @@ def test_get_pet_by_id(self):
         self.assert200(response,
                        '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):
         """Test case for update_pet
 
@@ -187,7 +187,7 @@ def test_upload_file(self):
             'Authorization': 'Bearer special-key',
         }
         data = dict(additional_metadata='additional_metadata_example',
-                    file=(BytesIO(b'some file data'), 'file.txt'))
+                    file='/path/to/file')
         response = self.client.open(
             '/v2/pet/{pet_id}/uploadImage'.format(pet_id=56),
             method='POST',
diff --git a/samples/server/petstore/python-flask/openapi_server/test/test_store_controller.py b/samples/server/petstore/python-flask/openapi_server/test/test_store_controller.py
index e2d0c7ddd372..43867b1d98e9 100644
--- a/samples/server/petstore/python-flask/openapi_server/test/test_store_controller.py
+++ b/samples/server/petstore/python-flask/openapi_server/test/test_store_controller.py
@@ -52,7 +52,7 @@ def test_get_order_by_id(self):
             'Accept': 'application/json',
         }
         response = self.client.open(
-            '/v2/store/order/{order_id}'.format(order_id=5),
+            '/v2/store/order/{order_id}'.format(order_id=1),
             method='GET',
             headers=headers)
         self.assert200(response,
@@ -64,7 +64,7 @@ def test_place_order(self):
 
         Place an order for a pet
         """
-        body = {}
+        body = openapi_server.Order()
         headers = { 
             'Accept': 'application/json',
             'Content-Type': 'application/json',
diff --git a/samples/server/petstore/python-flask/openapi_server/test/test_user_controller.py b/samples/server/petstore/python-flask/openapi_server/test/test_user_controller.py
index 172ff22d13d0..010a72b03069 100644
--- a/samples/server/petstore/python-flask/openapi_server/test/test_user_controller.py
+++ b/samples/server/petstore/python-flask/openapi_server/test/test_user_controller.py
@@ -19,7 +19,7 @@ def test_create_user(self):
 
         Create user
         """
-        body = {}
+        body = openapi_server.User()
         headers = { 
             'Content-Type': 'application/json',
         }
@@ -38,7 +38,7 @@ def test_create_users_with_array_input(self):
 
         Creates list of users with given input array
         """
-        body = [{}]
+        body = [openapi_server.User()]
         headers = { 
             'Content-Type': 'application/json',
         }
@@ -57,7 +57,7 @@ def test_create_users_with_list_input(self):
 
         Creates list of users with given input array
         """
-        body = [{}]
+        body = [openapi_server.User()]
         headers = { 
             'Content-Type': 'application/json',
         }
@@ -137,7 +137,7 @@ def test_update_user(self):
 
         Updated user
         """
-        body = {}
+        body = openapi_server.User()
         headers = { 
             'Content-Type': 'application/json',
         }
diff --git a/samples/server/petstore/python-flask/requirements.txt b/samples/server/petstore/python-flask/requirements.txt
index 70e1f0c55402..be4c8a3a02c1 100644
--- a/samples/server/petstore/python-flask/requirements.txt
+++ b/samples/server/petstore/python-flask/requirements.txt
@@ -8,4 +8,4 @@ werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
 swagger-ui-bundle >= 0.0.2
 python_dateutil >= 2.6.0
 setuptools >= 21.0.0
-Flask == 1.1.2
+Flask == 2.1.1
diff --git a/samples/server/petstore/python-flask/test-requirements.txt b/samples/server/petstore/python-flask/test-requirements.txt
index 0970f28c7c5a..58f51d6a0027 100644
--- a/samples/server/petstore/python-flask/test-requirements.txt
+++ b/samples/server/petstore/python-flask/test-requirements.txt
@@ -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-randomly==1.2.3 # needed for python 2.7+3.4
-Flask-Testing==0.8.0
+pytest-randomly>=1.2.3
+Flask-Testing==0.8.1