spacether 866df36c94
[python-exp] simplify examples (#7157)
* Adds example setting code in python-experimental with one fn setting example values

Fixes sample indentations

Handles composed schema models, object model and arraymodels

Adds brackets in arraymodel input

Sets modelName with map schemas

Removes included_schemas arguments, dicriminator examples do not include property examples

Refactors modelName into toExampleValueRecursive argument

Fixes bug where example models contained themselves

Stops using model ExampleGenerator examples because they are inconsistent with the ones in python-experimental

Uses example values if they exist

Removes single quotes from enum examples

Fixes password example

Adds commented our regex handling, commented out because it breaks

Handles AnyType schema examples

Adds x_example values for simple string properties, uses toExampleValue for all example generation

Adds examples for simple string parameters

Updates comments in toExampleValueBase

Fixes the double nested bug for AdditionalPropertiesWithArrayOfEnums

Fixes bug where NumberWithValidations had double nesting

Updates simple string examples in arrays

Fixes array string examples

Fixes example for string endpoint body example

Adds exampleFromStringOrArraySchema

Adds regex examples, pegs slf4j-version to v1.7.29 for rgxgen

Adds comment about regex seed

Updates pattern matcher to not handle ^ and $

Updates used sample values

Adds ensureQuotes

Adds ensureQuotes

Fixes double quote bug

Updates mustache file

Adds ensureQuotes to key handling

Adds modelNameToSchema map, reduces run time by using it

Fixes java tests

Regenerates python-experimental samples

Fixes python test

* Rebased on master

* Adds getModelNameToSchemaCache

* Updates toDefaultValue to not mutate schemas

* Has all dates and datetimes default and example setting use the same helper function

* Samples regenerated

* indentation tweak, removes txt from sample file
2020-08-19 21:27:31 -07:00

25 KiB

petstore_api.PetApi

All URIs are relative to http://petstore.swagger.io:80/v2

Method HTTP request Description
add_pet POST /pet Add a new pet to the store
delete_pet DELETE /pet/{petId} Deletes a pet
find_pets_by_status GET /pet/findByStatus Finds Pets by status
find_pets_by_tags GET /pet/findByTags Finds Pets by tags
get_pet_by_id GET /pet/{petId} Find pet by ID
update_pet PUT /pet Update an existing pet
update_pet_with_form POST /pet/{petId} Updates a pet in the store with form data
upload_file POST /pet/{petId}/uploadImage uploads an image
upload_file_with_required_file POST /fake/{petId}/uploadImageWithRequiredFile uploads an image (required)

add_pet

add_pet(body)

Add a new pet to the store

Example

  • OAuth Authentication (petstore_auth):
import time
import petstore_api
from petstore_api.api import pet_api
from petstore_api.model.pet import Pet
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure OAuth2 access token for authorization: petstore_auth
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'

# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = pet_api.PetApi(api_client)
    body = Pet(
        id=1,
        category=Category(
            id=1,
            name="default-name",
        ),
        name="doggie",
        photo_urls=[
            "photo_urls_example",
        ],
        tags=[
            Tag(
                id=1,
                name="name_example",
                full_name="full_name_example",
            ),
        ],
        status="available",
    ) # Pet | Pet object that needs to be added to the store

    # example passing only required values which don't have defaults set
    try:
        # Add a new pet to the store
        api_instance.add_pet(body)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->add_pet: %s\n" % e)

Parameters

Name Type Description Notes
body Pet Pet object that needs to be added to the store

Return type

void (empty response body)

Authorization

petstore_auth

HTTP request headers

  • Content-Type: application/json, application/xml
  • Accept: Not defined

HTTP response details

Status code Description Response headers
200 successful operation -
405 Invalid input -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

delete_pet

delete_pet(pet_id)

Deletes a pet

Example

  • OAuth Authentication (petstore_auth):
import time
import petstore_api
from petstore_api.api import pet_api
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure OAuth2 access token for authorization: petstore_auth
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'

# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = pet_api.PetApi(api_client)
    pet_id = 1 # int | Pet id to delete
    api_key = "api_key_example" # str |  (optional)

    # example passing only required values which don't have defaults set
    try:
        # Deletes a pet
        api_instance.delete_pet(pet_id)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->delete_pet: %s\n" % e)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # Deletes a pet
        api_instance.delete_pet(pet_id, api_key=api_key)
    except petstore_api.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

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

HTTP response details

Status code Description Response headers
200 successful operation -
400 Invalid pet value -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

find_pets_by_status

[Pet] find_pets_by_status(status)

Finds Pets by status

Multiple status values can be provided with comma separated strings

Example

  • OAuth Authentication (petstore_auth):
import time
import petstore_api
from petstore_api.api import pet_api
from petstore_api.model.pet import Pet
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure OAuth2 access token for authorization: petstore_auth
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'

# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = pet_api.PetApi(api_client)
    status = [
        "available",
    ] # [str] | Status values that need to be considered for filter

    # example passing only required values which don't have defaults set
    try:
        # Finds Pets by status
        api_response = api_instance.find_pets_by_status(status)
        pprint(api_response)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->find_pets_by_status: %s\n" % e)

Parameters

Name Type Description Notes
status [str] Status values that need to be considered for filter

Return type

[Pet]

Authorization

petstore_auth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/xml, application/json

HTTP response details

Status code Description Response headers
200 successful operation -
400 Invalid status value -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

find_pets_by_tags

[Pet] find_pets_by_tags(tags)

Finds Pets by tags

Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.

Example

  • OAuth Authentication (petstore_auth):
import time
import petstore_api
from petstore_api.api import pet_api
from petstore_api.model.pet import Pet
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure OAuth2 access token for authorization: petstore_auth
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'

# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = pet_api.PetApi(api_client)
    tags = [
        "tags_example",
    ] # [str] | Tags to filter by

    # example passing only required values which don't have defaults set
    try:
        # Finds Pets by tags
        api_response = api_instance.find_pets_by_tags(tags)
        pprint(api_response)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e)

