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 2b10bdd86d0..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 @@ -3,6 +3,7 @@ import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.CodegenParameter; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; @@ -17,6 +18,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig { protected String packageName; protected String packageVersion; + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; public PythonClientCodegen() { super(); @@ -28,6 +31,9 @@ public PythonClientCodegen() { apiTemplateFiles.put("api.mustache", ".py"); embeddedTemplateDir = templateDir = "python"; + modelDocTemplateFiles.put("model_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); + languageSpecificPrimitives.clear(); languageSpecificPrimitives.add("int"); languageSpecificPrimitives.add("float"); @@ -36,6 +42,7 @@ public PythonClientCodegen() { languageSpecificPrimitives.add("str"); languageSpecificPrimitives.add("datetime"); languageSpecificPrimitives.add("date"); + languageSpecificPrimitives.add("object"); typeMapping.clear(); typeMapping.put("integer", "int"); @@ -97,6 +104,10 @@ public void processOpts() { additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion); + // make api and model doc path available in mustache template + additionalProperties.put("apiDocPath", apiDocPath); + additionalProperties.put("modelDocPath", modelDocPath); + String swaggerFolder = packageName; modelPackage = swaggerFolder + File.separatorChar + "models"; @@ -138,6 +149,27 @@ public String escapeReservedWord(String name) { return "_" + name; } + @Override + public String apiDocFileFolder() { + return (outputFolder + "/" + apiDocPath); + } + + @Override + public String modelDocFileFolder() { + return (outputFolder + "/" + modelDocPath); + } + + @Override + public String toModelDocFilename(String name) { + return toModelName(name); + } + + @Override + public String toApiDocFilename(String name) { + return toApiName(name); + } + + @Override public String apiFileFolder() { return outputFolder + File.separatorChar + apiPackage().replace('.', File.separatorChar); @@ -388,4 +420,70 @@ public String toDefaultValue(Property p) { return null; } + @Override + public void setParameterExampleValue(CodegenParameter p) { + String example; + + if (p.defaultValue == null) { + example = p.example; + } else { + example = p.defaultValue; + } + + String type = p.baseType; + if (type == null) { + type = p.dataType; + } + + if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) { + if (example == null) { + example = p.paramName + "_example"; + } + example = "'" + escapeText(example) + "'"; + } else if ("Integer".equals(type) || "int".equals(type)) { + if (example == null) { + example = "56"; + } + } else if ("Float".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type)) { + if (example == null) { + example = "3.4"; + } + } else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) { + if (example == null) { + example = "True"; + } + } else if ("file".equalsIgnoreCase(type)) { + if (example == null) { + example = "/path/to/file"; + } + example = "'" + escapeText(example) + "'"; + } else if ("Date".equalsIgnoreCase(type)) { + if (example == null) { + example = "2013-10-20"; + } + example = "'" + escapeText(example) + "'"; + } else if ("DateTime".equalsIgnoreCase(type)) { + if (example == null) { + example = "2013-10-20T19:20:30+01:00"; + } + example = "'" + escapeText(example) + "'"; + } else if (!languageSpecificPrimitives.contains(type)) { + // type is a model class, e.g. User + example = this.packageName + "." + type + "()"; + } else { + LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue"); + } + + if (example == null) { + example = "NULL"; + } else if (Boolean.TRUE.equals(p.isListContainer)) { + example = "[" + example + "]"; + } else if (Boolean.TRUE.equals(p.isMapContainer)) { + 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 463bbb37a18..a1ba2f0d298 100644 --- a/modules/swagger-codegen/src/main/resources/python/README.mustache +++ b/modules/swagger-codegen/src/main/resources/python/README.mustache @@ -1,73 +1,122 @@ +# {{packageName}} +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +- Build date: {{generatedDate}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + ## Requirements. -Python 2.7 and later. -## Setuptools -You can install the bindings via [Setuptools](http://pypi.python.org/pypi/setuptools). +Python 2.7 and 3.4+ + +## Installation & Usage +### pip install + +If the python package is hosted on Github, you can install directly from Github ```sh -python setup.py install +pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git ``` +(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git`) -Or you can install from Github via pip: +Then import the package: +```python +import {{{packageName}}} +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). ```sh -pip install git+https://github.com/geekerzp/swagger_client.git +python setup.py install --user ``` +(or `sudo python setup.py install` to install the package for all users) -To use the bindings, import the pacakge: - +Then import the package: ```python -import swagger_client +import {{{packageName}}} ``` -## Manual Installation -If you do not wish to use setuptools, you can download the latest release. -Then, to use the bindings, import the package: +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: ```python -import path.to.swagger_client +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}}} +{{{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}} +# 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: +{{#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}} ``` -## Getting Started +## Documentation for API Endpoints -TODO +All URIs are relative to *{{basePath}}* -## Documentation +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} -TODO +## Documentation For Models -## Tests +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} -(Please make sure you have [virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) installed) +## Documentation For Authorization - Execute the following command to run the tests in the current Python (v2 or v3) environment: +{{^authMethods}} All endpoints do not require authorization. +{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} +{{#authMethods}}## {{{name}}} -```sh -$ make test -[... magically installs dependencies and runs tests on your virtualenv] -Ran 7 tests in 19.289s +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorizatoin URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} -OK -``` -or +{{/authMethods}} -``` -$ mvn integration-test -rf :PythonPetstoreClientTests -Using 2195432783 as seed -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------ -[INFO] Total time: 37.594 s -[INFO] Finished at: 2015-05-16T18:00:35+08:00 -[INFO] Final Memory: 11M/156M -[INFO] ------------------------------------------------------------------------ -``` -If you want to run the tests in all the python platforms: +## Author -```sh -$ make test-all -[... tox creates a virtualenv for every platform and runs tests inside of each] - py27: commands succeeded - py34: commands succeeded - congratulations :) -``` +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} 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/python/api_doc.mustache b/modules/swagger-codegen/src/main/resources/python/api_doc.mustache new file mode 100644 index 00000000000..b4f921fa870 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/python/api_doc.mustache @@ -0,0 +1,74 @@ +# {{packageName}}.{{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} +# **{{{operationId}}}** +> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{/required}}{{^required}}{{{paramName}}}={{{paramName}}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{{summary}}}{{#notes}} + +{{{notes}}}{{/notes}} + +### Example +```python +import time +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint +{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +# 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}} + +# 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: +{{#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 +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP reuqest headers + + - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +[[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) + +{{/operation}} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/python/model_doc.mustache b/modules/swagger-codegen/src/main/resources/python/model_doc.mustache new file mode 100644 index 00000000000..569550df372 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/python/model_doc.mustache @@ -0,0 +1,11 @@ +{{#models}}{{#model}}# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{/vars}} + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + +{{/model}}{{/models}} 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 463bbb37a18..9e99ae27370 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -1,28 +1,49 @@ +# 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-30T17:18:44.943+08:00 +- Build package: class io.swagger.codegen.languages.PythonClientCodegen + ## Requirements. -Python 2.7 and later. -## Setuptools -You can install the bindings via [Setuptools](http://pypi.python.org/pypi/setuptools). +Python 2.7 and 3.4+ + +## Installation & Usage +### pip install + +If the python package is hosted on Github, you can install directly from Github ```sh -python setup.py install +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`) -Or you can install from Github via pip: +Import the pacakge: +```python +import swagger_client +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). ```sh -pip install git+https://github.com/geekerzp/swagger_client.git +python setup.py install --user ``` +(or `sudo python setup.py install` to install the package for all users) -To use the bindings, import the pacakge: - +Import the pacakge: ```python import swagger_client ``` -## Manual Installation -If you do not wish to use setuptools, you can download the latest release. -Then, to use the bindings, import the package: +### Manual Installation + +Download the latest release to the project folder (e.g. ./path/to/swagger_client) and import the package: ```python import path.to.swagger_client @@ -30,44 +51,126 @@ import path.to.swagger_client ## Getting Started -TODO +Please follow the [installation procedure](#installation--usage) and then run the following: -## Documentation +```python +import time +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint -TODO +# 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) -## Tests +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 -(Please make sure you have [virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) installed) +``` - Execute the following command to run the tests in the current Python (v2 or v3) environment: +## Documentation for API Endpoints -```sh -$ make test -[... magically installs dependencies and runs tests on your virtualenv] -Ran 7 tests in 19.289s +All URIs are relative to *http://petstore.swagger.io/v2* -OK -``` -or +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**add_pet_using_byte_array**](docs/PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**get_pet_by_id_in_object**](docs/PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*PetApi* | [**pet_pet_idtesting_byte_arraytrue_get**](docs/PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**find_orders_by_status**](docs/StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status +*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**get_inventory_in_object**](docs/StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user +*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 +*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 +*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system +*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user -``` -$ mvn integration-test -rf :PythonPetstoreClientTests -Using 2195432783 as seed -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------ -[INFO] Total time: 37.594 s -[INFO] Finished at: 2015-05-16T18:00:35+08:00 -[INFO] Final Memory: 11M/156M -[INFO] ------------------------------------------------------------------------ -``` -If you want to run the tests in all the python platforms: -```sh -$ make test-all -[... tox creates a virtualenv for every platform and runs tests inside of each] - py27: commands succeeded - py34: commands succeeded - congratulations :) -``` +## Documentation For Models + + - [Animal](docs/Animal.md) + - [Cat](docs/Cat.md) + - [Category](docs/Category.md) + - [Dog](docs/Dog.md) + - [InlineResponse200](docs/InlineResponse200.md) + - [Model200Response](docs/Model200Response.md) + - [ModelReturn](docs/ModelReturn.md) + - [Name](docs/Name.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [SpecialModelName](docs/SpecialModelName.md) + - [Tag](docs/Tag.md) + - [User](docs/User.md) + + +## Documentation For Authorization + + +## test_api_key_header + +- **Type**: API key +- **API key parameter name**: test_api_key_header +- **Location**: HTTP header + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +## test_http_basic + +- **Type**: HTTP basic authentication + +## test_api_client_secret + +- **Type**: API key +- **API key parameter name**: x-test_api_client_secret +- **Location**: HTTP header + +## test_api_client_id + +- **Type**: API key +- **API key parameter name**: x-test_api_client_id +- **Location**: HTTP header + +## test_api_key_query + +- **Type**: API key +- **API key parameter name**: test_api_key_query +- **Location**: URL query string + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + + +## Author + +apiteam@swagger.io + diff --git a/samples/client/petstore/python/docs/Animal.md b/samples/client/petstore/python/docs/Animal.md new file mode 100644 index 00000000000..ceb8002b4ab --- /dev/null +++ b/samples/client/petstore/python/docs/Animal.md @@ -0,0 +1,10 @@ +# Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Cat.md b/samples/client/petstore/python/docs/Cat.md new file mode 100644 index 00000000000..fd4cd174fc2 --- /dev/null +++ b/samples/client/petstore/python/docs/Cat.md @@ -0,0 +1,11 @@ +# Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**declawed** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Category.md b/samples/client/petstore/python/docs/Category.md new file mode 100644 index 00000000000..7f453539bf8 --- /dev/null +++ b/samples/client/petstore/python/docs/Category.md @@ -0,0 +1,11 @@ +# Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Dog.md b/samples/client/petstore/python/docs/Dog.md new file mode 100644 index 00000000000..a4b38a70335 --- /dev/null +++ b/samples/client/petstore/python/docs/Dog.md @@ -0,0 +1,11 @@ +# Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**breed** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/InlineResponse200.md b/samples/client/petstore/python/docs/InlineResponse200.md new file mode 100644 index 00000000000..ec171d3a5d2 --- /dev/null +++ b/samples/client/petstore/python/docs/InlineResponse200.md @@ -0,0 +1,15 @@ +# InlineResponse200 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | [**list[Tag]**](Tag.md) | | [optional] +**id** | **int** | | +**category** | **object** | | [optional] +**status** | **str** | pet status in the store | [optional] +**name** | **str** | | [optional] +**photo_urls** | **list[str]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Model200Response.md b/samples/client/petstore/python/docs/Model200Response.md new file mode 100644 index 00000000000..e29747a87e7 --- /dev/null +++ b/samples/client/petstore/python/docs/Model200Response.md @@ -0,0 +1,10 @@ +# Model200Response + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/ModelReturn.md b/samples/client/petstore/python/docs/ModelReturn.md new file mode 100644 index 00000000000..2b03798e301 --- /dev/null +++ b/samples/client/petstore/python/docs/ModelReturn.md @@ -0,0 +1,10 @@ +# ModelReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_return** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Name.md b/samples/client/petstore/python/docs/Name.md new file mode 100644 index 00000000000..26473221c32 --- /dev/null +++ b/samples/client/petstore/python/docs/Name.md @@ -0,0 +1,11 @@ +# Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | [optional] +**snake_case** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Order.md b/samples/client/petstore/python/docs/Order.md new file mode 100644 index 00000000000..4499eaa976d --- /dev/null +++ b/samples/client/petstore/python/docs/Order.md @@ -0,0 +1,15 @@ +# Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**pet_id** | **int** | | [optional] +**quantity** | **int** | | [optional] +**ship_date** | **datetime** | | [optional] +**status** | **str** | Order Status | [optional] +**complete** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Pet.md b/samples/client/petstore/python/docs/Pet.md new file mode 100644 index 00000000000..9e15090300f --- /dev/null +++ b/samples/client/petstore/python/docs/Pet.md @@ -0,0 +1,15 @@ +# Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **str** | | +**photo_urls** | **list[str]** | | +**tags** | [**list[Tag]**](Tag.md) | | [optional] +**status** | **str** | pet status in the store | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/PetApi.md b/samples/client/petstore/python/docs/PetApi.md new file mode 100644 index 00000000000..3349a3cb7d4 --- /dev/null +++ b/samples/client/petstore/python/docs/PetApi.md @@ -0,0 +1,596 @@ +# swagger_client\PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **add_pet** +> add_pet(body=body) + +Add a new pet to the store + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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) + +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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[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=body) + +Fake endpoint to test byte array in body parameter for adding a new pet to the store + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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 = '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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **str**| Pet object in the form of byte array | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[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=api_key) + +Deletes a pet + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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() +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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| Pet id to delete | + **api_key** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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=status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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() +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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**list[str]**](str.md)| Status values that need to be considered for query | [optional] [default to available] + +### Return type + +[**list[Pet]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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=tags) + +Finds Pets by tags + +Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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() +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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**list[str]**](str.md)| Tags to filter by | [optional] + +### Return type + +[**list[Pet]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +Find pet by ID + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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' + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +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 +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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' + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**InlineResponse200**](InlineResponse200.md) + +### Authorization + +[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +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 +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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' + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +**str** + +### Authorization + +[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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=body) + +Update an existing pet + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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) + +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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[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=name, status=status) + +Updates a pet in the store with form data + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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() +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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **str**| ID of pet that needs to be updated | + **name** | **str**| Updated name of the pet | [optional] + **status** | **str**| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/json, application/xml + +[[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=additional_metadata, file=file) + +uploads an image + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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() +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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to update | + **additional_metadata** | **str**| Additional data to pass to server | [optional] + **file** | **file**| file to upload | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json, application/xml + +[[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) + diff --git a/samples/client/petstore/python/docs/SpecialModelName.md b/samples/client/petstore/python/docs/SpecialModelName.md new file mode 100644 index 00000000000..022ee19169c --- /dev/null +++ b/samples/client/petstore/python/docs/SpecialModelName.md @@ -0,0 +1,10 @@ +# SpecialModelName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**special_property_name** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/StoreApi.md b/samples/client/petstore/python/docs/StoreApi.md new file mode 100644 index 00000000000..bbffc6e384b --- /dev/null +++ b/samples/client/petstore/python/docs/StoreApi.md @@ -0,0 +1,330 @@ +# swagger_client\StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + +# **delete_order** +> 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 +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **str**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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=status) + +Finds orders by status + +A single status value can be provided as a string + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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' + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | **str**| Status value that needs to be considered for query | [optional] [default to placed] + +### Return type + +[**list[Order]**](Order.md) + +### Authorization + +[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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_inventory** +> dict(str, int) get_inventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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' + +# 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 +This endpoint does not need any parameter. + +### Return type + +[**dict(str, int)**](dict.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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_inventory_in_object** +> object get_inventory_in_object() + +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 +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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' + +# 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 +This endpoint does not need any parameter. + +### Return type + +**object** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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' + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **str**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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=body) + +Place an order for a pet + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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' + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional] + +### Return type + +[**Order**](Order.md) + +### Authorization + +[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + diff --git a/samples/client/petstore/python/docs/Tag.md b/samples/client/petstore/python/docs/Tag.md new file mode 100644 index 00000000000..243cd98eda6 --- /dev/null +++ b/samples/client/petstore/python/docs/Tag.md @@ -0,0 +1,11 @@ +# Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/User.md b/samples/client/petstore/python/docs/User.md new file mode 100644 index 00000000000..443ac123fdc --- /dev/null +++ b/samples/client/petstore/python/docs/User.md @@ -0,0 +1,17 @@ +# User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**username** | **str** | | [optional] +**first_name** | **str** | | [optional] +**last_name** | **str** | | [optional] +**email** | **str** | | [optional] +**password** | **str** | | [optional] +**phone** | **str** | | [optional] +**user_status** | **int** | User Status | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/UserApi.md b/samples/client/petstore/python/docs/UserApi.md new file mode 100644 index 00000000000..8145147a6ff --- /dev/null +++ b/samples/client/petstore/python/docs/UserApi.md @@ -0,0 +1,398 @@ +# swagger_client\UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +# **create_user** +> create_user(body=body) + +Create user + +This can only be done by the logged in user. + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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=body) + +Creates list of users with given input array + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**list[User]**](User.md)| List of user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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=body) + +Creates list of users with given input array + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**list[User]**](User.md)| List of user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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 + +This can only be done by the logged in user. + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure HTTP basic authorization: test_http_basic +swagger_client.configuration.username = 'YOUR_USERNAME' +swagger_client.configuration.password = 'YOUR_PASSWORD' + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +[test_http_basic](../README.md#test_http_basic) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +Get user by user name + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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=username, password=password) + +Logs user into the system + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| The user name for login | [optional] + **password** | **str**| The password for login in clear text | [optional] + +### Return type + +**str** + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **logout_user** +> logout_user() + +Logs out current logged in user session + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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 +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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=body) + +Updated user + +This can only be done by the logged in user. + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# 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 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + diff --git a/samples/client/petstore/python/swagger_client/__init__.py b/samples/client/petstore/python/swagger_client/__init__.py index 3b52f200834..dbdd791ada2 100644 --- a/samples/client/petstore/python/swagger_client/__init__.py +++ b/samples/client/petstore/python/swagger_client/__init__.py @@ -1,7 +1,10 @@ from __future__ import absolute_import # import models into sdk package +from .models.animal import Animal +from .models.cat import Cat from .models.category import Category +from .models.dog import Dog from .models.inline_response_200 import InlineResponse200 from .models.model_200_response import Model200Response from .models.model_return import ModelReturn diff --git a/samples/client/petstore/python/swagger_client/models/__init__.py b/samples/client/petstore/python/swagger_client/models/__init__.py index baccc53b4d6..c441500bc40 100644 --- a/samples/client/petstore/python/swagger_client/models/__init__.py +++ b/samples/client/petstore/python/swagger_client/models/__init__.py @@ -1,7 +1,10 @@ from __future__ import absolute_import # import models into model package +from .animal import Animal +from .cat import Cat from .category import Category +from .dog import Dog from .inline_response_200 import InlineResponse200 from .model_200_response import Model200Response from .model_return import ModelReturn 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 + diff --git a/samples/client/petstore/python/swagger_client/models/name.py b/samples/client/petstore/python/swagger_client/models/name.py index 52187bd7bc5..068bca97eea 100644 --- a/samples/client/petstore/python/swagger_client/models/name.py +++ b/samples/client/petstore/python/swagger_client/models/name.py @@ -37,14 +37,17 @@ def __init__(self): and the value is json key in definition. """ self.swagger_types = { - 'name': 'int' + 'name': 'int', + 'snake_case': 'int' } self.attribute_map = { - 'name': 'name' + 'name': 'name', + 'snake_case': 'snake_case' } self._name = None + self._snake_case = None @property def name(self): @@ -68,6 +71,28 @@ def name(self, name): """ self._name = name + @property + def snake_case(self): + """ + Gets the snake_case of this Name. + + + :return: The snake_case of this Name. + :rtype: int + """ + return self._snake_case + + @snake_case.setter + def snake_case(self, snake_case): + """ + Sets the snake_case of this Name. + + + :param snake_case: The snake_case of this Name. + :type: int + """ + self._snake_case = snake_case + def to_dict(self): """ Returns the model properties as a dict