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.
This commit is contained in:
Bart Kummel
2017-03-03 11:38:19 +01:00
committed by wing328
parent 9516c81ebb
commit 30c2b6f262
5 changed files with 157 additions and 91 deletions

View File

@@ -20,7 +20,7 @@ exports.getInventory = function(args, res, next) {
**/
var examples = {};
examples['application/json'] = {
"key" : 123
"key" : 0
};
if (Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
@@ -40,12 +40,12 @@ exports.getOrderById = function(args, res, next) {
**/
var examples = {};
examples['application/json'] = {
"id" : 123456789,
"petId" : 123456789,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+00:00"
"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');
@@ -65,12 +65,12 @@ exports.placeOrder = function(args, res, next) {
**/
var examples = {};
examples['application/json'] = {
"id" : 123456789,
"petId" : 123456789,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+00:00"
"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');