import { Request, Response, NextFunction, SwaggerOpenAPIConfig, SwaggerOpenAPIDocument, SwaggerRouteBuilder, VkrunSwaggerUi } from "../types"; export declare class SwaggerUiSetup implements VkrunSwaggerUi { private readonly doc; private currentPath; private swaggerUiPath; private baseUrl; constructor(config?: SwaggerOpenAPIConfig | (SwaggerOpenAPIConfig & SwaggerOpenAPIDocument)); route(path: string): SwaggerRouteBuilder; private addMethod; private getConfig; private generateSwaggerHTML; private serveSwaggerJSON; private filterSwaggerDoc; private serveStaticFiles; private setupSwaggerHTML; serve(absolutePath: string): (req: Request, res: Response, next: NextFunction) => void; } /** * @function swaggerUi * * Configures the Swagger UI for the application, enabling the visualization and interaction with the API documentation. * This function provides two primary use cases: * 1. Define API routes using the integrated route builder. * 2. Directly serve an existing Swagger JSON configuration. * * **Swagger UI Configuration Options:** * - **openapi**: The version of the OpenAPI specification (default is `'3.0.0'`). * - **info**: Provides metadata about the API, such as `title`, `version`, and `description`. * - **paths**: Defines the endpoints available in the API, including HTTP methods, parameters, and responses. * - **components**: Contains reusable components, such as `securitySchemes`, `schemas`, and `parameters`. * - **servers**: Lists the available servers for the API (e.g., development, staging, or production). * - **security**: Specifies security requirements for the API, such as Bearer tokens or API keys. * * **Usage Options:** * - If a configuration object is passed, you can dynamically define API routes using the `route` method. * - Alternatively, you can pass an absolute path to Swagger UI's distribution files (e.g., via `swagger-ui-dist` package) * and an existing Swagger JSON object to serve pre-defined documentation. * * @param {SwaggerOpenAPIConfig} [config] - The configuration object for Swagger UI. If not provided, a default configuration is used. * @returns {VkrunSwaggerUi} - An instance of `VkrunSwaggerUi`, which allows you to define routes or serve an existing Swagger JSON configuration. * * @example * // Example 1: Using integrated route builder * import { swaggerUi } from "vkrun" * import swaggerUiDist from "swagger-ui-dist" * * const swagger = swaggerUi({ * openapi: "3.0.0", * info: { * title: "API Documentation", * version: "1.0.0", * description: "API with public and private routes." * }, * servers: [{ url: "http://localhost:3000", description: "Development Server" }], * components: { * securitySchemes: { * BearerAuth: { * type: "http", * scheme: "bearer", * bearerFormat: "JWT" * } * } * } * }) * * swagger.route("/public").get({ * summary: "Public Route", * description: "This route is public and requires no authentication.", * responses: { * 200: { description: "Success", content: { "application/json": { schema: { type: "object", properties: { message: { type: "string", example: "This is a public route." } } } } } } * } * }) * * app.get("/api-docs/*", swagger.serve(swaggerUiDist.absolutePath())); * * // Example 2: Serving a pre-defined Swagger JSON object * import { swaggerUi } from "vkrun" * import swaggerJSON from "./swagger.json" * * app.get("/api-docs/*", swaggerUi(swaggerJSON).serve(swaggerUiDist.absolutePath())); */ export declare const swaggerUi: (config?: SwaggerOpenAPIConfig) => VkrunSwaggerUi;