[ad_1]
There is the Swagger Editor (https://editor.swagger.io/) and Swagger Hub (https://swaggerhub.com/). I thought both are doing the same job, untill I noticed, that the source codes are different.
Im my case, I generated a nodejs server in both and looked at the sourcecode.
Swagger editor delivers:
exports.getJobs = function(args, res, next)
/**
* Returns all jobs
*
* page String page (optional)
* returns List
**/
var examples = ;
examples['application/json'] = [
// my json
];
if (Object.keys(examples).length > 0) , null, 2));
else
res.end();
whereas Swagger Hub delivers:
/**
* Returns all jobs
*
* page String page (optional)
* returns List
**/
exports.getJobs = function(page)
return new Promise(function(resolve, reject)
var examples = ;
examples['application/json'] = [
// my json
];
if (Object.keys(examples).length > 0)
resolve(examples[Object.keys(examples)[0]]);
else
resolve();
);
Why are the function parameters different? In Swagger Online editor it's
exports.getJobs = function(args, res, next)
and in Swagger Hub Editor it's
exports.getJobs = function(page)
but why? Which is the right one to use? How can I use the parameter res (eg to set the header) in swagger hub if it's not passed?
[ad_2]
لینک منبع