forked from loafle/openapi-generator-original
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:
@@ -33,18 +33,18 @@ exports.findPetsByStatus = function(args, res, next) {
|
||||
**/
|
||||
var examples = {};
|
||||
examples['application/json'] = [ {
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
"id" : 1,
|
||||
"category" : {
|
||||
"name" : "aeiou",
|
||||
"id" : 7
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 2
|
||||
} ],
|
||||
"status" : "available"
|
||||
} ];
|
||||
if (Object.keys(examples).length > 0) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
@@ -64,18 +64,18 @@ exports.findPetsByTags = function(args, res, next) {
|
||||
**/
|
||||
var examples = {};
|
||||
examples['application/json'] = [ {
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
"id" : 9,
|
||||
"category" : {
|
||||
"name" : "aeiou",
|
||||
"id" : 7
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 4
|
||||
} ],
|
||||
"status" : "available"
|
||||
} ];
|
||||
if (Object.keys(examples).length > 0) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
@@ -95,18 +95,18 @@ exports.getPetById = function(args, res, next) {
|
||||
**/
|
||||
var examples = {};
|
||||
examples['application/json'] = {
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
"id" : 4,
|
||||
"category" : {
|
||||
"name" : "aeiou",
|
||||
"id" : 4
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 4
|
||||
} ],
|
||||
"status" : "available"
|
||||
};
|
||||
if (Object.keys(examples).length > 0) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
@@ -152,9 +152,9 @@ exports.uploadFile = function(args, res, next) {
|
||||
**/
|
||||
var examples = {};
|
||||
examples['application/json'] = {
|
||||
"message" : "aeiou",
|
||||
"code" : 123,
|
||||
"type" : "aeiou"
|
||||
"code" : 7,
|
||||
"type" : "aeiou",
|
||||
"message" : "aeiou"
|
||||
};
|
||||
if (Object.keys(examples).length > 0) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
|
||||
Reference in New Issue
Block a user