Bart Kummel 30c2b6f262 Improved ExampleGenerator (#4797)
* Improved ExampleGenerator:

- Now takes into account enum and uri/url formats for strings.
- Uses example for referenced objects if available.
- Proper examples get generated for specific numeric formats, because more specific formats now get checked before generic format.
- Honors min and max values for numerical properties, if set.

* Ran script `bin/nodejs-petstore-server.sh`.

* Renamed log to logger to conform to coding standard.
2017-03-03 18:38:19 +08:00

83 lines
2.0 KiB
JavaScript

'use strict';
exports.deleteOrder = function(args, res, next) {
/**
* Delete purchase order by ID
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
*
* orderId String ID of the order that needs to be deleted
* no response value expected for this operation
**/
res.end();
}
exports.getInventory = function(args, res, next) {
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
*
* returns Map
**/
var examples = {};
examples['application/json'] = {
"key" : 0
};
if (Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
} else {
res.end();
}
}
exports.getOrderById = function(args, res, next) {
/**
* Find purchase order by ID
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
*
* orderId Long ID of pet that needs to be fetched
* returns Order
**/
var examples = {};
examples['application/json'] = {
"petId" : 2,
"quantity" : 9,
"id" : 5,
"shipDate" : "2000-01-23T04:56:07.000+00:00",
"complete" : false,
"status" : "placed"
};
if (Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
} else {
res.end();
}
}
exports.placeOrder = function(args, res, next) {
/**
* Place an order for a pet
*
*
* body Order order placed for purchasing the pet
* returns Order
**/
var examples = {};
examples['application/json'] = {
"petId" : 5,
"quantity" : 5,
"id" : 1,
"shipDate" : "2000-01-23T04:56:07.000+00:00",
"complete" : false,
"status" : "placed"
};
if (Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
} else {
res.end();
}
}