kopia lustrzana https://github.com/OpenDroneMap/NodeODM
Start on use of swagger for documenting API
rodzic
6e3624d5f8
commit
02c50e28f0
|
@ -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);
|
||||
});
|
12
index.js
12
index.js
|
@ -160,6 +160,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));
|
||||
});
|
||||
|
|
|
@ -24,11 +24,13 @@
|
|||
"async": "^2.0.0-rc.6",
|
||||
"body-parser": "^1.15.2",
|
||||
"express": "^4.14.0",
|
||||
"jsonfile": "^2.3.1",
|
||||
"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": {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{"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":[]}
|
Ładowanie…
Reference in New Issue