diff --git a/types/swagger-ui-express/index.d.ts b/types/swagger-ui-express/index.d.ts index 4af7308533..f4165355fe 100644 --- a/types/swagger-ui-express/index.d.ts +++ b/types/swagger-ui-express/index.d.ts @@ -7,11 +7,11 @@ import { RequestHandler } from "express"; import { ServeStaticOptions } from "serve-static"; -declare namespace SwaggerUiExpress { - interface JsonObject { [key: string]: any; } - interface SwaggerUiOptions { [key: string]: any; } - interface SwaggerOptions { [key: string]: any; } +interface JsonObject { [key: string]: any; } +interface SwaggerUiOptions { [key: string]: any; } +interface SwaggerOptions { [key: string]: any; } +interface SwaggerUiExpress { /** * Creates a middleware function that returns the pre-generated html file for the Swagger UI page. * @@ -24,7 +24,7 @@ declare namespace SwaggerUiExpress { * @param customeSiteTitle custom title for a page * @returns an express middleware function that returns the generated html page. */ - function setup(swaggerDoc?: JsonObject | null, + setup(swaggerDoc?: JsonObject | null, opts?: SwaggerUiOptions | false | null, options?: SwaggerOptions, customCss?: string | false | null, @@ -38,7 +38,7 @@ declare namespace SwaggerUiExpress { * * @returns Express handlers that process requests and return files for Swagger UI. */ - function serve(): RequestHandler[]; + serve(): RequestHandler[]; /** * Returns handlers for serving Swagger UI files. @@ -48,7 +48,7 @@ declare namespace SwaggerUiExpress { * @param options options object that is passed to the express.static middleware. * @returns Express handlers that process requests and return files for Swagger UI. */ - function serveWithOptions(options: ServeStaticOptions): RequestHandler[]; + serveWithOptions(options: ServeStaticOptions): RequestHandler[]; /** * Generates the custom html page for the UI API. @@ -62,7 +62,7 @@ declare namespace SwaggerUiExpress { * @param customeSiteTitle custom title for a page * @returns the generated html page. */ - function generateHTML(swaggerDoc?: JsonObject | null, + generateHTML(swaggerDoc?: JsonObject | null, opts?: SwaggerUiOptions | false | null, options?: SwaggerOptions, customCss?: string | false | null, @@ -79,7 +79,9 @@ declare namespace SwaggerUiExpress { * @param opts options to pass to Swagger UI. * @returns Express handlers that process requests and return files for Swagger UI. */ - function serveFiles(swaggerDoc?: JsonObject, opts?: SwaggerUiOptions): RequestHandler[]; + serveFiles(swaggerDoc?: JsonObject, opts?: SwaggerUiOptions): RequestHandler[]; } -export default SwaggerUiExpress; +declare const swaggerUiExpress: SwaggerUiExpress; + +export = swaggerUiExpress; diff --git a/types/swagger-ui-express/swagger-ui-express-tests.ts b/types/swagger-ui-express/swagger-ui-express-tests.ts index 7338bd1f7b..f91128205c 100644 --- a/types/swagger-ui-express/swagger-ui-express-tests.ts +++ b/types/swagger-ui-express/swagger-ui-express-tests.ts @@ -2,21 +2,25 @@ * Tests are taken from the module's repository at https://github.com/scottie1984/swagger-ui-express/blob/master/test/testapp/app.js */ -import swaggerUi from "swagger-ui-express"; +import swaggerUi = require('swagger-ui-express'); +import express = require('express'); -const express = require('express'); const app = express(); -const swaggerDocument = require('./swagger.json'); -const swaggerDocumentSplit = require('./swagger-split.json'); +const swaggerDocument = { + swagger: '2.0', + info: { version: '1.0.0', title: 'Example API' }, + paths: { '/user': { get: { responses: { 200: { description: 'all users' } } } } } +}; +const swaggerDocumentSplit = swaggerDocument; const options = { validatorUrl: null, oauth: { - clientId: "your-client-id1", - clientSecret: "your-client-secret-if-required1", - realm: "your-realms1", - appName: "your-app-name1", - scopeSeparator: ",", + clientId: 'your-client-id1', + clientSecret: 'your-client-secret-if-required1', + realm: 'your-realms1', + appName: 'your-app-name1', + scopeSeparator: ',', additionalQueryStringParams: {} }, docExpansion: 'full', diff --git a/types/swagger-ui-express/tslint.json b/types/swagger-ui-express/tslint.json index 1e30988418..f93cf8562a 100644 --- a/types/swagger-ui-express/tslint.json +++ b/types/swagger-ui-express/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "no-var-requires": false - } + "extends": "dtslint/dt.json" }