Skip to content

Instantly share code, notes, and snippets.

@raymondfeng
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raymondfeng/37c672d4cb9b45661d3c to your computer and use it in GitHub Desktop.
Save raymondfeng/37c672d4cb9b45661d3c to your computer and use it in GitHub Desktop.
Generated loopback model from swagger api v2 specs
module.exports = function(Store) = {
/**
* Creates list of users with given input array
* @param {User} body List of user object
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {Object} result Result object
*/
function createUsersWithListInput(body, callback) {
// Add your implementation here. Please make sure the callback is invoked
}
/**
* Update an existing pet
* @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 {Object} 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);
*/
}
/**
* 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 {Object} 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);
*/
}
/**
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
* @param {string} orderId ID of pet that needs to be fetched
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {Order} result Result object
*/
function getOrderById(orderId, 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('Order not found');
err1.statusCode = 404;
return cb(err1);
*/
}
/**
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
* @param {string} orderId ID of the order that needs to be deleted
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {Object} result Result object
*/
function deleteOrder(orderId, 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('Order not found');
err1.statusCode = 404;
return cb(err1);
*/
}
/**
* Creates list of users with given input array
* @param {*} body List of user object
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {Object} result Result object
*/
function createUsersWithArrayInput(body, callback) {
// Add your implementation here. Please make sure the callback is invoked
}
/**
* Place an order for a pet
* @param {Order} body order placed for purchasing the pet
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {Order} result Result object
*/
function placeOrder(body, callback) {
// Add your implementation here. Please make sure the callback is invoked
/*
var err0 = new Error('Invalid Order');
err0.statusCode = 400;
return cb(err0);
*/
}
/**
* Multiple status values can be provided with comma seperated strings
* @param {array} status Status values that need to be considered for filter
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {Pet} 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);
*/
}
/**
* Get user by user name
* @param {string} username The name that needs to be fetched. Use user1 for testing.
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {User} result Result object
*/
function getUserByName(username, callback) {
// Add your implementation here. Please make sure the callback is invoked
/*
var err0 = new Error('Invalid username supplied');
err0.statusCode = 400;
return cb(err0);
*/
/*
var err1 = new Error('User not found');
err1.statusCode = 404;
return cb(err1);
*/
}
/**
* This can only be done by the logged in user.
* @param {string} username name that need to be deleted * @param {User} body Updated user object
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {Object} result Result object
*/
function updateUser(username, body, callback) {
// Add your implementation here. Please make sure the callback is invoked
/*
var err0 = new Error('Invalid user supplied');
err0.statusCode = 400;
return cb(err0);
*/
/*
var err1 = new Error('User not found');
err1.statusCode = 404;
return cb(err1);
*/
}
/**
* This can only be done by the logged in user.
* @param {string} username The name that needs to be deleted
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {Object} result Result object
*/
function deleteUser(username, callback) {
// Add your implementation here. Please make sure the callback is invoked
/*
var err0 = new Error('Invalid username supplied');
err0.statusCode = 400;
return cb(err0);
*/
/*
var err1 = new Error('User not found');
err1.statusCode = 404;
return cb(err1);
*/
}
/**
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
* @param {array} tags Tags to filter by
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {Pet} 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);
*/
}
/**
* This can only be done by the logged in user.
* @param {User} body Created user object
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {Object} result Result object
*/
function createUser(body, callback) {
// Add your implementation here. Please make sure the callback is invoked
}
/**
* Logs out current logged in user session
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {Object} result Result object
*/
function logoutUser(callback) {
// Add your implementation here. Please make sure the callback is invoked
}
/**
* Logs user into the system
* @param {string} username The user name for login * @param {string} password The password for login in clear text
* @callback {Function} callback Callback function
* @param {Error|String} err Error object
* @param {Object} result Result object
*/
function loginUser(username, password, callback) {
// Add your implementation here. Please make sure the callback is invoked
/*
var err0 = new Error('Invalid username/password supplied');
err0.statusCode = 400;
return cb(err0);
*/
}
/**
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
* @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);
*/
}
Store.remoteMethod('createUsersWithListInput',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'body',
type: 'User',
description: 'List of user object',
required: false,
http: [Object] } ],
returns: [],
http: { verb: 'post', path: '/user/createWithList' } }
});
Store.remoteMethod('updatePet',
{ isStatic: true,
consumes: [ 'application/json', 'application/xml' ],
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'body',
type: 'Pet',
description: 'Pet object that needs to be added to the store',
required: false,
http: [Object] } ],
returns: [],
http: { verb: 'put', path: '/pet' } }
});
Store.remoteMethod('addPet',
{ isStatic: true,
consumes: [ 'application/json', 'application/xml' ],
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'body',
type: 'Pet',
description: 'Pet object that needs to be added to the store',
required: false,
http: [Object] } ],
returns: [],
http: { verb: 'post', path: '/pet' } }
});
Store.remoteMethod('getOrderById',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'orderId',
type: 'string',
description: 'ID of pet that needs to be fetched',
required: true,
http: [Object] } ],
returns: [ { description: 'successful operation', type: 'Order' } ],
http: { verb: 'get', path: '/store/order/:orderId' } }
});
Store.remoteMethod('deleteOrder',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'orderId',
type: 'string',
description: 'ID of the order that needs to be deleted',
required: true,
http: [Object] } ],
returns: [],
http: { verb: 'delete', path: '/store/order/:orderId' } }
});
Store.remoteMethod('createUsersWithArrayInput',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'body',
type: undefined,
description: 'List of user object',
required: false,
http: [Object] } ],
returns: [],
http: { verb: 'post', path: '/user/createWithArray' } }
});
Store.remoteMethod('placeOrder',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'body',
type: 'Order',
description: 'order placed for purchasing the pet',
required: false,
http: [Object] } ],
returns: [ { description: 'successful operation', type: 'Order' } ],
http: { verb: 'post', path: '/store/order' } }
});
Store.remoteMethod('findPetsByStatus',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'status',
type: 'array',
description: 'Status values that need to be considered for filter',
required: false,
http: [Object] } ],
returns: [ { description: 'successful operation', type: 'Pet' } ],
http: { verb: 'get', path: '/pet/findByStatus' } }
});
Store.remoteMethod('getUserByName',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'username',
type: 'string',
description: 'The name that needs to be fetched. Use user1 for testing. ',
required: true,
http: [Object] } ],
returns: [ { description: 'successful operation', type: 'User' } ],
http: { verb: 'get', path: '/user/:username' } }
});
Store.remoteMethod('updateUser',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'username',
type: 'string',
description: 'name that need to be deleted',
required: true,
http: [Object] },
{ arg: 'body',
type: 'User',
description: 'Updated user object',
required: false,
http: [Object] } ],
returns: [],
http: { verb: 'put', path: '/user/:username' } }
});
Store.remoteMethod('deleteUser',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'username',
type: 'string',
description: 'The name that needs to be deleted',
required: true,
http: [Object] } ],
returns: [],
http: { verb: 'delete', path: '/user/:username' } }
});
Store.remoteMethod('findPetsByTags',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'tags',
type: 'array',
description: 'Tags to filter by',
required: false,
http: [Object] } ],
returns: [ { description: 'successful operation', type: 'Pet' } ],
http: { verb: 'get', path: '/pet/findByTags' } }
});
Store.remoteMethod('createUser',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'body',
type: 'User',
description: 'Created user object',
required: false,
http: [Object] } ],
returns: [],
http: { verb: 'post', path: '/user' } }
});
Store.remoteMethod('logoutUser',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts: [],
returns: [],
http: { verb: 'get', path: '/user/logout' } }
});
Store.remoteMethod('loginUser',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'username',
type: 'string',
description: 'The user name for login',
required: false,
http: [Object] },
{ arg: 'password',
type: 'string',
description: 'The password for login in clear text',
required: false,
http: [Object] } ],
returns: [],
http: { verb: 'get', path: '/user/login' } }
});
Store.remoteMethod('getPetById',
{ isStatic: true,
produces: [ 'application/json', 'application/xml' ],
accepts:
[ { arg: 'petId',
type: 'number',
description: 'ID of pet that needs to be fetched',
required: true,
http: [Object] } ],
returns: [ { description: 'successful operation', type: 'Pet' } ],
http: { verb: 'get', path: '/pet/:petId' } }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment