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

[Python] Add python experimental openapiv3 sample and fix PEP8 formatting issues #4992

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
32 changes: 32 additions & 0 deletions bin/openapi3/python-experimental-petstore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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 clean package
fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples/openapi3/client/petstore/python-experimental/ --additional-properties packageName=petstore_api $@"

java $JAVA_OPTS -jar $executable $ags
10 changes: 10 additions & 0 deletions bin/openapi3/windows/python-experimental-petstore.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples\openapi3\client\petstore\python-experimental --additional-properties packageName=petstore_api

java %JAVA_OPTS% -jar %executable% %ags%
1 change: 1 addition & 0 deletions bin/utils/ensure-up-to-date
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ declare -a samples=(
"${root}/bin/python-petstore-all.sh"
"${root}/bin/python-server-all.sh"
"${root}/bin/openapi3/python-petstore.sh"
"${root}/bin/openapi3/python-experimental-petstore.sh"
"${root}/bin/php-petstore.sh"
"${root}/bin/php-silex-petstore-server.sh"
"${root}/bin/php-symfony-petstore.sh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ private String robustImport(String name) {
// name looks like cat.Cat
String moduleName = name.split("\\.")[0];
// https://exceptionshub.com/circular-or-cyclic-imports-in-python.html
String modelImport = "try:\n from " + modelPackage() + " import "+ moduleName+ "\nexcept ImportError:\n "+moduleName+" = sys.modules['"+modelPackage() + "."+ moduleName+"']";
String modelImport = "try:\n from " + modelPackage() +
" import " + moduleName+ "\nexcept ImportError:\n " +
moduleName + " = sys.modules[\n '" + modelPackage() + "." + moduleName + "']";
return modelImport;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class {{classname}}(object):
)
kwargs['_host_index'] = kwargs.get('_host_index', 0)
{{#requiredParams}}
kwargs['{{paramName}}'] = {{paramName}}
kwargs['{{paramName}}'] = \
{{paramName}}
{{/requiredParams}}
return self.call_with_http_info(**kwargs)

Expand Down Expand Up @@ -216,7 +217,8 @@ class {{classname}}(object):
},
'openapi_types': {
{{#allParams}}
'{{paramName}}': ({{{dataType}}},),
'{{paramName}}':
({{{dataType}}},),
{{/allParams}}
},
'attribute_map': {
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@
<module>samples/client/petstore/python-asyncio</module>
<module>samples/client/petstore/python-tornado</module>
<module>samples/openapi3/client/petstore/python</module>
<module>samples/openapi3/client/petstore/python-experimental</module>
<module>samples/client/petstore/typescript-fetch/builds/default</module>
<module>samples/client/petstore/typescript-fetch/builds/es6-target</module>
<module>samples/client/petstore/typescript-fetch/builds/with-npm-version</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def __call_123_test_special_tags(self, body, **kwargs): # noqa: E501
'_check_return_type', True
)
kwargs['_host_index'] = kwargs.get('_host_index', 0)
kwargs['body'] = body
kwargs['body'] = \
body
return self.call_with_http_info(**kwargs)

self.call_123_test_special_tags = Endpoint(
Expand Down Expand Up @@ -134,7 +135,8 @@ def __call_123_test_special_tags(self, body, **kwargs): # noqa: E501
'allowed_values': {
},
'openapi_types': {
'body': (client.Client,),
'body':
(client.Client,),
},
'attribute_map': {
},
Expand Down
Loading