Parameters

Name Type Description Notes
tags [str] Tags to filter by

Return type

[Pet]

Authorization

petstore_auth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/xml, application/json

HTTP response details

Status code Description Response headers
200 successful operation -
400 Invalid tag value -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_pet_by_id

Pet get_pet_by_id(pet_id)

Find pet by ID

Returns a single pet

Example

  • Api Key Authentication (api_key):
import time
import petstore_api
from petstore_api.api import pet_api
from petstore_api.model.pet import Pet
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: api_key
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2",
    api_key = {
        'api_key': 'YOUR_API_KEY'
    }
)
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api_key'] = 'Bearer'

# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = pet_api.PetApi(api_client)
    pet_id = 1 # int | ID of pet to return

    # example passing only required values which don't have defaults set
    try:
        # Find pet by ID
        api_response = api_instance.get_pet_by_id(pet_id)
        pprint(api_response)
    except petstore_api.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 to return

Return type

Pet

Authorization

api_key

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/xml, application/json

HTTP response details

Status code Description Response headers
200 successful operation -
400 Invalid ID supplied -
404 Pet not found -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

update_pet

update_pet(body)

Update an existing pet

Example

  • OAuth Authentication (petstore_auth):
import time
import petstore_api
from petstore_api.api import pet_api
from petstore_api.model.pet import Pet
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure OAuth2 access token for authorization: petstore_auth
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'

# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = pet_api.PetApi(api_client)
    body = Pet(
        id=1,
        category=Category(
            id=1,
            name="default-name",
        ),
        name="doggie",
        photo_urls=[
            "photo_urls_example",
        ],
        tags=[
            Tag(
                id=1,
                name="name_example",
                full_name="full_name_example",
            ),
        ],
        status="available",
    ) # Pet | Pet object that needs to be added to the store

    # example passing only required values which don't have defaults set
    try:
        # Update an existing pet
        api_instance.update_pet(body)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->update_pet: %s\n" % e)

Parameters

Name Type Description Notes
body Pet Pet object that needs to be added to the store

Return type

void (empty response body)

Authorization

petstore_auth

HTTP request headers

  • Content-Type: application/json, application/xml
  • Accept: Not defined

HTTP response details

Status code Description Response headers
200 successful operation -
400 Invalid ID supplied -
404 Pet not found -
405 Validation exception -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

update_pet_with_form

update_pet_with_form(pet_id)

Updates a pet in the store with form data

Example

  • OAuth Authentication (petstore_auth):
import time
import petstore_api
from petstore_api.api import pet_api
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure OAuth2 access token for authorization: petstore_auth
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'

# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = pet_api.PetApi(api_client)
    pet_id = 1 # int | 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)

    # example passing only required values which don't have defaults set
    try:
        # Updates a pet in the store with form data
        api_instance.update_pet_with_form(pet_id)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->update_pet_with_form: %s\n" % e)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # Updates a pet in the store with form data
        api_instance.update_pet_with_form(pet_id, name=name, status=status)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->update_pet_with_form: %s\n" % e)

Parameters

Name Type Description Notes
pet_id int 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

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: Not defined

HTTP response details

Status code Description Response headers
405 Invalid input -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

upload_file

ApiResponse upload_file(pet_id)

uploads an image

Example

  • OAuth Authentication (petstore_auth):
import time
import petstore_api
from petstore_api.api import pet_api
from petstore_api.model.api_response import ApiResponse
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure OAuth2 access token for authorization: petstore_auth
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'

# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = pet_api.PetApi(api_client)
    pet_id = 1 # int | ID of pet to update
    additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional)
    file = open('/path/to/file', 'rb') # file_type | file to upload (optional)
    files =  # [file_type] | files to upload (optional)

    # example passing only required values which don't have defaults set
    try:
        # uploads an image
        api_response = api_instance.upload_file(pet_id)
        pprint(api_response)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->upload_file: %s\n" % e)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # uploads an image
        api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file, files=files)
        pprint(api_response)
    except petstore_api.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_type file to upload [optional]
files [file_type] files to upload [optional]

Return type

ApiResponse

Authorization

petstore_auth

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 successful operation -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

upload_file_with_required_file

ApiResponse upload_file_with_required_file(pet_id, required_file)

uploads an image (required)

Example

  • OAuth Authentication (petstore_auth):
import time
import petstore_api
from petstore_api.api import pet_api
from petstore_api.model.api_response import ApiResponse
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure OAuth2 access token for authorization: petstore_auth
configuration = petstore_api.Configuration(
    host = "http://petstore.swagger.io:80/v2"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'

# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = pet_api.PetApi(api_client)
    pet_id = 1 # int | ID of pet to update
    required_file = open('/path/to/file', 'rb') # file_type | file to upload
    additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional)

    # example passing only required values which don't have defaults set
    try:
        # uploads an image (required)
        api_response = api_instance.upload_file_with_required_file(pet_id, required_file)
        pprint(api_response)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # uploads an image (required)
        api_response = api_instance.upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata)
        pprint(api_response)
    except petstore_api.ApiException as e:
        print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)

Parameters

Name Type Description Notes
pet_id int ID of pet to update
required_file file_type file to upload
additional_metadata str Additional data to pass to server [optional]

Return type

ApiResponse

Authorization

petstore_auth

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 successful operation -

[Back to top] [Back to API list] [Back to Model list] [Back to README]