forked from com2ghz/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pythonSrcRoot option to python servers (aiohttp/flask/blueplanet)…
… to support src/ layout projects [and reenable/fix all python server tests] (OpenAPITools#5423) * python server: Add pythonSrcRoot option This will allow the python project to be in a subdirectory (as specified in pythonSrcRoot). That could mean following the src layout with sources under src/ or lib/. Multi-language projects might use a sub directory like python/, or whatever makes sense for the project. By default, the pythonSrcRoot is "", meaning the existing behavior is the default. * python server: update template files to support pythonSrcRoot * python server: update docs to add pythonSrcRoot option * python server: add pythonSrcRoot sample script * python server: build sample srclayout project * [Python] copy test files preserving history * [Python] Make a conflict to preserve file copy history * [Python] customize pom.xml for src layout tests * [Python] add python-aiohttp-srclayout tests * [Python] Fix server tests by updating requirements Reverts the PR that disabled python2 server tests: OpenAPITools#4949 Reverts commits that disabled python3 server tests: 9adfedb 17ee990 Issue about the python 3 tests: OpenAPITools#5235 I couldn't find an issue about the python2 tests being disabled. I'm guessing build errors like the following were the trigger: https://travis-ci.org/github/OpenAPITools/openapi-generator/builds/634238181 Let's see what breaks! * [Python] Copy setup.py to python-aiohttp * [Python] Save history while copying setup.py to python-aiohttp * [Python] Add aiohttp server setup.py * [Python] Fix python server tests with src layout * [Python] bump Flask-Testing version * [Python] Pin pyyaml for py2.7 flask server * [Python] simplify flask server requirements * consolidate server tests * [Python] rebuild python server samples * [Python] Fix python server requirements for older pythons Documented minimum python version for our aiohttp server is 3.5. Documented minimum python version for our flask server is 3.4. Connexion 2.3 is the last version to support python 3.4 and 3.5, so fix the version pinning to correctly select <=2.3 for these EOL python versions. Newer pythons should get the latest if possible as there many relevant bug fixes. Werkzeug also needs to be pinned for these old versions in the aiohttp server just like for the flask server. 3.4 and 3.5 are EOL. We really should increase the minimum supported version, but that is for another PR to do.
- Loading branch information
1 parent
a59d082
commit 867e155
Showing
63 changed files
with
3,260 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/sh | ||
|
||
SCRIPT="$0" | ||
echo "# START SCRIPT: $SCRIPT" | ||
|
||
while [ -h "$SCRIPT" ] ; do | ||
ls=`ls -ld "$SCRIPT"` | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
SCRIPT="$link" | ||
else | ||
SCRIPT=`dirname "$SCRIPT"`/"$link" | ||
fi | ||
done | ||
|
||
if [ ! -d "${APP_DIR}" ]; then | ||
APP_DIR=`dirname "$SCRIPT"`/.. | ||
APP_DIR=`cd "${APP_DIR}"; pwd` | ||
fi | ||
|
||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" | ||
|
||
if [ ! -f "$executable" ] | ||
then | ||
mvn -B clean package | ||
fi | ||
|
||
generator=python-aiohttp | ||
input=modules/openapi-generator/src/test/resources/2_0/petstore.yaml | ||
out_folder=samples/server/petstore/${generator}-srclayout | ||
resources=modules/openapi-generator/src/main/resources/${generator} | ||
|
||
# if you've executed sbt assembly previously it will use that instead. | ||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties -Dservice" | ||
ags="generate -t $resources -i $input -g $generator -o $out_folder --additional-properties pythonSrcRoot=src $@" | ||
|
||
rm -rf $out_folder/.openapi* | ||
rm -rf $out_folder/openapi_server | ||
rm -rf $out_folder/tests* | ||
rm $out_folder/README.md | ||
rm $out_folder/requirements.txt | ||
rm $out_folder/test-requirements.txt | ||
|
||
java $JAVA_OPTS -jar $executable $ags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#!/bin/sh | ||
|
||
./bin/python-server-aiohttp-petstore.sh | ||
./bin/python-server-aiohttp-srclayout-petstore.sh | ||
./bin/python-server-flask-petstore.sh | ||
./bin/python-server-flask-petstore-python2.sh | ||
./bin/python-server-blueplanet-petstore.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
modules/openapi-generator/src/main/resources/python-aiohttp/requirements.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
connexion[aiohttp,swagger-ui] == 2.0.2 | ||
swagger-ui-bundle == 0.0.2 | ||
aiohttp_jinja2 == 1.1.0 | ||
connexion[aiohttp,swagger-ui] >= 2.6.0; python_version>="3.6" | ||
# 2.3 is the last version that supports python 3.5 | ||
connexion[aiohttp,swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=="3.4" | ||
# 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 | ||
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4" | ||
swagger-ui-bundle == 0.0.6 | ||
aiohttp_jinja2 == 1.2.0 |
40 changes: 40 additions & 0 deletions
40
modules/openapi-generator/src/main/resources/python-aiohttp/setup.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# coding: utf-8 | ||
|
||
import sys | ||
from setuptools import setup, find_packages | ||
|
||
NAME = "{{packageName}}" | ||
VERSION = "{{packageVersion}}" | ||
{{#apiInfo}}{{#apis}}{{^hasMore}} | ||
# To install the library, run the following | ||
# | ||
# python setup.py install | ||
# | ||
# prerequisite: setuptools | ||
# http://pypi.python.org/pypi/setuptools | ||
|
||
REQUIRES = [ | ||
"connexion==2.6.0", | ||
"swagger-ui-bundle==0.0.6", | ||
"aiohttp_jinja2==1.2.0", | ||
] | ||
|
||
setup( | ||
name=NAME, | ||
version=VERSION, | ||
description="{{appName}}", | ||
author_email="{{infoEmail}}", | ||
url="{{packageUrl}}", | ||
keywords=["OpenAPI", "{{appName}}"], | ||
install_requires=REQUIRES, | ||
packages=find_packages({{#pythonSrcRoot}}"{{{.}}}"{{/pythonSrcRoot}}),{{#pythonSrcRoot}} | ||
package_dir={"": "{{{.}}}"},{{/pythonSrcRoot}} | ||
package_data={'': ['{{#pythonSrcRoot}}{{{.}}}/{{/pythonSrcRoot}}openapi/openapi.yaml']}, | ||
include_package_data=True, | ||
entry_points={ | ||
'console_scripts': ['{{packageName}}={{packageName}}.__main__:main']}, | ||
long_description="""\ | ||
{{appDescription}} | ||
""" | ||
) | ||
{{/hasMore}}{{/apis}}{{/apiInfo}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
18 changes: 14 additions & 4 deletions
18
modules/openapi-generator/src/main/resources/python-flask/requirements.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
connexion >= 2.6.0; python_version>="3.6" | ||
connexion >= 2.3.0; python_version=="3.5" | ||
connexion >= 2.3.0; python_version=="3.4" | ||
connexion == 2.4.0; python_version<="2.7" | ||
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 | ||
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4" | ||
swagger-ui-bundle >= 0.0.2 | ||
python_dateutil >= 2.6.0 | ||
{{#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
modules/openapi-generator/src/main/resources/python-flask/tox.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
[tox] | ||
envlist = {{#supportPython2}}py27, {{/supportPython2}}py3 | ||
skipsdist=True | ||
|
||
[testenv] | ||
deps=-r{toxinidir}/requirements.txt | ||
-r{toxinidir}/test-requirements.txt | ||
{toxinidir} | ||
|
||
commands= | ||
{{^useNose}}pytest --cov={{{packageName}}}{{/useNose}}{{#useNose}}nosetests{{/useNose}} | ||
{{^useNose}}pytest --cov={{{pythonSrcRoot}}}{{{packageName}}}{{/useNose}}{{#useNose}}nosetests{{/useNose}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.