From ba74c69fdbee88a060019d11ae40da1fe75104e8 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 30 Mar 2016 17:50:38 +0800 Subject: [PATCH] update doc for python, add new files --- .../languages/PythonClientCodegen.java | 19 +- .../main/resources/Javascript/README.mustache | 2 +- .../src/main/resources/perl/README.mustache | 2 +- .../src/main/resources/php/README.mustache | 2 +- .../src/main/resources/python/README.mustache | 87 ++-- .../src/main/resources/python/api.mustache | 10 +- .../src/main/resources/ruby/README.mustache | 2 +- samples/client/petstore/python/README.md | 61 +-- .../petstore/python/docs/InlineResponse200.md | 2 +- samples/client/petstore/python/docs/PetApi.md | 387 ++++++++++-------- .../client/petstore/python/docs/StoreApi.md | 232 ++++++----- .../client/petstore/python/docs/UserApi.md | 228 ++++++----- .../python/swagger_client/models/animal.py | 120 ++++++ .../python/swagger_client/models/cat.py | 145 +++++++ .../python/swagger_client/models/dog.py | 145 +++++++ 15 files changed, 974 insertions(+), 470 deletions(-) create mode 100644 samples/client/petstore/python/swagger_client/models/animal.py create mode 100644 samples/client/petstore/python/swagger_client/models/cat.py create mode 100644 samples/client/petstore/python/swagger_client/models/dog.py diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index e101cf91289..6091b36b90a 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -42,6 +42,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig languageSpecificPrimitives.add("str"); languageSpecificPrimitives.add("datetime"); languageSpecificPrimitives.add("date"); + languageSpecificPrimitives.add("object"); typeMapping.clear(); typeMapping.put("integer", "int"); @@ -434,11 +435,11 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig type = p.dataType; } - if ("String".equalsIgnoreCase(type)) { + if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) { if (example == null) { example = p.paramName + "_example"; } - example = "\"" + escapeText(example) + "\""; + example = "'" + escapeText(example) + "'"; } else if ("Integer".equals(type) || "int".equals(type)) { if (example == null) { example = "56"; @@ -451,24 +452,24 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig if (example == null) { example = "True"; } - } else if ("\\SplFileObject".equalsIgnoreCase(type)) { + } else if ("file".equalsIgnoreCase(type)) { if (example == null) { example = "/path/to/file"; } - example = "\"" + escapeText(example) + "\""; + example = "'" + escapeText(example) + "'"; } else if ("Date".equalsIgnoreCase(type)) { if (example == null) { example = "2013-10-20"; } - example = "new \\DateTime(\"" + escapeText(example) + "\")"; + example = "'" + escapeText(example) + "'"; } else if ("DateTime".equalsIgnoreCase(type)) { if (example == null) { example = "2013-10-20T19:20:30+01:00"; } - example = "new \\DateTime(\"" + escapeText(example) + "\")"; + example = "'" + escapeText(example) + "'"; } else if (!languageSpecificPrimitives.contains(type)) { // type is a model class, e.g. User - example = "new " + type + "()"; + example = this.packageName + "." + type + "()"; } else { LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue"); } @@ -476,9 +477,9 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig if (example == null) { example = "NULL"; } else if (Boolean.TRUE.equals(p.isListContainer)) { - example = "array(" + example + ")"; + example = "[" + example + "]"; } else if (Boolean.TRUE.equals(p.isMapContainer)) { - example = "array('key' => " + example + ")"; + example = "{'key': " + example + "}"; } p.example = example; diff --git a/modules/swagger-codegen/src/main/resources/Javascript/README.mustache b/modules/swagger-codegen/src/main/resources/Javascript/README.mustache index 767e2a849fd..633f2f0aebb 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/README.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/README.mustache @@ -6,7 +6,7 @@ {{/appDescription}} This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: {{appVersion}} +- API version: {{appVersion}} - Package version: {{projectVersion}} - Build date: {{generatedDate}} - Build package: {{generatorClass}} diff --git a/modules/swagger-codegen/src/main/resources/perl/README.mustache b/modules/swagger-codegen/src/main/resources/perl/README.mustache index 185859ec4a3..630a0a5979b 100644 --- a/modules/swagger-codegen/src/main/resources/perl/README.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/README.mustache @@ -8,7 +8,7 @@ Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: {{appVersion}} +- API version: {{appVersion}} - Package version: {{moduleVersion}} - Build date: {{generatedDate}} - Build package: {{generatorClass}} diff --git a/modules/swagger-codegen/src/main/resources/php/README.mustache b/modules/swagger-codegen/src/main/resources/php/README.mustache index 4088ddf1fbe..8275c4c9d7c 100644 --- a/modules/swagger-codegen/src/main/resources/php/README.mustache +++ b/modules/swagger-codegen/src/main/resources/php/README.mustache @@ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: {{appVersion}} +- API version: {{appVersion}} - Package version: {{artifactVersion}} - Build date: {{generatedDate}} - Build package: {{generatorClass}} diff --git a/modules/swagger-codegen/src/main/resources/python/README.mustache b/modules/swagger-codegen/src/main/resources/python/README.mustache index 823b5eabcfc..8ea60023b85 100644 --- a/modules/swagger-codegen/src/main/resources/python/README.mustache +++ b/modules/swagger-codegen/src/main/resources/python/README.mustache @@ -1,12 +1,12 @@ -# {{packagePath}} +# {{packageName}} {{#appDescription}} {{{appDescription}}} {{/appDescription}} This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: {{appVersion}} -- Package version: {{artifactVersion}} +- API version: {{appVersion}} +- Package version: {{packageVersion}} - Build date: {{generatedDate}} - Build package: {{generatorClass}} {{#infoUrl}} @@ -14,33 +14,44 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) {{/infoUrl}} ## Requirements. + Python 2.7 and 3.4+ ## Installation & Usage -### Setuptools -You can install the bindings via [Setuptools](http://pypi.python.org/pypi/setuptools). +### pip install -```sh -python setup.py install -``` - -Or you can install from Github via pip: +If the python package is hosted on Github, you can install directly from Github ```sh pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git ``` +(you may need to run the command with root permission: `sudo pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git`) -Finally import the pacakge: - +Import the pacakge: ```python -import swagger_client +import {{{packageName}}} +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Import the pacakge: +```python +import {{{packageName}}} ``` ### Manual Installation -Download the latest release to the project folder (e.g. ./path/to/swagger_client) and import the package: + +Download the latest release to the project folder (e.g. ./path/to/{{{packageName}}}) and import the package: ```python -import path.to.swagger_client +import path.to.{{{packageName}}} ``` ## Getting Started @@ -48,37 +59,35 @@ import path.to.swagger_client Please follow the [installation procedure](#installation--usage) and then run the following: ```python -require_once(__DIR__ . '/vendor/autoload.php'); +import time +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} -// Configure HTTP basic authorization: {{{name}}} -{{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setUsername('YOUR_USERNAME'); -{{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setPassword('YOUR_PASSWORD');{{/isBasic}}{{#isApiKey}} -// Configure API key authorization: {{{name}}} -{{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'BEARER');{{/isApiKey}}{{#isOAuth}} -// Configure OAuth2 access token for authorization: {{{name}}} -{{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');{{/isOAuth}}{{/authMethods}} +# Configure HTTP basic authorization: {{{name}}} +{{{packageName}}}.configuration.username = 'YOUR_USERNAME' +{{{packageName}}}.configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} +# Configure API key authorization: {{{name}}} +{{{packageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# {{{packageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'BEARER'{{/isApiKey}}{{#isOAuth}} +# Configure OAuth2 access token for authorization: {{{name}}} +{{{packageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} {{/hasAuthMethods}} - -$api_instance = new {{invokerPackage}}\Api\{{classname}}(); -{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}} +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}} +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/allParams}} -try { - {{#returnType}}$result = {{/returnType}}$api_instance->{{{operationId}}}({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} - print_r($result);{{/returnType}} -} catch (Exception $e) { - echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), "\n"; -} +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except ApiException as e: + print "Exception when calling {{classname}}->{{operationId}}: %s\n" % e {{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} -?> ``` -## Documentation - -TODO - ## Documentation for API Endpoints All URIs are relative to *{{basePath}}* diff --git a/modules/swagger-codegen/src/main/resources/python/api.mustache b/modules/swagger-codegen/src/main/resources/python/api.mustache index 230f05d94af..0967a2ec6b3 100644 --- a/modules/swagger-codegen/src/main/resources/python/api.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api.mustache @@ -47,7 +47,7 @@ class {{classname}}(object): self.api_client = config.api_client {{#operation}} - def {{nickname}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): + def {{operationId}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): """ {{{summary}}} {{{notes}}} @@ -59,10 +59,10 @@ class {{classname}}(object): >>> pprint(response) >>> {{#sortParamsByRequiredFlag}} - >>> thread = api.{{nickname}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}callback=callback_function) + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}callback=callback_function) {{/sortParamsByRequiredFlag}} {{^sortParamsByRequiredFlag}} - >>> thread = api.{{nickname}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}callback=callback_function) + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}callback=callback_function) {{/sortParamsByRequiredFlag}} :param callback function: The callback function @@ -83,7 +83,7 @@ class {{classname}}(object): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method {{nickname}}" % key + " to method {{operationId}}" % key ) params[key] = val del params['kwargs'] @@ -92,7 +92,7 @@ class {{classname}}(object): {{#required}} # verify the required parameter '{{paramName}}' is set if ('{{paramName}}' not in params) or (params['{{paramName}}'] is None): - raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{nickname}}`") + raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") {{/required}} {{/allParams}} diff --git a/modules/swagger-codegen/src/main/resources/ruby/README.mustache b/modules/swagger-codegen/src/main/resources/ruby/README.mustache index 3566329c244..164285e1533 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/README.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/README.mustache @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: -- API verion: {{appVersion}} +- API version: {{appVersion}} - Package version: {{gemVersion}} - Build date: {{generatedDate}} - Build package: {{generatorClass}} diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 80d04ef061d..9e99ae27370 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -1,37 +1,48 @@ -# +# swagger_client This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API verion: 1.0.0 - Package version: -- Build date: 2016-03-30T15:12:57.913+08:00 +- Build date: 2016-03-30T17:18:44.943+08:00 - Build package: class io.swagger.codegen.languages.PythonClientCodegen ## Requirements. + Python 2.7 and 3.4+ ## Installation & Usage -### Setuptools -You can install the bindings via [Setuptools](http://pypi.python.org/pypi/setuptools). +### pip install -```sh -python setup.py install -``` - -Or you can install from Github via pip: +If the python package is hosted on Github, you can install directly from Github ```sh pip install git+https://github.com/YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID.git ``` +(you may need to run the command with root permission: `sudo pip install git+https://github.com/YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID.git`) -Finally import the pacakge: +Import the pacakge: +```python +import swagger_client +``` +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Import the pacakge: ```python import swagger_client ``` ### Manual Installation + Download the latest release to the project folder (e.g. ./path/to/swagger_client) and import the package: ```python @@ -43,27 +54,25 @@ import path.to.swagger_client Please follow the [installation procedure](#installation--usage) and then run the following: ```python -require_once(__DIR__ . '/vendor/autoload.php'); +import time +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint -// Configure OAuth2 access token for authorization: petstore_auth -\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' +# create an instance of the API class +api_instance = swagger_client.PetApi +body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store (optional) -$api_instance = new \Api\PetApi(); -$body = new Pet(); // Pet | Pet object that needs to be added to the store +try: + # Add a new pet to the store + api_instance.add_pet(body=body); +except ApiException as e: + print "Exception when calling PetApi->add_pet: %s\n" % e -try { - $api_instance->add_pet($body); -} catch (Exception $e) { - echo 'Exception when calling PetApi->add_pet: ', $e->getMessage(), "\n"; -} - -?> ``` -## Documentation - -TODO - ## Documentation for API Endpoints All URIs are relative to *http://petstore.swagger.io/v2* diff --git a/samples/client/petstore/python/docs/InlineResponse200.md b/samples/client/petstore/python/docs/InlineResponse200.md index 8ff2adc59b1..ec171d3a5d2 100644 --- a/samples/client/petstore/python/docs/InlineResponse200.md +++ b/samples/client/petstore/python/docs/InlineResponse200.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **tags** | [**list[Tag]**](Tag.md) | | [optional] **id** | **int** | | -**category** | [**object**](object.md) | | [optional] +**category** | **object** | | [optional] **status** | **str** | pet status in the store | [optional] **name** | **str** | | [optional] **photo_urls** | **list[str]** | | [optional] diff --git a/samples/client/petstore/python/docs/PetApi.md b/samples/client/petstore/python/docs/PetApi.md index 9f2fb805785..3349a3cb7d4 100644 --- a/samples/client/petstore/python/docs/PetApi.md +++ b/samples/client/petstore/python/docs/PetApi.md @@ -1,4 +1,4 @@ -# \PetApi +# swagger_client\PetApi All URIs are relative to *http://petstore.swagger.io/v2* @@ -18,29 +18,32 @@ Method | HTTP request | Description # **add_pet** -> add_pet($body) +> add_pet(body=body) Add a new pet to the store ### Example -```php -setAccessToken('YOUR_ACCESS_TOKEN'); -$api_instance = new \Api\PetApi(); -$body = new Pet(); // Pet | Pet object that needs to be added to the store +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' -try { - $api_instance->add_pet($body); -} catch (Exception $e) { - echo 'Exception when calling PetApi->add_pet: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.PetApi() +body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store (optional) + +try: + # Add a new pet to the store + api_instance.add_pet(body=body); +except ApiException as e: + print "Exception when calling PetApi->add_pet: %s\n" % e ``` ### Parameters @@ -65,29 +68,32 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **add_pet_using_byte_array** -> add_pet_using_byte_array($body) +> add_pet_using_byte_array(body=body) Fake endpoint to test byte array in body parameter for adding a new pet to the store ### Example -```php -setAccessToken('YOUR_ACCESS_TOKEN'); -$api_instance = new \Api\PetApi(); -$body = B; // str | Pet object in the form of byte array +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' -try { - $api_instance->add_pet_using_byte_array($body); -} catch (Exception $e) { - echo 'Exception when calling PetApi->add_pet_using_byte_array: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.PetApi() +body = 'B' # str | Pet object in the form of byte array (optional) + +try: + # Fake endpoint to test byte array in body parameter for adding a new pet to the store + api_instance.add_pet_using_byte_array(body=body); +except ApiException as e: + print "Exception when calling PetApi->add_pet_using_byte_array: %s\n" % e ``` ### Parameters @@ -112,30 +118,33 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_pet** -> delete_pet($pet_id, $api_key) +> delete_pet(pet_id, api_key=api_key) Deletes a pet ### Example -```php -setAccessToken('YOUR_ACCESS_TOKEN'); -$api_instance = new \Api\PetApi(); -$pet_id = 789; // int | Pet id to delete -$api_key = api_key_example; // str | +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' -try { - $api_instance->delete_pet($pet_id, $api_key); -} catch (Exception $e) { - echo 'Exception when calling PetApi->delete_pet: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.PetApi() +pet_id = 789 # int | Pet id to delete +api_key = 'api_key_example' # str | (optional) + +try: + # Deletes a pet + api_instance.delete_pet(pet_id, api_key=api_key); +except ApiException as e: + print "Exception when calling PetApi->delete_pet: %s\n" % e ``` ### Parameters @@ -161,30 +170,33 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **find_pets_by_status** -> list[Pet] find_pets_by_status($status) +> list[Pet] find_pets_by_status(status=status) Finds Pets by status Multiple status values can be provided with comma separated strings ### Example -```php -setAccessToken('YOUR_ACCESS_TOKEN'); -$api_instance = new \Api\PetApi(); -$status = array(available); // list[str] | Status values that need to be considered for query +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' -try { - $result = $api_instance->find_pets_by_status($status); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling PetApi->find_pets_by_status: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.PetApi() +status = ['available'] # list[str] | Status values that need to be considered for query (optional) (default to available) + +try: + # Finds Pets by status + api_response = api_instance.find_pets_by_status(status=status); + pprint(api_response) +except ApiException as e: + print "Exception when calling PetApi->find_pets_by_status: %s\n" % e ``` ### Parameters @@ -209,30 +221,33 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **find_pets_by_tags** -> list[Pet] find_pets_by_tags($tags) +> list[Pet] find_pets_by_tags(tags=tags) Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. ### Example -```php -setAccessToken('YOUR_ACCESS_TOKEN'); -$api_instance = new \Api\PetApi(); -$tags = NULL; // list[str] | Tags to filter by +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' -try { - $result = $api_instance->find_pets_by_tags($tags); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling PetApi->find_pets_by_tags: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.PetApi() +tags = ['tags_example'] # list[str] | Tags to filter by (optional) + +try: + # Finds Pets by tags + api_response = api_instance.find_pets_by_tags(tags=tags); + pprint(api_response) +except ApiException as e: + print "Exception when calling PetApi->find_pets_by_tags: %s\n" % e ``` ### Parameters @@ -257,34 +272,37 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_pet_by_id** -> Pet get_pet_by_id($pet_id) +> Pet get_pet_by_id(pet_id) Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions ### Example -```php -setApiKey('api_key', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// \Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); -// Configure OAuth2 access token for authorization: petstore_auth -\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); -$api_instance = new \Api\PetApi(); -$pet_id = 789; // int | ID of pet that needs to be fetched +# Configure API key authorization: api_key +swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' -try { - $result = $api_instance->get_pet_by_id($pet_id); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling PetApi->get_pet_by_id: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.PetApi() +pet_id = 789 # int | ID of pet that needs to be fetched + +try: + # Find pet by ID + api_response = api_instance.get_pet_by_id(pet_id); + pprint(api_response) +except ApiException as e: + print "Exception when calling PetApi->get_pet_by_id: %s\n" % e ``` ### Parameters @@ -309,34 +327,37 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_pet_by_id_in_object** -> InlineResponse200 get_pet_by_id_in_object($pet_id) +> InlineResponse200 get_pet_by_id_in_object(pet_id) Fake endpoint to test inline arbitrary object return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions ### Example -```php -setApiKey('api_key', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// \Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); -// Configure OAuth2 access token for authorization: petstore_auth -\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); -$api_instance = new \Api\PetApi(); -$pet_id = 789; // int | ID of pet that needs to be fetched +# Configure API key authorization: api_key +swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' -try { - $result = $api_instance->get_pet_by_id_in_object($pet_id); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling PetApi->get_pet_by_id_in_object: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.PetApi() +pet_id = 789 # int | ID of pet that needs to be fetched + +try: + # Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + api_response = api_instance.get_pet_by_id_in_object(pet_id); + pprint(api_response) +except ApiException as e: + print "Exception when calling PetApi->get_pet_by_id_in_object: %s\n" % e ``` ### Parameters @@ -361,34 +382,37 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **pet_pet_idtesting_byte_arraytrue_get** -> str pet_pet_idtesting_byte_arraytrue_get($pet_id) +> str pet_pet_idtesting_byte_arraytrue_get(pet_id) Fake endpoint to test byte array return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions ### Example -```php -setApiKey('api_key', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// \Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); -// Configure OAuth2 access token for authorization: petstore_auth -\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); -$api_instance = new \Api\PetApi(); -$pet_id = 789; // int | ID of pet that needs to be fetched +# Configure API key authorization: api_key +swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' -try { - $result = $api_instance->pet_pet_idtesting_byte_arraytrue_get($pet_id); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling PetApi->pet_pet_idtesting_byte_arraytrue_get: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.PetApi() +pet_id = 789 # int | ID of pet that needs to be fetched + +try: + # Fake endpoint to test byte array return by 'Find pet by ID' + api_response = api_instance.pet_pet_idtesting_byte_arraytrue_get(pet_id); + pprint(api_response) +except ApiException as e: + print "Exception when calling PetApi->pet_pet_idtesting_byte_arraytrue_get: %s\n" % e ``` ### Parameters @@ -413,29 +437,32 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **update_pet** -> update_pet($body) +> update_pet(body=body) Update an existing pet ### Example -```php -setAccessToken('YOUR_ACCESS_TOKEN'); -$api_instance = new \Api\PetApi(); -$body = new Pet(); // Pet | Pet object that needs to be added to the store +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' -try { - $api_instance->update_pet($body); -} catch (Exception $e) { - echo 'Exception when calling PetApi->update_pet: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.PetApi() +body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store (optional) + +try: + # Update an existing pet + api_instance.update_pet(body=body); +except ApiException as e: + print "Exception when calling PetApi->update_pet: %s\n" % e ``` ### Parameters @@ -460,31 +487,34 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **update_pet_with_form** -> update_pet_with_form($pet_id, $name, $status) +> update_pet_with_form(pet_id, name=name, status=status) Updates a pet in the store with form data ### Example -```php -setAccessToken('YOUR_ACCESS_TOKEN'); -$api_instance = new \Api\PetApi(); -$pet_id = pet_id_example; // str | ID of pet that needs to be updated -$name = name_example; // str | Updated name of the pet -$status = status_example; // str | Updated status of the pet +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' -try { - $api_instance->update_pet_with_form($pet_id, $name, $status); -} catch (Exception $e) { - echo 'Exception when calling PetApi->update_pet_with_form: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.PetApi() +pet_id = 'pet_id_example' # str | ID of pet that needs to be updated +name = 'name_example' # str | Updated name of the pet (optional) +status = 'status_example' # str | Updated status of the pet (optional) + +try: + # Updates a pet in the store with form data + api_instance.update_pet_with_form(pet_id, name=name, status=status); +except ApiException as e: + print "Exception when calling PetApi->update_pet_with_form: %s\n" % e ``` ### Parameters @@ -511,31 +541,34 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **upload_file** -> upload_file($pet_id, $additional_metadata, $file) +> upload_file(pet_id, additional_metadata=additional_metadata, file=file) uploads an image ### Example -```php -setAccessToken('YOUR_ACCESS_TOKEN'); -$api_instance = new \Api\PetApi(); -$pet_id = 789; // int | ID of pet to update -$additional_metadata = additional_metadata_example; // str | Additional data to pass to server -$file = new file(); // file | file to upload +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' -try { - $api_instance->upload_file($pet_id, $additional_metadata, $file); -} catch (Exception $e) { - echo 'Exception when calling PetApi->upload_file: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.PetApi() +pet_id = 789 # int | ID of pet to update +additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional) +file = '/path/to/file.txt' # file | file to upload (optional) + +try: + # uploads an image + api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file); +except ApiException as e: + print "Exception when calling PetApi->upload_file: %s\n" % e ``` ### Parameters diff --git a/samples/client/petstore/python/docs/StoreApi.md b/samples/client/petstore/python/docs/StoreApi.md index a421d5aecf1..bbffc6e384b 100644 --- a/samples/client/petstore/python/docs/StoreApi.md +++ b/samples/client/petstore/python/docs/StoreApi.md @@ -1,4 +1,4 @@ -# \StoreApi +# swagger_client\StoreApi All URIs are relative to *http://petstore.swagger.io/v2* @@ -13,26 +13,29 @@ Method | HTTP request | Description # **delete_order** -> delete_order($order_id) +> delete_order(order_id) Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors ### Example -```php -delete_order($order_id); -} catch (Exception $e) { - echo 'Exception when calling StoreApi->delete_order: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.StoreApi() +order_id = 'order_id_example' # str | ID of the order that needs to be deleted + +try: + # Delete purchase order by ID + api_instance.delete_order(order_id); +except ApiException as e: + print "Exception when calling StoreApi->delete_order: %s\n" % e ``` ### Parameters @@ -57,36 +60,39 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **find_orders_by_status** -> list[Order] find_orders_by_status($status) +> list[Order] find_orders_by_status(status=status) Finds orders by status A single status value can be provided as a string ### Example -```php -setApiKey('x-test_api_client_id', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// \Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-test_api_client_id', 'BEARER'); -// Configure API key authorization: test_api_client_secret -\Configuration::getDefaultConfiguration()->setApiKey('x-test_api_client_secret', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// \Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-test_api_client_secret', 'BEARER'); -$api_instance = new \Api\StoreApi(); -$status = placed; // str | Status value that needs to be considered for query +# Configure API key authorization: test_api_client_id +swagger_client.configuration.api_key['x-test_api_client_id'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['x-test_api_client_id'] = 'BEARER' +# Configure API key authorization: test_api_client_secret +swagger_client.configuration.api_key['x-test_api_client_secret'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['x-test_api_client_secret'] = 'BEARER' -try { - $result = $api_instance->find_orders_by_status($status); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling StoreApi->find_orders_by_status: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.StoreApi() +status = 'placed' # str | Status value that needs to be considered for query (optional) (default to placed) + +try: + # Finds orders by status + api_response = api_instance.find_orders_by_status(status=status); + pprint(api_response) +except ApiException as e: + print "Exception when calling StoreApi->find_orders_by_status: %s\n" % e ``` ### Parameters @@ -118,24 +124,27 @@ Returns pet inventories by status Returns a map of status codes to quantities ### Example -```php -setApiKey('api_key', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// \Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); -$api_instance = new \Api\StoreApi(); +# Configure API key authorization: api_key +swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' -try { - $result = $api_instance->get_inventory(); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling StoreApi->get_inventory: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.StoreApi() + +try: + # Returns pet inventories by status + api_response = api_instance.get_inventory(); + pprint(api_response) +except ApiException as e: + print "Exception when calling StoreApi->get_inventory: %s\n" % e ``` ### Parameters @@ -164,24 +173,27 @@ Fake endpoint to test arbitrary object return by 'Get inventory' Returns an arbitrary object which is actually a map of status codes to quantities ### Example -```php -setApiKey('api_key', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// \Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); -$api_instance = new \Api\StoreApi(); +# Configure API key authorization: api_key +swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' -try { - $result = $api_instance->get_inventory_in_object(); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling StoreApi->get_inventory_in_object: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.StoreApi() + +try: + # Fake endpoint to test arbitrary object return by 'Get inventory' + api_response = api_instance.get_inventory_in_object(); + pprint(api_response) +except ApiException as e: + print "Exception when calling StoreApi->get_inventory_in_object: %s\n" % e ``` ### Parameters @@ -189,7 +201,7 @@ This endpoint does not need any parameter. ### Return type -[**object**](object.md) +**object** ### Authorization @@ -203,36 +215,39 @@ This endpoint does not need any parameter. [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_order_by_id** -> Order get_order_by_id($order_id) +> Order get_order_by_id(order_id) Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions ### Example -```php -setApiKey('test_api_key_header', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// \Configuration::getDefaultConfiguration()->setApiKeyPrefix('test_api_key_header', 'BEARER'); -// Configure API key authorization: test_api_key_query -\Configuration::getDefaultConfiguration()->setApiKey('test_api_key_query', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// \Configuration::getDefaultConfiguration()->setApiKeyPrefix('test_api_key_query', 'BEARER'); -$api_instance = new \Api\StoreApi(); -$order_id = order_id_example; // str | ID of pet that needs to be fetched +# Configure API key authorization: test_api_key_header +swagger_client.configuration.api_key['test_api_key_header'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['test_api_key_header'] = 'BEARER' +# Configure API key authorization: test_api_key_query +swagger_client.configuration.api_key['test_api_key_query'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['test_api_key_query'] = 'BEARER' -try { - $result = $api_instance->get_order_by_id($order_id); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling StoreApi->get_order_by_id: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.StoreApi() +order_id = 'order_id_example' # str | ID of pet that needs to be fetched + +try: + # Find purchase order by ID + api_response = api_instance.get_order_by_id(order_id); + pprint(api_response) +except ApiException as e: + print "Exception when calling StoreApi->get_order_by_id: %s\n" % e ``` ### Parameters @@ -257,36 +272,39 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **place_order** -> Order place_order($body) +> Order place_order(body=body) Place an order for a pet ### Example -```php -setApiKey('x-test_api_client_id', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// \Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-test_api_client_id', 'BEARER'); -// Configure API key authorization: test_api_client_secret -\Configuration::getDefaultConfiguration()->setApiKey('x-test_api_client_secret', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// \Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-test_api_client_secret', 'BEARER'); -$api_instance = new \Api\StoreApi(); -$body = new Order(); // Order | order placed for purchasing the pet +# Configure API key authorization: test_api_client_id +swagger_client.configuration.api_key['x-test_api_client_id'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['x-test_api_client_id'] = 'BEARER' +# Configure API key authorization: test_api_client_secret +swagger_client.configuration.api_key['x-test_api_client_secret'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['x-test_api_client_secret'] = 'BEARER' -try { - $result = $api_instance->place_order($body); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling StoreApi->place_order: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.StoreApi() +body = swagger_client.Order() # Order | order placed for purchasing the pet (optional) + +try: + # Place an order for a pet + api_response = api_instance.place_order(body=body); + pprint(api_response) +except ApiException as e: + print "Exception when calling StoreApi->place_order: %s\n" % e ``` ### Parameters diff --git a/samples/client/petstore/python/docs/UserApi.md b/samples/client/petstore/python/docs/UserApi.md index 03c2fd0e10f..8145147a6ff 100644 --- a/samples/client/petstore/python/docs/UserApi.md +++ b/samples/client/petstore/python/docs/UserApi.md @@ -1,4 +1,4 @@ -# \UserApi +# swagger_client\UserApi All URIs are relative to *http://petstore.swagger.io/v2* @@ -15,26 +15,29 @@ Method | HTTP request | Description # **create_user** -> create_user($body) +> create_user(body=body) Create user This can only be done by the logged in user. ### Example -```php -create_user($body); -} catch (Exception $e) { - echo 'Exception when calling UserApi->create_user: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.UserApi() +body = swagger_client.User() # User | Created user object (optional) + +try: + # Create user + api_instance.create_user(body=body); +except ApiException as e: + print "Exception when calling UserApi->create_user: %s\n" % e ``` ### Parameters @@ -59,26 +62,29 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **create_users_with_array_input** -> create_users_with_array_input($body) +> create_users_with_array_input(body=body) Creates list of users with given input array ### Example -```php -create_users_with_array_input($body); -} catch (Exception $e) { - echo 'Exception when calling UserApi->create_users_with_array_input: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.UserApi() +body = [swagger_client.User()] # list[User] | List of user object (optional) + +try: + # Creates list of users with given input array + api_instance.create_users_with_array_input(body=body); +except ApiException as e: + print "Exception when calling UserApi->create_users_with_array_input: %s\n" % e ``` ### Parameters @@ -103,26 +109,29 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **create_users_with_list_input** -> create_users_with_list_input($body) +> create_users_with_list_input(body=body) Creates list of users with given input array ### Example -```php -create_users_with_list_input($body); -} catch (Exception $e) { - echo 'Exception when calling UserApi->create_users_with_list_input: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.UserApi() +body = [swagger_client.User()] # list[User] | List of user object (optional) + +try: + # Creates list of users with given input array + api_instance.create_users_with_list_input(body=body); +except ApiException as e: + print "Exception when calling UserApi->create_users_with_list_input: %s\n" % e ``` ### Parameters @@ -147,30 +156,33 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **delete_user** -> delete_user($username) +> delete_user(username) Delete user This can only be done by the logged in user. ### Example -```php -setUsername('YOUR_USERNAME'); -\Configuration::getDefaultConfiguration()->setPassword('YOUR_PASSWORD'); -$api_instance = new \Api\UserApi(); -$username = username_example; // str | The name that needs to be deleted +# Configure HTTP basic authorization: test_http_basic +swagger_client.configuration.username = 'YOUR_USERNAME' +swagger_client.configuration.password = 'YOUR_PASSWORD' -try { - $api_instance->delete_user($username); -} catch (Exception $e) { - echo 'Exception when calling UserApi->delete_user: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.UserApi() +username = 'username_example' # str | The name that needs to be deleted + +try: + # Delete user + api_instance.delete_user(username); +except ApiException as e: + print "Exception when calling UserApi->delete_user: %s\n" % e ``` ### Parameters @@ -195,27 +207,30 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **get_user_by_name** -> User get_user_by_name($username) +> User get_user_by_name(username) Get user by user name ### Example -```php -get_user_by_name($username); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling UserApi->get_user_by_name: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.UserApi() +username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing. + +try: + # Get user by user name + api_response = api_instance.get_user_by_name(username); + pprint(api_response) +except ApiException as e: + print "Exception when calling UserApi->get_user_by_name: %s\n" % e ``` ### Parameters @@ -240,28 +255,31 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **login_user** -> str login_user($username, $password) +> str login_user(username=username, password=password) Logs user into the system ### Example -```php -login_user($username, $password); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling UserApi->login_user: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.UserApi() +username = 'username_example' # str | The user name for login (optional) +password = 'password_example' # str | The password for login in clear text (optional) + +try: + # Logs user into the system + api_response = api_instance.login_user(username=username, password=password); + pprint(api_response) +except ApiException as e: + print "Exception when calling UserApi->login_user: %s\n" % e ``` ### Parameters @@ -294,18 +312,21 @@ Logs out current logged in user session ### Example -```php -logout_user(); -} catch (Exception $e) { - echo 'Exception when calling UserApi->logout_user: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.UserApi() + +try: + # Logs out current logged in user session + api_instance.logout_user(); +except ApiException as e: + print "Exception when calling UserApi->logout_user: %s\n" % e ``` ### Parameters @@ -327,27 +348,30 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **update_user** -> update_user($username, $body) +> update_user(username, body=body) Updated user This can only be done by the logged in user. ### Example -```php -update_user($username, $body); -} catch (Exception $e) { - echo 'Exception when calling UserApi->update_user: ', $e->getMessage(), "\n"; -} -?> +# create an instance of the API class +api_instance = swagger_client.UserApi() +username = 'username_example' # str | name that need to be deleted +body = swagger_client.User() # User | Updated user object (optional) + +try: + # Updated user + api_instance.update_user(username, body=body); +except ApiException as e: + print "Exception when calling UserApi->update_user: %s\n" % e ``` ### Parameters diff --git a/samples/client/petstore/python/swagger_client/models/animal.py b/samples/client/petstore/python/swagger_client/models/animal.py new file mode 100644 index 00000000000..762e3df5b37 --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/animal.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class Animal(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + Animal - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'class_name': 'str' + } + + self.attribute_map = { + 'class_name': 'className' + } + + self._class_name = None + + @property + def class_name(self): + """ + Gets the class_name of this Animal. + + + :return: The class_name of this Animal. + :rtype: str + """ + return self._class_name + + @class_name.setter + def class_name(self, class_name): + """ + Sets the class_name of this Animal. + + + :param class_name: The class_name of this Animal. + :type: str + """ + self._class_name = class_name + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other + diff --git a/samples/client/petstore/python/swagger_client/models/cat.py b/samples/client/petstore/python/swagger_client/models/cat.py new file mode 100644 index 00000000000..4744fc4821c --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/cat.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class Cat(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + Cat - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'class_name': 'str', + 'declawed': 'bool' + } + + self.attribute_map = { + 'class_name': 'className', + 'declawed': 'declawed' + } + + self._class_name = None + self._declawed = None + + @property + def class_name(self): + """ + Gets the class_name of this Cat. + + + :return: The class_name of this Cat. + :rtype: str + """ + return self._class_name + + @class_name.setter + def class_name(self, class_name): + """ + Sets the class_name of this Cat. + + + :param class_name: The class_name of this Cat. + :type: str + """ + self._class_name = class_name + + @property + def declawed(self): + """ + Gets the declawed of this Cat. + + + :return: The declawed of this Cat. + :rtype: bool + """ + return self._declawed + + @declawed.setter + def declawed(self, declawed): + """ + Sets the declawed of this Cat. + + + :param declawed: The declawed of this Cat. + :type: bool + """ + self._declawed = declawed + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other + diff --git a/samples/client/petstore/python/swagger_client/models/dog.py b/samples/client/petstore/python/swagger_client/models/dog.py new file mode 100644 index 00000000000..3885dd314ef --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/dog.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class Dog(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + Dog - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'class_name': 'str', + 'breed': 'str' + } + + self.attribute_map = { + 'class_name': 'className', + 'breed': 'breed' + } + + self._class_name = None + self._breed = None + + @property + def class_name(self): + """ + Gets the class_name of this Dog. + + + :return: The class_name of this Dog. + :rtype: str + """ + return self._class_name + + @class_name.setter + def class_name(self, class_name): + """ + Sets the class_name of this Dog. + + + :param class_name: The class_name of this Dog. + :type: str + """ + self._class_name = class_name + + @property + def breed(self): + """ + Gets the breed of this Dog. + + + :return: The breed of this Dog. + :rtype: str + """ + return self._breed + + @breed.setter + def breed(self, breed): + """ + Sets the breed of this Dog. + + + :param breed: The breed of this Dog. + :type: str + """ + self._breed = breed + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other +