Skip to content

Commit 63859d6

Browse files
sebastien-rossetwing328
authored andcommitted
Add python-experimental-openapiv3-sample (#4992)
Add python-experimental-openapiv3-sample Add missing files for the Python samples Add python-experimental-petstore.bat for openapi v3 Add python-experimental samples openapi v3 Add python-experimental samples openapi v3 Add python-experimental samples openapi v3. Address review comments add missing files for test purpose fix python formatting issues fix python formatting issues fix python formatting issues Fix unit tests fix python formatting issues fix python formatting issues fix python formatting issues fix 'line too long' pep8 error address PR comments for pep8 'line too long' problem regenerate samples execute samples scripts dummy commit to retrigger circleci Revert dummy commit, it didn't help.
1 parent 95bd32d commit 63859d6

File tree

226 files changed

+22417
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+22417
-214
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
echo "# START SCRIPT: $SCRIPT"
5+
6+
while [ -h "$SCRIPT" ] ; do
7+
ls=`ls -ld "$SCRIPT"`
8+
link=`expr "$ls" : '.*-> \(.*\)$'`
9+
if expr "$link" : '/.*' > /dev/null; then
10+
SCRIPT="$link"
11+
else
12+
SCRIPT=`dirname "$SCRIPT"`/"$link"
13+
fi
14+
done
15+
16+
if [ ! -d "${APP_DIR}" ]; then
17+
APP_DIR=`dirname "$SCRIPT"`/..
18+
APP_DIR=`cd "${APP_DIR}"; pwd`
19+
fi
20+
21+
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
22+
23+
if [ ! -f "$executable" ]
24+
then
25+
mvn clean package
26+
fi
27+
28+
# if you've executed sbt assembly previously it will use that instead.
29+
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30+
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 $@"
31+
32+
java $JAVA_OPTS -jar $executable $ags
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
2+
3+
If Not Exist %executable% (
4+
mvn clean package
5+
)
6+
7+
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
8+
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
9+
10+
java %JAVA_OPTS% -jar %executable% %ags%

bin/utils/ensure-up-to-date

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ declare -a samples=(
4141
"${root}/bin/python-petstore-all.sh"
4242
"${root}/bin/python-server-all.sh"
4343
"${root}/bin/openapi3/python-petstore.sh"
44+
"${root}/bin/openapi3/python-experimental-petstore.sh"
4445
"${root}/bin/php-petstore.sh"
4546
"${root}/bin/php-silex-petstore-server.sh"
4647
"${root}/bin/php-symfony-petstore.sh"

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ private String robustImport(String name) {
277277
// name looks like cat.Cat
278278
String moduleName = name.split("\\.")[0];
279279
// https://exceptionshub.com/circular-or-cyclic-imports-in-python.html
280-
String modelImport = "try:\n from " + modelPackage() + " import "+ moduleName+ "\nexcept ImportError:\n "+moduleName+" = sys.modules['"+modelPackage() + "."+ moduleName+"']";
280+
String modelImport = "try:\n from " + modelPackage() +
281+
" import " + moduleName+ "\nexcept ImportError:\n " +
282+
moduleName + " = sys.modules[\n '" + modelPackage() + "." + moduleName + "']";
281283
return modelImport;
282284
}
283285

modules/openapi-generator/src/main/resources/python/python-experimental/api.mustache

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ class {{classname}}(object):
108108
)
109109
kwargs['_host_index'] = kwargs.get('_host_index', 0)
110110
{{#requiredParams}}
111-
kwargs['{{paramName}}'] = {{paramName}}
111+
kwargs['{{paramName}}'] = \
112+
{{paramName}}
112113
{{/requiredParams}}
113114
return self.call_with_http_info(**kwargs)
114115

@@ -216,7 +217,8 @@ class {{classname}}(object):
216217
},
217218
'openapi_types': {
218219
{{#allParams}}
219-
'{{paramName}}': ({{{dataType}}},),
220+
'{{paramName}}':
221+
({{{dataType}}},),
220222
{{/allParams}}
221223
},
222224
'attribute_map': {

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,7 @@
10601060
<module>samples/client/petstore/python-asyncio</module>
10611061
<module>samples/client/petstore/python-tornado</module>
10621062
<module>samples/openapi3/client/petstore/python</module>
1063+
<module>samples/openapi3/client/petstore/python-experimental</module>
10631064
<module>samples/client/petstore/typescript-fetch/builds/default</module>
10641065
<module>samples/client/petstore/typescript-fetch/builds/es6-target</module>
10651066
<module>samples/client/petstore/typescript-fetch/builds/with-npm-version</module>

samples/client/petstore/python-experimental/petstore_api/api/another_fake_api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ def __call_123_test_special_tags(self, body, **kwargs): # noqa: E501
102102
'_check_return_type', True
103103
)
104104
kwargs['_host_index'] = kwargs.get('_host_index', 0)
105-
kwargs['body'] = body
105+
kwargs['body'] = \
106+
body
106107
return self.call_with_http_info(**kwargs)
107108

108109
self.call_123_test_special_tags = Endpoint(
@@ -134,7 +135,8 @@ def __call_123_test_special_tags(self, body, **kwargs): # noqa: E501
134135
'allowed_values': {
135136
},
136137
'openapi_types': {
137-
'body': (client.Client,),
138+
'body':
139+
(client.Client,),
138140
},
139141
'attribute_map': {
140142
},

0 commit comments

Comments
 (0)