Merge pull request #9 from smart-facility/swagger

Swagger
pull/1/head
Piero Toffanin 2016-09-14 16:39:25 -04:00 zatwierdzone przez GitHub
commit f05375418a
4 zmienionych plików z 65 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,22 @@
var swaggerJSDoc = require('swagger-jsdoc');
var jsonfile = require('jsonfile');
var options = {
swaggerDefinition: {
info: {
title: 'Node-OpenDroneMap', // Title (required)
version: '0.1.0', // Version (required)
},
},
apis: ['./index.js'], // Path to the API docs
};
// Initialize swagger-jsdoc -> returns validated swagger spec in json format
var swaggerSpec = swaggerJSDoc(options);
var file = 'swagger-api.json';
jsonfile.writeFile(file, swaggerSpec, function (err) {
console.error(err);
process.exit(1);
});

Wyświetl plik

@ -165,6 +165,18 @@ let successHandler = res => {
};
};
/**
* @swagger
* /task/cancel/{uuidCheck}:
* get:
* description: Cancels a task
* parameters:
* - uuidCheck: uuid of the task to cancel
* responses:
* 200:
* description: Task cancelled
*/
app.post('/task/cancel', uuidCheck, (req, res) => {
taskManager.cancel(req.body.uuid, successHandler(res));
});

Wyświetl plik

@ -24,12 +24,14 @@
"async": "^2.0.0-rc.6",
"body-parser": "^1.15.2",
"express": "^4.14.0",
"jsonfile": "^2.3.1",
"minimist": "^1.2.0",
"morgan": "^1.7.0",
"multer": "^1.1.0",
"node-schedule": "^1.1.1",
"node-uuid": "^1.4.7",
"rimraf": "^2.5.3",
"swagger-jsdoc": "^1.3.1",
"winston": "^2.2.0"
},
"devDependencies": {

29
swagger-api.json 100644
Wyświetl plik

@ -0,0 +1,29 @@
{
"info": {
"title": "Node-OpenDroneMap",
"version": "0.1.0"
},
"swagger": "2.0",
"paths": {
"/task/cancel/{uuidCheck}": {
"get": {
"description": "Cancels a task",
"parameters": [
{
"uuidCheck": "uuid of the task to cancel"
}
],
"responses": {
"200": {
"description": "Task cancelled"
}
}
}
}
},
"definitions": {},
"responses": {},
"parameters": {},
"securityDefinitions": {},
"tags": []
}