Swagger Petstore v3 (OpenAPI 3)

Pets

createPets

Create a pet


/pets

Usage and SDK Samples

curl -X POST "http://petstore.swagger.io/v1/pets"
import org.openapitools.client.*;
import org.openapitools.client.auth.*;
import org.openapitools.client.model.*;
import org.openapitools.client.api.PetsApi;

import java.io.File;
import java.util.*;

public class PetsApiExample {

    public static void main(String[] args) {
        
        PetsApi apiInstance = new PetsApi();
        try {
            apiInstance.createPets();
        } catch (ApiException e) {
            System.err.println("Exception when calling PetsApi#createPets");
            e.printStackTrace();
        }
    }
}
import org.openapitools.client.api.PetsApi;

public class PetsApiExample {

    public static void main(String[] args) {
        PetsApi apiInstance = new PetsApi();
        try {
            apiInstance.createPets();
        } catch (ApiException e) {
            System.err.println("Exception when calling PetsApi#createPets");
            e.printStackTrace();
        }
    }
}

PetsApi *apiInstance = [[PetsApi alloc] init];

// Create a pet
[apiInstance createPetsWithCompletionHandler: 
              ^(NSError* error) {
                            if (error) {
                                NSLog(@"Error: %@", error);
                            }
                        }];
var SwaggerPetstoreV3OpenApi3 = require('swagger_petstore_v3__open_api_3');

var api = new SwaggerPetstoreV3OpenApi3.PetsApi()
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully.');
  }
};
api.createPets(callback);
using System;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;

