Skip to content

Commit b978914

Browse files
committed
Merge pull request #3061 from taxpon/issue-3055
[Python] Fix bug of test files about packageName
2 parents 6a73f29 + df11034 commit b978914

Some content is hidden

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

78 files changed

+260
-278
lines changed

bin/python-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ fi
2626

2727
# if you've executed sbt assembly previously it will use that instead.
2828
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29-
ags="$@ generate -t modules/swagger-codegen/src/main/resources/python -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l python -o samples/client/petstore/python"
29+
ags="$@ generate -t modules/swagger-codegen/src/main/resources/python -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l python -o samples/client/petstore/python -DpackageName=petstore_api"
3030

3131
java $JAVA_OPTS -jar $executable $ags

modules/swagger-codegen/src/main/resources/python/api_test.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import os
88
import sys
99
import unittest
1010

11-
import swagger_client
12-
from swagger_client.rest import ApiException
13-
from swagger_client.apis.{{classVarName}} import {{classname}}
11+
import {{packageName}}
12+
from {{packageName}}.rest import ApiException
13+
from {{packageName}}.apis.{{classVarName}} import {{classname}}
1414

1515

1616
class {{#operations}}Test{{classname}}(unittest.TestCase):
1717
""" {{classname}} unit test stubs """
1818

1919
def setUp(self):
20-
self.api = swagger_client.apis.{{classVarName}}.{{classname}}()
20+
self.api = {{packageName}}.apis.{{classVarName}}.{{classname}}()
2121

2222
def tearDown(self):
2323
pass

modules/swagger-codegen/src/main/resources/python/model_test.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import unittest
1010

1111
{{#models}}
1212
{{#model}}
13-
import swagger_client
14-
from swagger_client.rest import ApiException
15-
from swagger_client.models.{{classFilename}} import {{classname}}
13+
import {{packageName}}
14+
from {{packageName}}.rest import ApiException
15+
from {{packageName}}.models.{{classFilename}} import {{classname}}
1616

1717

1818
class Test{{classname}}(unittest.TestCase):
@@ -28,7 +28,7 @@ class Test{{classname}}(unittest.TestCase):
2828
"""
2929
Test {{classname}}
3030
"""
31-
model = swagger_client.models.{{classFilename}}.{{classname}}()
31+
model = {{packageName}}.models.{{classFilename}}.{{classname}}()
3232

3333
{{/model}}
3434
{{/models}}

samples/client/petstore/python/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ nosetests.xml
4444
coverage.xml
4545
*,cover
4646
.hypothesis/
47+
venv/
48+
.python-version
4749

4850
# Translations
4951
*.mo

samples/client/petstore/python/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https://
55

66
- API version: 1.0.0
77
- Package version: 1.0.0
8-
- Build date: 2016-06-07T08:27:42.099+09:00
8+
- Build date: 2016-06-07T00:29:52.148+09:00
99
- Build package: class io.swagger.codegen.languages.PythonClientCodegen
1010

1111
## Requirements.

samples/client/petstore/python/docs/FakeApi.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# swagger_client.FakeApi
1+
# petstore_api.FakeApi
22

33
All URIs are relative to *http://petstore.swagger.io/v2*
44

@@ -17,12 +17,12 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
1717
### Example
1818
```python
1919
import time
20-
import swagger_client
21-
from swagger_client.rest import ApiException
20+
import petstore_api
21+
from petstore_api.rest import ApiException
2222
from pprint import pprint
2323

2424
# create an instance of the API class
25-
api_instance = swagger_client.FakeApi()
25+
api_instance = petstore_api.FakeApi()
2626
number = 3.4 # float | None
2727
double = 1.2 # float | None
2828
string = 'string_example' # str | None

samples/client/petstore/python/docs/PetApi.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# swagger_client.PetApi
1+
# petstore_api.PetApi
22

33
All URIs are relative to *http://petstore.swagger.io/v2*
44

@@ -24,16 +24,16 @@ Add a new pet to the store
2424
### Example
2525
```python
2626
import time
27-
import swagger_client
28-
from swagger_client.rest import ApiException
27+
import petstore_api
28+
from petstore_api.rest import ApiException
2929
from pprint import pprint
3030

3131
# Configure OAuth2 access token for authorization: petstore_auth
32-
swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'
32+
petstore_api.configuration.access_token = 'YOUR_ACCESS_TOKEN'
3333

3434
# create an instance of the API class
35-
api_instance = swagger_client.PetApi()
36-
body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store
35+
api_instance = petstore_api.PetApi()
36+
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
3737

3838
try:
3939
# Add a new pet to the store
@@ -73,15 +73,15 @@ Deletes a pet
7373
### Example
7474
```python
7575
import time
76-
import swagger_client
77-
from swagger_client.rest import ApiException
76+
import petstore_api
77+
from petstore_api.rest import ApiException
7878
from pprint import pprint
7979

8080
# Configure OAuth2 access token for authorization: petstore_auth
81-
swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'
81+
petstore_api.configuration.access_token = 'YOUR_ACCESS_TOKEN'
8282

8383
# create an instance of the API class
84-
api_instance = swagger_client.PetApi()
84+
api_instance = petstore_api.PetApi()
8585
pet_id = 789 # int | Pet id to delete
8686
api_key = 'api_key_example' # str | (optional)
8787

@@ -124,15 +124,15 @@ Multiple status values can be provided with comma separated strings
124124
### Example
125125
```python
126126
import time
127-
import swagger_client
128-
from swagger_client.rest import ApiException
127+
import petstore_api
128+
from petstore_api.rest import ApiException
129129
from pprint import pprint
130130

131131
# Configure OAuth2 access token for authorization: petstore_auth
132-
swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'
132+
petstore_api.configuration.access_token = 'YOUR_ACCESS_TOKEN'
133133

134134
# create an instance of the API class
135-
api_instance = swagger_client.PetApi()
135+
api_instance = petstore_api.PetApi()
136136
status = ['status_example'] # list[str] | Status values that need to be considered for filter
137137

138138
try:
@@ -174,15 +174,15 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
174174
### Example
175175
```python
176176
import time
177-
import swagger_client
178-
from swagger_client.rest import ApiException
177+
import petstore_api
178+
from petstore_api.rest import ApiException
179179
from pprint import pprint
180180

181181
# Configure OAuth2 access token for authorization: petstore_auth
182-
swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'
182+
petstore_api.configuration.access_token = 'YOUR_ACCESS_TOKEN'
183183

184184
# create an instance of the API class
185-
api_instance = swagger_client.PetApi()
185+
api_instance = petstore_api.PetApi()
186186
tags = ['tags_example'] # list[str] | Tags to filter by
187187

188188
try:
@@ -224,17 +224,17 @@ Returns a single pet
224224
### Example
225225
```python
226226
import time
227-
import swagger_client
228-
from swagger_client.rest import ApiException
227+
import petstore_api
228+
from petstore_api.rest import ApiException
229229
from pprint import pprint
230230

231231
# Configure API key authorization: api_key
232-
swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'
232+
petstore_api.configuration.api_key['api_key'] = 'YOUR_API_KEY'
233233
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
234-
# swagger_client.configuration.api_key_prefix['api_key'] = 'Bearer'
234+
# petstore_api.configuration.api_key_prefix['api_key'] = 'Bearer'
235235

236236
# create an instance of the API class
237-
api_instance = swagger_client.PetApi()
237+
api_instance = petstore_api.PetApi()
238238
pet_id = 789 # int | ID of pet to return
239239

240240
try:
@@ -276,16 +276,16 @@ Update an existing pet
276276
### Example
277277
```python
278278
import time
279-
import swagger_client
280-
from swagger_client.rest import ApiException
279+
import petstore_api
280+
from petstore_api.rest import ApiException
281281
from pprint import pprint
282282

283283
# Configure OAuth2 access token for authorization: petstore_auth
284-
swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'
284+
petstore_api.configuration.access_token = 'YOUR_ACCESS_TOKEN'
285285

286286
# create an instance of the API class
287-
api_instance = swagger_client.PetApi()
288-
body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store
287+
api_instance = petstore_api.PetApi()
288+
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
289289

290290
try:
291291
# Update an existing pet
@@ -325,15 +325,15 @@ Updates a pet in the store with form data
325325
### Example
326326
```python
327327
import time
328-
import swagger_client
329-
from swagger_client.rest import ApiException
328+
import petstore_api
329+
from petstore_api.rest import ApiException
330330
from pprint import pprint
331331

332332
# Configure OAuth2 access token for authorization: petstore_auth
333-
swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'
333+
petstore_api.configuration.access_token = 'YOUR_ACCESS_TOKEN'
334334

335335
# create an instance of the API class
336-
api_instance = swagger_client.PetApi()
336+
api_instance = petstore_api.PetApi()
337337
pet_id = 789 # int | ID of pet that needs to be updated
338338
name = 'name_example' # str | Updated name of the pet (optional)
339339
status = 'status_example' # str | Updated status of the pet (optional)
@@ -378,15 +378,15 @@ uploads an image
378378
### Example
379379
```python
380380
import time
381-
import swagger_client
382-
from swagger_client.rest import ApiException
381+
import petstore_api
382+
from petstore_api.rest import ApiException
383383
from pprint import pprint
384384

385385
# Configure OAuth2 access token for authorization: petstore_auth
386-
swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'
386+
petstore_api.configuration.access_token = 'YOUR_ACCESS_TOKEN'
387387

388388
# create an instance of the API class
389-
api_instance = swagger_client.PetApi()
389+
api_instance = petstore_api.PetApi()
390390
pet_id = 789 # int | ID of pet to update
391391
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
392392
file = '/path/to/file.txt' # file | file to upload (optional)

samples/client/petstore/python/docs/StoreApi.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# swagger_client.StoreApi
1+
# petstore_api.StoreApi
22

33
All URIs are relative to *http://petstore.swagger.io/v2*
44

@@ -20,12 +20,12 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non
2020
### Example
2121
```python
2222
import time
23-
import swagger_client
24-
from swagger_client.rest import ApiException
23+
import petstore_api
24+
from petstore_api.rest import ApiException
2525
from pprint import pprint
2626

2727
# create an instance of the API class
28-
api_instance = swagger_client.StoreApi()
28+
api_instance = petstore_api.StoreApi()
2929
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
3030

3131
try:
@@ -66,17 +66,17 @@ Returns a map of status codes to quantities
6666
### Example
6767
```python
6868
import time
69-
import swagger_client
70-
from swagger_client.rest import ApiException
69+
import petstore_api
70+
from petstore_api.rest import ApiException
7171
from pprint import pprint
7272

7373
# Configure API key authorization: api_key
74-
swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'
74+
petstore_api.configuration.api_key['api_key'] = 'YOUR_API_KEY'
7575
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
76-
# swagger_client.configuration.api_key_prefix['api_key'] = 'Bearer'
76+
# petstore_api.configuration.api_key_prefix['api_key'] = 'Bearer'
7777

7878
# create an instance of the API class
79-
api_instance = swagger_client.StoreApi()
79+
api_instance = petstore_api.StoreApi()
8080

8181
try:
8282
# Returns pet inventories by status
@@ -114,12 +114,12 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
114114
### Example
115115
```python
116116
import time
117-
import swagger_client
118-
from swagger_client.rest import ApiException
117+
import petstore_api
118+
from petstore_api.rest import ApiException
119119
from pprint import pprint
120120

121121
# create an instance of the API class
122-
api_instance = swagger_client.StoreApi()
122+
api_instance = petstore_api.StoreApi()
123123
order_id = 789 # int | ID of pet that needs to be fetched
124124

125125
try:
@@ -161,13 +161,13 @@ Place an order for a pet
161161
### Example
162162
```python
163163
import time
164-
import swagger_client
165-
from swagger_client.rest import ApiException
164+
import petstore_api
165+
from petstore_api.rest import ApiException
166166
from pprint import pprint
167167

168168
# create an instance of the API class
169-
api_instance = swagger_client.StoreApi()
170-
body = swagger_client.Order() # Order | order placed for purchasing the pet
169+
api_instance = petstore_api.StoreApi()
170+
body = petstore_api.Order() # Order | order placed for purchasing the pet
171171

172172
try:
173173
# Place an order for a pet

0 commit comments

Comments
 (0)