Skip to content

Latest commit

 

History

History
391 lines (261 loc) · 10.7 KB

PetApi.md

File metadata and controls

391 lines (261 loc) · 10.7 KB

openapi.api.PetApi

Load the API package

import 'package:openapi/api.dart';

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

Method HTTP request Description
addPet POST /pet Add a new pet to the store
deletePet DELETE /pet/{petId} Deletes a pet
findPetsByStatus GET /pet/findByStatus Finds Pets by status
findPetsByTags GET /pet/findByTags Finds Pets by tags
getPetById GET /pet/{petId} Find pet by ID
updatePet PUT /pet Update an existing pet
updatePetWithForm POST /pet/{petId} Updates a pet in the store with form data
uploadFile POST /pet/{petId}/uploadImage uploads an image

addPet

Pet addPet(pet)

Add a new pet to the store

Example

import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';

final api_instance = PetApi();
final pet = Pet(); // Pet | Pet object that needs to be added to the store

try {
    final result = api_instance.addPet(pet);
    print(result);
} catch (e) {
    print('Exception when calling PetApi->addPet: $e\n');
}

Parameters

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

Return type

Pet

Authorization

petstore_auth

HTTP request headers

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

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

deletePet

deletePet(petId, apiKey)

Deletes a pet

Example

import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';

final api_instance = PetApi();
final petId = 789; // int | Pet id to delete
final apiKey = apiKey_example; // String | 

try {
    api_instance.deletePet(petId, apiKey);
} catch (e) {
    print('Exception when calling PetApi->deletePet: $e\n');
}

Parameters

Name Type Description Notes
petId int Pet id to delete
apiKey String [optional]

Return type

void (empty response body)

Authorization

petstore_auth

HTTP request headers

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

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

findPetsByStatus

List findPetsByStatus(status)

Finds Pets by status

Multiple status values can be provided with comma separated strings

Example

import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';

final api_instance = PetApi();
final status = []; // List<String> | Status values that need to be considered for filter

try {
    final result = api_instance.findPetsByStatus(status);
    print(result);
} catch (e) {
    print('Exception when calling PetApi->findPetsByStatus: $e\n');
}

Parameters

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

Return type

List

Authorization

petstore_auth

HTTP request headers

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

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

findPetsByTags

List findPetsByTags(tags)

Finds Pets by tags

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

Example

import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';

final api_instance = PetApi();
final tags = []; // List<String> | Tags to filter by

try {
    final result = api_instance.findPetsByTags(tags);
    print(result);
} catch (e) {
    print('Exception when calling PetApi->findPetsByTags: $e\n');
}

Parameters

Name Type Description Notes
tags List Tags to filter by [default to const []]

Return type

List

Authorization

petstore_auth

HTTP request headers

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

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

getPetById

Pet getPetById(petId)

Find pet by ID

Returns a single pet

Example

import 'package:openapi/api.dart';
// TODO Configure API key authorization: api_key
//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKey = 'YOUR_API_KEY';
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKeyPrefix = 'Bearer';

final api_instance = PetApi();
final petId = 789; // int | ID of pet to return

try {
    final result = api_instance.getPetById(petId);
    print(result);
} catch (e) {
    print('Exception when calling PetApi->getPetById: $e\n');
}

Parameters

Name Type Description Notes
petId int ID of pet to return

Return type

Pet

Authorization

api_key

HTTP request headers

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

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

updatePet

Pet updatePet(pet)

Update an existing pet

Example

import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';

final api_instance = PetApi();
final pet = Pet(); // Pet | Pet object that needs to be added to the store

try {
    final result = api_instance.updatePet(pet);
    print(result);
} catch (e) {
    print('Exception when calling PetApi->updatePet: $e\n');
}

Parameters

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

Return type

Pet

Authorization

petstore_auth

HTTP request headers

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

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

updatePetWithForm

updatePetWithForm(petId, name, status)

Updates a pet in the store with form data

Example

import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';

final api_instance = PetApi();
final petId = 789; // int | ID of pet that needs to be updated
final name = name_example; // String | Updated name of the pet
final status = status_example; // String | Updated status of the pet

try {
    api_instance.updatePetWithForm(petId, name, status);
} catch (e) {
    print('Exception when calling PetApi->updatePetWithForm: $e\n');
}

Parameters

Name Type Description Notes
petId int ID of pet that needs to be updated
name String Updated name of the pet [optional]
status String 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

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

uploadFile

ApiResponse uploadFile(petId, additionalMetadata, file)

uploads an image

Example

import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';

final api_instance = PetApi();
final petId = 789; // int | ID of pet to update
final additionalMetadata = additionalMetadata_example; // String | Additional data to pass to server
final file = BINARY_DATA_HERE; // MultipartFile | file to upload

try {
    final result = api_instance.uploadFile(petId, additionalMetadata, file);
    print(result);
} catch (e) {
    print('Exception when calling PetApi->uploadFile: $e\n');
}

Parameters

Name Type Description Notes
petId int ID of pet to update
additionalMetadata String Additional data to pass to server [optional]
file MultipartFile file to upload [optional]

Return type

ApiResponse

Authorization

petstore_auth

HTTP request headers

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

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