Skip to content

Commit 7554f33

Browse files
committed
added python sample.
1 parent 7df5b62 commit 7554f33

File tree

186 files changed

+19151
-2
lines changed

Some content is hidden

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

186 files changed

+19151
-2
lines changed

bin/python-petstore.sh

Lines changed: 2 additions & 2 deletions
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 -Dlogback.configurationFile=bin/logback.xml"
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 $@"
29+
ags="generate -i modules/swagger-codegen/src/test/resources/3_0_0/petstore-with-fake-endpoints-models-for-testing.yaml -l python -o samples/client/petstore/python $@"
3030

31-
# java $JAVA_OPTS -jar $executable $ags
31+
java $JAVA_OPTS -jar $executable $ags
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
47+
venv/
48+
.python-version
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
57+
# Sphinx documentation
58+
docs/_build/
59+
60+
# PyBuilder
61+
target/
62+
63+
#Ipython Notebook
64+
.ipynb_checkpoints
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Swagger Codegen Ignore
2+
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0.14-SNAPSHOT
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ref: https://docs.travis-ci.com/user/languages/python
2+
language: python
3+
python:
4+
- "2.7"
5+
- "3.2"
6+
- "3.3"
7+
- "3.4"
8+
- "3.5"
9+
#- "3.5-dev" # 3.5 development branch
10+
#- "nightly" # points to the latest development branch e.g. 3.6-dev
11+
# command to install dependencies
12+
install: "pip install -r requirements.txt"
13+
# command to run tests
14+
script: nosetests
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
# swagger-client
2+
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
3+
4+
This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
5+
6+
- API version: 1.0.0
7+
- Package version: 1.0.0
8+
- Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen
9+
10+
## Requirements.
11+
12+
Python 2.7 and 3.4+
13+
14+
## Installation & Usage
15+
### pip install
16+
17+
If the python package is hosted on Github, you can install directly from Github
18+
19+
```sh
20+
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
21+
```
22+
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)
23+
24+
Then import the package:
25+
```python
26+
import swagger_client
27+
```
28+
29+
### Setuptools
30+
31+
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
32+
33+
```sh
34+
python setup.py install --user
35+
```
36+
(or `sudo python setup.py install` to install the package for all users)
37+
38+
Then import the package:
39+
```python
40+
import swagger_client
41+
```
42+
43+
## Getting Started
44+
45+
Please follow the [installation procedure](#installation--usage) and then run the following:
46+
47+
```python
48+
from __future__ import print_function
49+
import time
50+
import swagger_client
51+
from swagger_client.rest import ApiException
52+
from pprint import pprint
53+
54+
# create an instance of the API class
55+
api_instance = swagger_client.AnimalApi(swagger_client.ApiClient(configuration))
56+
body = swagger_client.Animal() # Animal | Animal object that needs to be added to the store
57+
58+
try:
59+
# Add a new animal to the store
60+
api_instance.add_animal(body)
61+
except ApiException as e:
62+
print("Exception when calling AnimalApi->add_animal: %s\n" % e)
63+
64+
# create an instance of the API class
65+
api_instance = swagger_client.AnimalApi(swagger_client.ApiClient(configuration))
66+
animal_id = 789 # int | Animal id to delete
67+
api_key = 'api_key_example' # str | (optional)
68+
69+
try:
70+
# Deletes a animal
71+
api_instance.delete_animal(animal_id, api_key=api_key)
72+
except ApiException as e:
73+
print("Exception when calling AnimalApi->delete_animal: %s\n" % e)
74+
75+
# create an instance of the API class
76+
api_instance = swagger_client.AnimalApi(swagger_client.ApiClient(configuration))
77+
animal_id = 789 # int | ID of pet to return
78+
79+
try:
80+
# Find animal by ID
81+
api_response = api_instance.get_animal_by_id(animal_id)
82+
pprint(api_response)
83+
except ApiException as e:
84+
print("Exception when calling AnimalApi->get_animal_by_id: %s\n" % e)
85+
86+
# create an instance of the API class
87+
api_instance = swagger_client.AnimalApi(swagger_client.ApiClient(configuration))
88+
body = swagger_client.Animal() # Animal | Animal object that needs to be added.
89+
90+
try:
91+
# Update an existing animal
92+
api_instance.update_animal(body)
93+
except ApiException as e:
94+
print("Exception when calling AnimalApi->update_animal: %s\n" % e)
95+
96+
# create an instance of the API class
97+
api_instance = swagger_client.AnimalApi(swagger_client.ApiClient(configuration))
98+
animal_id = 789 # int | ID of animal that needs to be updated
99+
name = 'name_example' # str | (optional)
100+
status = 'status_example' # str | (optional)
101+
102+
try:
103+
# Updates a animal
104+
api_instance.update_animal_with_form(animal_id, name=name, status=status)
105+
except ApiException as e:
106+
print("Exception when calling AnimalApi->update_animal_with_form: %s\n" % e)
107+
```
108+
109+
## Documentation for API Endpoints
110+
111+
All URIs are relative to *http://petstore.swagger.io:80/v2*
112+
113+
Class | Method | HTTP request | Description
114+
------------ | ------------- | ------------- | -------------
115+
*AnimalApi* | [**add_animal**](docs/AnimalApi.md#add_animal) | **POST** /animal | Add a new animal to the store
116+
*AnimalApi* | [**delete_animal**](docs/AnimalApi.md#delete_animal) | **DELETE** /animal/{animalId} | Deletes a animal
117+
*AnimalApi* | [**get_animal_by_id**](docs/AnimalApi.md#get_animal_by_id) | **GET** /animal/{animalId} | Find animal by ID
118+
*AnimalApi* | [**update_animal**](docs/AnimalApi.md#update_animal) | **PUT** /animal | Update an existing animal
119+
*AnimalApi* | [**update_animal_with_form**](docs/AnimalApi.md#update_animal_with_form) | **POST** /animal/{animalId} | Updates a animal
120+
*AnotherFakeApi* | [**test_special_tags**](docs/AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
121+
*DogApi* | [**add_dog**](docs/DogApi.md#add_dog) | **POST** /dog | Add a new dog to the store
122+
*DogApi* | [**delete_dog**](docs/DogApi.md#delete_dog) | **DELETE** /dog/{dogId} | Deletes a dog
123+
*DogApi* | [**get_dog_by_id**](docs/DogApi.md#get_dog_by_id) | **GET** /dog/{dogId} | Find dog by ID
124+
*DogApi* | [**update_dog**](docs/DogApi.md#update_dog) | **PUT** /dog | Update an existing dog
125+
*DogApi* | [**update_dog_with_form**](docs/DogApi.md#update_dog_with_form) | **POST** /dog/{dogId} | Updates a dog
126+
*FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean |
127+
*FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
128+
*FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
129+
*FakeApi* | [**fake_outer_string_serialize**](docs/FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string |
130+
*FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
131+
*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
132+
*FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
133+
*FakeApi* | [**test_enum_request_body**](docs/FakeApi.md#test_enum_request_body) | **POST** /fake/enum/form | To test enum parameters
134+
*FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
135+
*FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **POST** /fake/jsonFormData | test json serialization of form data
136+
*FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case
137+
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
138+
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
139+
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
140+
*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags
141+
*PetApi* | [**get_all_pets**](docs/PetApi.md#get_all_pets) | **GET** /allPets |
142+
*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID
143+
*PetApi* | [**get_random_pet**](docs/PetApi.md#get_random_pet) | **GET** /randomPet |
144+
*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
145+
*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
146+
*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image
147+
*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
148+
*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status
149+
*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{order_id} | Find purchase order by ID
150+
*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet
151+
*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user
152+
*UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array
153+
*UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array
154+
*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user
155+
*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name
156+
*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system
157+
*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session
158+
*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user
159+
160+
## Documentation For Models
161+
162+
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
163+
- [AllPetsResponse](docs/AllPetsResponse.md)
164+
- [Animal](docs/Animal.md)
165+
- [AnimalFarm](docs/AnimalFarm.md)
166+
- [ApiResponse](docs/ApiResponse.md)
167+
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
168+
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
169+
- [ArrayTest](docs/ArrayTest.md)
170+
- [Body](docs/Body.md)
171+
- [Body1](docs/Body1.md)
172+
- [Body2](docs/Body2.md)
173+
- [Body3](docs/Body3.md)
174+
- [Body4](docs/Body4.md)
175+
- [Body5](docs/Body5.md)
176+
- [Body6](docs/Body6.md)
177+
- [Body7](docs/Body7.md)
178+
- [Capitalization](docs/Capitalization.md)
179+
- [Cat](docs/Cat.md)
180+
- [Category](docs/Category.md)
181+
- [ClassModel](docs/ClassModel.md)
182+
- [Client](docs/Client.md)
183+
- [Dog](docs/Dog.md)
184+
- [EnumArrays](docs/EnumArrays.md)
185+
- [EnumClass](docs/EnumClass.md)
186+
- [EnumTest](docs/EnumTest.md)
187+
- [FormatTest](docs/FormatTest.md)
188+
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
189+
- [List](docs/List.md)
190+
- [MapTest](docs/MapTest.md)
191+
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
192+
- [Model200Response](docs/Model200Response.md)
193+
- [ModelReturn](docs/ModelReturn.md)
194+
- [Name](docs/Name.md)
195+
- [NumberOnly](docs/NumberOnly.md)
196+
- [OneOfAllPetsResponseItems](docs/OneOfAllPetsResponseItems.md)
197+
- [OneOfSinglePetResponsePet](docs/OneOfSinglePetResponsePet.md)
198+
- [Order](docs/Order.md)
199+
- [OuterBoolean](docs/OuterBoolean.md)
200+
- [OuterComposite](docs/OuterComposite.md)
201+
- [OuterEnum](docs/OuterEnum.md)
202+
- [OuterNumber](docs/OuterNumber.md)
203+
- [OuterString](docs/OuterString.md)
204+
- [Pet](docs/Pet.md)
205+
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
206+
- [SinglePetResponse](docs/SinglePetResponse.md)
207+
- [SpecialModelName](docs/SpecialModelName.md)
208+
- [Tag](docs/Tag.md)
209+
- [User](docs/User.md)
210+
211+
## Documentation For Authorization
212+
213+
214+
## api_key
215+
216+
- **Type**: API key
217+
- **API key parameter name**: api_key
218+
- **Location**: HTTP header
219+
220+
## api_key_query
221+
222+
- **Type**: API key
223+
- **API key parameter name**: api_key_query
224+
- **Location**: URL query string
225+
226+
## http_basic_test
227+
228+
- **Type**: HTTP basic authentication
229+
230+
## petstore_auth
231+
232+
- **Type**: OAuth
233+
- **Flow**: implicit
234+
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
235+
- **Scopes**:
236+
- ****:
237+
238+
239+
## Author
240+
241+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# AdditionalPropertiesClass
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**map_property** | **dict(str, str)** | | [optional]
7+
**map_of_map_property** | **dict(str, dict(str, str))** | | [optional]
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# AllPetsResponse
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
7+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
8+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Animal
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**class_name** | **str** | |
7+
**color** | **str** | | [optional] [default to 'red']
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+

0 commit comments

Comments
 (0)