Conflicts: samples/client/petstore/javascript-promise/README.md samples/client/petstore/javascript-promise/docs/PetApi.md samples/client/petstore/javascript-promise/docs/StoreApi.md samples/client/petstore/javascript-promise/src/api/PetApi.js samples/client/petstore/javascript-promise/src/index.js samples/client/petstore/javascript/README.md samples/client/petstore/javascript/docs/PetApi.md samples/client/petstore/javascript/docs/StoreApi.md samples/client/petstore/javascript/src/api/PetApi.js samples/client/petstore/javascript/src/index.js
15 KiB
SwaggerPetstore.PetApi
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
addPet(opts)
Add a new pet to the store
Example
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var opts = {
'body': new SwaggerPetstore.Pet() // Pet | Pet object that needs to be added to the store
};
apiInstance.addPet(opts).then(function() {
console.log('API called successfully.');
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
body | Pet | Pet object that needs to be added to the store | [optional] |
Return type
null (empty response body)
Authorization
HTTP request headers
<<<<<<< HEAD
- Content-Type: application/json, application/xml
- Accept: application/json, application/xml
addPetUsingByteArray
addPetUsingByteArray(opts)
Fake endpoint to test byte array in body parameter for adding a new pet to the store
Example
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = "YOUR ACCESS TOKEN"
var apiInstance = new SwaggerPetstore.PetApi()
var opts = {
'body': "B" // {String} Pet object in the form of byte array
};
apiInstance.addPetUsingByteArray(opts).then(function() {
console.log('API called successfully.');
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
body | String | Pet object in the form of byte array | [optional] |
Return type
null (empty response body)
Authorization
HTTP request headers
- Content-Type: application/json, application/xml
- Accept: application/json, application/xml
deletePet
deletePet(petId, opts)
Deletes a pet
Example
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var petId = 789; // Integer | Pet id to delete
var opts = {
'apiKey': "apiKey_example" // String |
};
apiInstance.deletePet(petId, opts).then(function() {
console.log('API called successfully.');
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
petId | Integer | Pet id to delete | |
apiKey | String | [optional] |
Return type
null (empty response body)
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/xml
findPetsByStatus
[Pet] findPetsByStatus(opts)
Finds Pets by status
Multiple status values can be provided with comma seperated strings
Example
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var opts = {
'status': ["available"] // [String] | Status values that need to be considered for filter
};
apiInstance.findPetsByStatus(opts).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
status | [String] | Status values that need to be considered for filter | [optional] [default to available] |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/xml
findPetsByTags
[Pet] findPetsByTags(opts)
Finds Pets by tags
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
Example
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var opts = {
'tags': ["tags_example"] // [String] | Tags to filter by
};
apiInstance.findPetsByTags(opts).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
tags | [String] | Tags to filter by | [optional] |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/xml
getPetById
Pet getPetById(petId)
Find pet by ID
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
Example
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix = 'Token';
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var petId = 789; // Integer | ID of pet that needs to be fetched
apiInstance.getPetById(petId).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
petId | Integer | ID of pet that needs to be fetched |
Return type
Authorization
HTTP request headers
<<<<<<< HEAD
- Content-Type: Not defined
- Accept: application/json, application/xml
getPetByIdInObject
InlineResponse200 getPetByIdInObject(petId)
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
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix['api_key'] = "Token"
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = "YOUR ACCESS TOKEN"
var apiInstance = new SwaggerPetstore.PetApi()
var petId = 789; // {Integer} ID of pet that needs to be fetched
apiInstance.getPetByIdInObject(petId).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
petId | Integer | ID of pet that needs to be fetched |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/xml
petPetIdtestingByteArraytrueGet
'String' petPetIdtestingByteArraytrueGet(petId)
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
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix['api_key'] = "Token"
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = "YOUR ACCESS TOKEN"
var apiInstance = new SwaggerPetstore.PetApi()
var petId = 789; // {Integer} ID of pet that needs to be fetched
apiInstance.petPetIdtestingByteArraytrueGet(petId).then(function(data) {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
petId | Integer | ID of pet that needs to be fetched |
Return type
'String'
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/xml
updatePet
updatePet(opts)
Update an existing pet
Example
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var opts = {
'body': new SwaggerPetstore.Pet() // Pet | Pet object that needs to be added to the store
};
apiInstance.updatePet(opts).then(function() {
console.log('API called successfully.');
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
body | Pet | Pet object that needs to be added to the store | [optional] |
Return type
null (empty response body)
Authorization
HTTP request headers
- Content-Type: application/json, application/xml
- Accept: application/json, application/xml
updatePetWithForm
updatePetWithForm(petId, opts)
Updates a pet in the store with form data
Example
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var petId = "petId_example"; // String | ID of pet that needs to be updated
var opts = {
'name': "name_example", // String | Updated name of the pet
'status': "status_example" // String | Updated status of the pet
};
apiInstance.updatePetWithForm(petId, opts).then(function() {
console.log('API called successfully.');
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
petId | String | 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
null (empty response body)
Authorization
HTTP request headers
- Content-Type: application/x-www-form-urlencoded
- Accept: application/json, application/xml
uploadFile
uploadFile(petId, opts)
uploads an image
Example
var SwaggerPetstore = require('swagger-petstore');
var defaultClient = SwaggerPetstore.ApiClient.default;
// Configure OAuth2 access token for authorization: petstore_auth
var petstore_auth = defaultClient.authentications['petstore_auth'];
petstore_auth.accessToken = 'YOUR ACCESS TOKEN';
var apiInstance = new SwaggerPetstore.PetApi();
var petId = 789; // Integer | ID of pet to update
var opts = {
'additionalMetadata': "additionalMetadata_example", // String | Additional data to pass to server
'file': "/path/to/file.txt" // File | file to upload
};
apiInstance.uploadFile(petId, opts).then(function() {
console.log('API called successfully.');
}, function(error) {
console.error(error);
});
Parameters
Name | Type | Description | Notes |
---|---|---|---|
petId | Integer | ID of pet to update | |
additionalMetadata | String | Additional data to pass to server | [optional] |
file | File | file to upload | [optional] |
Return type
null (empty response body)
Authorization
HTTP request headers
- Content-Type: multipart/form-data
- Accept: application/json, application/xml