Add definition for swagger-jsdoc (#11298)

* Add definition for swagger-jsdoc

* Update files

* Remove interface and use any instead for options, fix tests

* Fix Usage example
This commit is contained in:
Daniel Grove
2016-09-30 21:36:42 +09:00
committed by Masahiro Wakame
parent b6e9f64018
commit d3c2f19e0b
3 changed files with 66 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
/// <reference path="../express/express.d.ts" />
/// <reference path="./swagger-jsdoc.d.ts" />
import * as express from 'express';
import swaggerJSDoc = require('swagger-jsdoc');
const app = express();
let options = {
swaggerDefinition: {
info: {
title: 'A test api',
version: '1.0.0'
}
}
};
let swaggerSpec = swaggerJSDoc(options);
app.get('/api-docs.json', function(req, res) {
res.send(swaggerSpec);
})
app.listen(8888);
@@ -0,0 +1 @@
-m commonjs
+41
View File
@@ -0,0 +1,41 @@
// Type definitions for Swagger-JSDoc
// Project: https://github.com/surnet/swagger-jsdoc
// Definitions by: Daniel Grove <https://github.com/drGrove>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* =================== USAGE ===================
import * as express from "express"
import swaggerJSDoc = require('swagger-jsdoc');
const app = express()
let options = {
swaggerDefinition: {
info: {
title: 'Hello World',
version: '1.0.0',
description: 'A sample API'
},
host: 'localhost:3000',
basePath: '/'
},
apis: [
'./example/routes*.js',
'./example/parameters.yaml'
]
}
};
var spec = swaggerJSDoc(options);
app.get('/api-docs.json', function(req, res) {
res.setHeader('Content-Type', 'application/json');
res.send(spec);
});
=============================================== */
declare module "swagger-jsdoc" {
function swaggerJSDoc(options?: any): any;
export = swaggerJSDoc;
}