I have generated my api-docs like this:
{
"apiVersion": "0.1",
"swaggerVersion": "1.2",
"basePath": "/",
"resourcePath": "/binnacle",
"produces": [
"text/plain; charset=UTF-8"
],
"apis": [
{
"path": "/binnacle/justArrived",
"operations": [
{
"method": "POST",
"summary": "Logs when a user just logged in",
"notes": "",
"type": "string",
"nickname": "justArrived",
"produces": [
"text/plain"
],
"consumes": [
"application/json",
"application/vnd.custom.inputParams+json"
],
"parameters": [
{
"name": "body",
"description": "userId is required",
"required": true,
"type": "SimpleInputParams",
"paramType": "body",
"allowMultiple": false
}
],
"responseMessages": [
{
"code": 200,
"message": "Thanks for using this API!"
},
{
"code": 400,
"message": "A message describing the missing arguments"
}
]
}
]
}
],
"models": {
"SimpleInputParams": {
"id": "SimpleInputParams",
"description": "Input Parameters with just User",
"required": [
"userId"
],
"properties": {
"userId": {
"type": "string",
"description": "User Identifier"
},
"source": {
"$ref": "EventSource",
"description": "Event Source"
}
}
}
}
}
This is working properly with the Scala Module. However the code generator for node is currently not generating the parameters inside SimpleInputParams correctly, leaving the body of the endpoint like this:
exports.justArrived = function(body) {
var examples = {};
if(Object.keys(examples).length > 0)
return examples[Object.keys(examples)[0]];
}
On the service, and
module.exports.justArrived = function justArrived (req, res, next) {
var body = req.swagger.params['body'].value;
var result = Binnacle.justArrived(body);
if(typeof result !== 'undefined') {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(result || {}, null, 2));
}
else
res.end();
};
How can I make the codegen to read what is inside of "models" on the first JSON of the Swagger spec and let it generate the correct JS with the types inside?
Cheers,