mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 13:00:19 +00:00
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:
committed by
Masahiro Wakame
parent
b6e9f64018
commit
d3c2f19e0b
@@ -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
|
||||
Vendored
+41
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user