diff --git a/types/swagger-ui-dist/absolute-path.d.ts b/types/swagger-ui-dist/absolute-path.d.ts new file mode 100644 index 0000000000..e8bc18a717 --- /dev/null +++ b/types/swagger-ui-dist/absolute-path.d.ts @@ -0,0 +1,8 @@ +/* + * getAbsoluteFSPath + * @return When run in NodeJS env, returns the absolute path to the current directory + * When run outside of NodeJS, will return an error message + */ +declare function getAbsoluteFSPath(): string; + +export = getAbsoluteFSPath; diff --git a/types/swagger-ui-dist/index.d.ts b/types/swagger-ui-dist/index.d.ts index 273cce0ea8..2bcf4bbd7d 100644 --- a/types/swagger-ui-dist/index.d.ts +++ b/types/swagger-ui-dist/index.d.ts @@ -1,26 +1,28 @@ -// Type definitions for swagger-ui-dist 3.x +// Type definitions for swagger-ui-dist 3.30 // Project: https://github.com/swagger-api/swagger-ui#readme // Definitions by: Haowen // Bryce +// Piotr Błażejewicz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +import implementation = require('./absolute-path'); -export {}; export as namespace SwaggerUIDist; /** * get an absolute path to swagger ui for static file serving */ -export function getAbsoluteFSPath(): string; -export function absolutePath(): string; +export const getAbsoluteFSPath: typeof implementation; +export const absolutePath: typeof implementation; +export const SwaggerUIStandalonePreset: any; +export const SwaggerUIBundle: SwaggerUIBundle; export interface Url { - url: string; - name: string; + url: string; + name: string; } export interface Spec { - [k: string]: any; + [k: string]: any; } export interface SwaggerConfigs { @@ -97,35 +99,31 @@ export interface SwaggerConfigs { * Function to intercept remote definition, "Try it out", and OAuth 2.0 requests. * Accepts one argument requestInterceptor(request) and must return the modified request, or a Promise that resolves to the modified request. */ - requestInterceptor?: ((request: SwaggerRequest) => SwaggerRequest); + requestInterceptor?: (request: SwaggerRequest) => SwaggerRequest; /** * Function to intercept remote definition, "Try it out", and OAuth 2.0 responses. * Accepts one argument responseInterceptor(response) and must return the modified response, or a Promise that resolves to the modified response. */ - responseInterceptor?: ((response: SwaggerResponse) => SwaggerResponse); + responseInterceptor?: (response: SwaggerResponse) => SwaggerResponse; [k: string]: any; } export interface SwaggerUIBundle { - (a?: SwaggerConfigs): any; + (a?: SwaggerConfigs): any; - [k: string]: any; + [k: string]: any; - getConfigs(): SwaggerConfigs; + getConfigs(): SwaggerConfigs; } -export const SwaggerUIBundle: SwaggerUIBundle; - export interface SwaggerRequest { - url: string; - credentials: string; - [k: string]: any; + url: string; + credentials: string; + [k: string]: any; } export interface SwaggerResponse { - [k: string]: any; + [k: string]: any; } - -export const SwaggerUIStandalonePreset: any; diff --git a/types/swagger-ui-dist/swagger-ui-dist-tests.ts b/types/swagger-ui-dist/swagger-ui-dist-tests.ts index 1cf6051207..b7b1e17870 100644 --- a/types/swagger-ui-dist/swagger-ui-dist-tests.ts +++ b/types/swagger-ui-dist/swagger-ui-dist-tests.ts @@ -1,6 +1,25 @@ -import * as SwaggerUIDist from "swagger-ui-dist"; +import SwaggerUIDist = require('swagger-ui-dist'); +import express = require('express'); +import { getAbsoluteFSPath, absolutePath as absolutePathAlias, SwaggerUIBundle } from 'swagger-ui-dist'; +import absolutePath = require('swagger-ui-dist/absolute-path'); SwaggerUIDist.getAbsoluteFSPath(); // $ExpectType string SwaggerUIDist.absolutePath(); // $ExpectType string - +getAbsoluteFSPath(); // $ExpectType string +absolutePathAlias(); // $ExpectType string +absolutePath(); // $ExpectType string SwaggerUIDist.SwaggerUIBundle(); +SwaggerUIDist.SwaggerUIBundle.getConfigs(); + +// api tests + +const app = express(); +app.use(express.static(absolutePath())); +app.listen(3000); + +const ui = SwaggerUIBundle({ + url: 'https://petstore.swagger.io/v2/swagger.json', + dom_id: '#swagger-ui', + presets: [SwaggerUIBundle.presets.apis, SwaggerUIBundle.SwaggerUIStandalonePreset], + layout: 'StandaloneLayout', +});