namespace Example
{
    public class createPetsExample
    {
        public void main()
        {
            
            var apiInstance = new PetsApi();

            try
            {
                // Create a pet
                apiInstance.createPets();
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling PetsApi.createPets: " + e.Message );
            }
        }
    }
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');

$api_instance = new OpenAPITools\Client\Api\PetsApi();

try {
    $api_instance->createPets();
} catch (Exception $e) {
    echo 'Exception when calling PetsApi->createPets: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::OPenAPIClient::Configuration;
use WWW::OPenAPIClient::PetsApi;

my $api_instance = WWW::OPenAPIClient::PetsApi->new();

eval { 
    $api_instance->createPets();
};
if ($@) {
    warn "Exception when calling PetsApi->createPets: $@\n";
}
from __future__ import print_statement
import time
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = openapi_client.PetsApi()

try: 
    # Create a pet
    api_instance.create_pets()
except ApiException as e:
    print("Exception when calling PetsApi->createPets: %s\n" % e)
extern crate PetsApi;

pub fn main() {

    let mut context = PetsApi::Context::default();
    let result = client.createPets(&context).wait();
    println!("{:?}", result);

}

Scopes

Parameters

Responses


listPets

List all pets


/pets

Usage and SDK Samples

curl -X GET "http://petstore.swagger.io/v1/pets?limit="
import org.openapitools.client.*;
import org.openapitools.client.auth.*;
import org.openapitools.client.model.*;
import org.openapitools.client.api.PetsApi;

import java.io.File;
import java.util.*;

public class PetsApiExample {

    public static void main(String[] args) {
        
        PetsApi apiInstance = new PetsApi();
        Integer limit = 56; // Integer | How many items to return at one time (max 100)
        try {
            array[Pet] result = apiInstance.listPets(limit);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling PetsApi#listPets");
            e.printStackTrace();
        }
    }
}
import org.openapitools.client.api.PetsApi;

public class PetsApiExample {

    public static void main(String[] args) {
        PetsApi apiInstance = new PetsApi();
        Integer limit = 56; // Integer | How many items to return at one time (max 100)
        try {
            array[Pet] result = apiInstance.listPets(limit);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling PetsApi#listPets");
            e.printStackTrace();
        }
    }
}
Integer *limit = 56; // How many items to return at one time (max 100) (optional) (default to null)

PetsApi *apiInstance = [[PetsApi alloc] init];

// List all pets
[apiInstance listPetsWith:limit
              completionHandler: ^(array[Pet] output, NSError* error) {
                            if (output) {
                                NSLog(@"%@", output);
                            }
                            if (error) {
                                NSLog(@"Error: %@", error);
                            }
                        }];
var SwaggerPetstoreV3OpenApi3 = require('swagger_petstore_v3__open_api_3');

var api = new SwaggerPetstoreV3OpenApi3.PetsApi()
var opts = {
  'limit': 56 // {Integer} How many items to return at one time (max 100)
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.listPets(opts, callback);
using System;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;

namespace Example
{
    public class listPetsExample
    {
        public void main()
        {
            
            var apiInstance = new PetsApi();
            var limit = 56;  // Integer | How many items to return at one time (max 100) (optional)  (default to null)

            try
            {
                // List all pets
                array[Pet] result = apiInstance.listPets(limit);
                Debug.WriteLine(result);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling PetsApi.listPets: " + e.Message );
            }
        }
    }
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');

$api_instance = new OpenAPITools\Client\Api\PetsApi();
$limit = 56; // Integer | How many items to return at one time (max 100)

try {
    $result = $api_instance->listPets($limit);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling PetsApi->listPets: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::OPenAPIClient::Configuration;
use WWW::OPenAPIClient::PetsApi;

my $api_instance = WWW::OPenAPIClient::PetsApi->new();
my $limit = 56; # Integer | How many items to return at one time (max 100)

eval { 
    my $result = $api_instance->listPets(limit => $limit);
    print Dumper($result);
};
if ($@) {
    warn "Exception when calling PetsApi->listPets: $@\n";
}
from __future__ import print_statement
import time
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = openapi_client.PetsApi()
limit = 56 # Integer | How many items to return at one time (max 100) (optional) (default to null)

try: 
    # List all pets
    api_response = api_instance.list_pets(limit=limit)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling PetsApi->listPets: %s\n" % e)
extern crate PetsApi;

pub fn main() {
    let limit = 56; // Integer

    let mut context = PetsApi::Context::default();
    let result = client.listPets(limit, &context).wait();
    println!("{:?}", result);

}

Scopes

Parameters

Query parameters
Name Description
limit
Integer (int32)
How many items to return at one time (max 100)

Responses

Name Type Format Description
xMinusnext String A link to the next page of responses


showPetById

Info for a specific pet


/pets/{petId}

Usage and SDK Samples

curl -X GET "http://petstore.swagger.io/v1/pets/{petId}"
import org.openapitools.client.*;
import org.openapitools.client.auth.*;
import org.openapitools.client.model.*;
import org.openapitools.client.api.PetsApi;

import java.io.File;
import java.util.*;

public class PetsApiExample {

    public static void main(String[] args) {
        
        PetsApi apiInstance = new PetsApi();
        String petId = petId_example; // String | The id of the pet to retrieve
        try {
            array[Pet] result = apiInstance.showPetById(petId);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling PetsApi#showPetById");
            e.printStackTrace();
        }
    }
}
import org.openapitools.client.api.PetsApi;

public class PetsApiExample {

    public static void main(String[] args) {
        PetsApi apiInstance = new PetsApi();
        String petId = petId_example; // String | The id of the pet to retrieve
        try {
            array[Pet] result = apiInstance.showPetById(petId);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling PetsApi#showPetById");
            e.printStackTrace();
        }
    }
}
String *petId = petId_example; // The id of the pet to retrieve (default to null)

PetsApi *apiInstance = [[PetsApi alloc] init];

// Info for a specific pet
[apiInstance showPetByIdWith:petId
              completionHandler: ^(array[Pet] output, NSError* error) {
                            if (output) {
                                NSLog(@"%@", output);
                            }
                            if (error) {
                                NSLog(@"Error: %@", error);
                            }
                        }];
var SwaggerPetstoreV3OpenApi3 = require('swagger_petstore_v3__open_api_3');

var api = new SwaggerPetstoreV3OpenApi3.PetsApi()
var petId = petId_example; // {String} The id of the pet to retrieve

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.showPetById(petId, callback);
using System;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;

namespace Example
{
    public class showPetByIdExample
    {
        public void main()
        {
            
            var apiInstance = new PetsApi();
            var petId = petId_example;  // String | The id of the pet to retrieve (default to null)

            try
            {
                // Info for a specific pet
                array[Pet] result = apiInstance.showPetById(petId);
                Debug.WriteLine(result);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling PetsApi.showPetById: " + e.Message );
            }
        }
    }
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');

$api_instance = new OpenAPITools\Client\Api\PetsApi();
$petId = petId_example; // String | The id of the pet to retrieve

try {
    $result = $api_instance->showPetById($petId);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling PetsApi->showPetById: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::OPenAPIClient::Configuration;
use WWW::OPenAPIClient::PetsApi;

my $api_instance = WWW::OPenAPIClient::PetsApi->new();
my $petId = petId_example; # String | The id of the pet to retrieve

eval { 
    my $result = $api_instance->showPetById(petId => $petId);
    print Dumper($result);
};
if ($@) {
    warn "Exception when calling PetsApi->showPetById: $@\n";
}
from __future__ import print_statement
import time
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = openapi_client.PetsApi()
petId = petId_example # String | The id of the pet to retrieve (default to null)

try: 
    # Info for a specific pet
    api_response = api_instance.show_pet_by_id(petId)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling PetsApi->showPetById: %s\n" % e)
extern crate PetsApi;

pub fn main() {
    let petId = petId_example; // String

    let mut context = PetsApi::Context::default();
    let result = client.showPetById(petId, &context).wait();
    println!("{:?}", result);

}

Scopes

Parameters

Path parameters
Name Description
petId*
String
The id of the pet to retrieve
Required

Responses