Created
August 27, 2014 20:48
-
-
Save raymondfeng/8ba80ecbf3a0d4f5edd2 to your computer and use it in GitHub Desktop.
Generated loopback model from swagger api v1.2 specs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(SwaggerModel) = { | |
/** | |
* Find pet by ID | |
* @param {integer} petId ID of pet that needs to be fetched | |
* @callback {Function} callback Callback function | |
* @param {Error|String} err Error object | |
* @param {Pet} result Result object | |
*/ | |
function getPetById(petId, callback) { | |
// Add your implementation here. Please make sure the callback is invoked | |
/* | |
var err0 = new Error('Invalid ID supplied'); | |
err0.statusCode = 400; | |
return cb(err0); | |
*/ | |
/* | |
var err1 = new Error('Pet not found'); | |
err1.statusCode = 404; | |
return cb(err1); | |
*/ | |
} | |
/** | |
* partial updates to a pet | |
* @param {string} petId ID of pet that needs to be fetched * @param {Pet} body Pet object that needs to be added to the store | |
* @callback {Function} callback Callback function | |
* @param {Error|String} err Error object | |
* @param {array} result Result object | |
*/ | |
function partialUpdate(petId, body, callback) { | |
// Add your implementation here. Please make sure the callback is invoked | |
/* | |
var err0 = new Error('Invalid tag value'); | |
err0.statusCode = 400; | |
return cb(err0); | |
*/ | |
} | |
/** | |
* Updates a pet in the store with form data | |
* @param {string} petId ID of pet that needs to be updated * @param {string} name Updated name of the pet * @param {string} status Updated status of the pet | |
* @callback {Function} callback Callback function | |
* @param {Error|String} err Error object | |
* @param {void} result Result object | |
*/ | |
function updatePetWithForm(petId, name, status, callback) { | |
// Add your implementation here. Please make sure the callback is invoked | |
/* | |
var err0 = new Error('Invalid input'); | |
err0.statusCode = 405; | |
return cb(err0); | |
*/ | |
} | |
/** | |
* Deletes a pet | |
* @param {string} petId Pet id to delete | |
* @callback {Function} callback Callback function | |
* @param {Error|String} err Error object | |
* @param {void} result Result object | |
*/ | |
function deletePet(petId, callback) { | |
// Add your implementation here. Please make sure the callback is invoked | |
/* | |
var err0 = new Error('Invalid pet value'); | |
err0.statusCode = 400; | |
return cb(err0); | |
*/ | |
} | |
/** | |
* Add a new pet to the store | |
* @param {Pet} body Pet object that needs to be added to the store | |
* @callback {Function} callback Callback function | |
* @param {Error|String} err Error object | |
* @param {void} result Result object | |
*/ | |
function addPet(body, callback) { | |
// Add your implementation here. Please make sure the callback is invoked | |
/* | |
var err0 = new Error('Invalid input'); | |
err0.statusCode = 405; | |
return cb(err0); | |
*/ | |
} | |
/** | |
* Update an existing pet | |
* @param {Pet} body Pet object that needs to be updated in the store | |
* @callback {Function} callback Callback function | |
* @param {Error|String} err Error object | |
* @param {void} result Result object | |
*/ | |
function updatePet(body, callback) { | |
// Add your implementation here. Please make sure the callback is invoked | |
/* | |
var err0 = new Error('Invalid ID supplied'); | |
err0.statusCode = 400; | |
return cb(err0); | |
*/ | |
/* | |
var err1 = new Error('Pet not found'); | |
err1.statusCode = 404; | |
return cb(err1); | |
*/ | |
/* | |
var err2 = new Error('Validation exception'); | |
err2.statusCode = 405; | |
return cb(err2); | |
*/ | |
} | |
/** | |
* Finds Pets by status | |
* @param {string} status Status values that need to be considered for filter | |
* @callback {Function} callback Callback function | |
* @param {Error|String} err Error object | |
* @param {array} result Result object | |
*/ | |
function findPetsByStatus(status, callback) { | |
// Add your implementation here. Please make sure the callback is invoked | |
/* | |
var err0 = new Error('Invalid status value'); | |
err0.statusCode = 400; | |
return cb(err0); | |
*/ | |
} | |
/** | |
* Finds Pets by tags | |
* @param {string} tags Tags to filter by | |
* @callback {Function} callback Callback function | |
* @param {Error|String} err Error object | |
* @param {array} result Result object | |
*/ | |
function findPetsByTags(tags, callback) { | |
// Add your implementation here. Please make sure the callback is invoked | |
/* | |
var err0 = new Error('Invalid tag value'); | |
err0.statusCode = 400; | |
return cb(err0); | |
*/ | |
} | |
/** | |
* uploads an image | |
* @param {string} additionalMetadata Additional data to pass to server * @param {File} file file to upload | |
* @callback {Function} callback Callback function | |
* @param {Error|String} err Error object | |
* @param {void} result Result object | |
*/ | |
function uploadFile(additionalMetadata, file, callback) { | |
// Add your implementation here. Please make sure the callback is invoked | |
} | |
SwaggerModel.remoteMethod('getPetById', | |
{ isStatic: true, | |
produces: | |
[ 'application/json', | |
'application/xml', | |
'text/plain', | |
'text/html' ], | |
accepts: | |
[ { arg: 'petId', | |
type: 'number', | |
description: 'ID of pet that needs to be fetched', | |
required: true, | |
http: [Object] } ], | |
returns: [ { description: undefined, type: 'Pet' } ], | |
http: { verb: 'get', path: '/pet/:petId' } } | |
}); | |
SwaggerModel.remoteMethod('partialUpdate', | |
{ isStatic: true, | |
consumes: [ 'application/json', 'application/xml' ], | |
produces: [ 'application/json', 'application/xml' ], | |
accepts: | |
[ { arg: 'petId', | |
type: 'string', | |
description: 'ID of pet that needs to be fetched', | |
required: true, | |
http: [Object] }, | |
{ arg: 'body', | |
type: 'Pet', | |
description: 'Pet object that needs to be added to the store', | |
required: true, | |
http: [Object] } ], | |
returns: [ { description: undefined, type: 'array' } ], | |
http: { verb: 'patch', path: '/pet/:petId' } } | |
}); | |
SwaggerModel.remoteMethod('updatePetWithForm', | |
{ isStatic: true, | |
consumes: [ 'application/x-www-form-urlencoded' ], | |
produces: | |
[ 'application/json', | |
'application/xml', | |
'text/plain', | |
'text/html' ], | |
accepts: | |
[ { arg: 'petId', | |
type: 'string', | |
description: 'ID of pet that needs to be updated', | |
required: true, | |
http: [Object] }, | |
{ arg: 'name', | |
type: 'string', | |
description: 'Updated name of the pet', | |
required: false, | |
http: [Object] }, | |
{ arg: 'status', | |
type: 'string', | |
description: 'Updated status of the pet', | |
required: false, | |
http: [Object] } ], | |
returns: [], | |
http: { verb: 'post', path: '/pet/:petId' } } | |
}); | |
SwaggerModel.remoteMethod('deletePet', | |
{ isStatic: true, | |
produces: | |
[ 'application/json', | |
'application/xml', | |
'text/plain', | |
'text/html' ], | |
accepts: | |
[ { arg: 'petId', | |
type: 'string', | |
description: 'Pet id to delete', | |
required: true, | |
http: [Object] } ], | |
returns: [], | |
http: { verb: 'delete', path: '/pet/:petId' } } | |
}); | |
SwaggerModel.remoteMethod('addPet', | |
{ isStatic: true, | |
consumes: [ 'application/json', 'application/xml' ], | |
produces: | |
[ 'application/json', | |
'application/xml', | |
'text/plain', | |
'text/html' ], | |
accepts: | |
[ { arg: 'body', | |
type: 'Pet', | |
description: 'Pet object that needs to be added to the store', | |
required: true, | |
http: [Object] } ], | |
returns: [], | |
http: { verb: 'post', path: '/pet' } } | |
}); | |
SwaggerModel.remoteMethod('updatePet', | |
{ isStatic: true, | |
produces: | |
[ 'application/json', | |
'application/xml', | |
'text/plain', | |
'text/html' ], | |
accepts: | |
[ { arg: 'body', | |
type: 'Pet', | |
description: 'Pet object that needs to be updated in the store', | |
required: true, | |
http: [Object] } ], | |
returns: [], | |
http: { verb: 'put', path: '/pet' } } | |
}); | |
SwaggerModel.remoteMethod('findPetsByStatus', | |
{ isStatic: true, | |
produces: | |
[ 'application/json', | |
'application/xml', | |
'text/plain', | |
'text/html' ], | |
accepts: | |
[ { arg: 'status', | |
type: 'string', | |
description: 'Status values that need to be considered for filter', | |
required: true, | |
http: [Object] } ], | |
returns: [ { description: undefined, type: 'array' } ], | |
http: { verb: 'get', path: '/pet/findByStatus' } } | |
}); | |
SwaggerModel.remoteMethod('findPetsByTags', | |
{ isStatic: true, | |
produces: | |
[ 'application/json', | |
'application/xml', | |
'text/plain', | |
'text/html' ], | |
accepts: | |
[ { arg: 'tags', | |
type: 'string', | |
description: 'Tags to filter by', | |
required: true, | |
http: [Object] } ], | |
returns: [ { description: undefined, type: 'array' } ], | |
http: { verb: 'get', path: '/pet/findByTags' } } | |
}); | |
SwaggerModel.remoteMethod('uploadFile', | |
{ isStatic: true, | |
consumes: [ 'multipart/form-data' ], | |
produces: | |
[ 'application/json', | |
'application/xml', | |
'text/plain', | |
'text/html' ], | |
accepts: | |
[ { arg: 'additionalMetadata', | |
type: 'string', | |
description: 'Additional data to pass to server', | |
required: false, | |
http: [Object] }, | |
{ arg: 'file', | |
type: 'File', | |
description: 'file to upload', | |
required: false, | |
http: [Object] } ], | |
returns: [], | |
http: { verb: 'post', path: '/pet/uploadImage' } } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment