Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to disable Swagger UI #2840

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
docs: add docs on SwaggerCustomOptions
lucas-gregoire committed Feb 15, 2024

Verified

This commit was signed with the committer’s verified signature.
michael-valdron Michael Valdron
commit d56087c50982c375146aa8ad50d3acf37cd878db
101 changes: 89 additions & 12 deletions lib/interfaces/swagger-custom-options.interface.ts
Original file line number Diff line number Diff line change
@@ -2,29 +2,106 @@ import { SwaggerUiOptions } from './swagger-ui-options.interface';
import { OpenAPIObject } from './open-api-spec.interface';

export interface SwaggerCustomOptions {
/**
* If `true`, Swagger resources paths will be prefixed by the global prefix set through `setGlobalPrefix()`.
* Default: `false`.
* @see https://docs.nestjs.com/faq/global-prefix
*/
useGlobalPrefix?: boolean;

/**
* If `false`, only API definitions (JSON and YAML) will be served (on `/{path}-json` and `/{path}-yaml`).
* This is particularly useful if you are already hosting a Swagger UI somewhere else and just want to serve API definitions.
* Default: `true`.
*/
swaggerUiEnabled?: boolean;

/**
* Url point the API definition to load in Swagger UI.
*/
swaggerUrl?: string;

/**
* Path of the JSON API definition to serve.
* Default: `{{path}}-json`.
*/
jsonDocumentUrl?: string;

/**
* Path of the YAML API definition to serve.
* Default: `{{path}}-json`.
*/
yamlDocumentUrl?: string;

/**
* Hook allowing to alter the OpenAPI document before being served.
* It's called after the document is generated and before it is served as JSON & YAML.
*/
patchDocumentOnRequest?: <TRequest = any, TResponse = any>(
req: TRequest,
res: TResponse,
document: OpenAPIObject
) => OpenAPIObject;

/**
* If `true`, the selector of OpenAPI definitions is displayed in the Swagger UI interface.
* Default: `false`.
*/
explorer?: boolean;

/**
* Additional Swagger UI options
*/
swaggerOptions?: SwaggerUiOptions;

/**
* Custom CSS styles to inject in Swagger UI page.
*/
customCss?: string;

/**
* URL(s) of a custom CSS stylesheet to load in Swagger UI page.
*/
customCssUrl?: string | string[];

/**
* URL(s) of custom JavaScript files to load in Swagger UI page.
*/
customJs?: string | string[];

/**
* Custom JavaScript scripts to load in Swagger UI page.
*/
customJsStr?: string | string[];

/**
* Custom favicon for Swagger UI page.
*/
customfavIcon?: string;
customSwaggerUiPath?: string;
swaggerUrl?: string;

/**
* Custom title for Swagger UI page.
*/
customSiteTitle?: string;
/** @deprecated This property has no effect. */

/**
* File system path (ex: ./node_modules/swagger-ui-dist) containing static Swagger UI assets.
*/
customSwaggerUiPath?: string;

/**
* @deprecated This property has no effect.
*/
validatorUrl?: string;
/** @deprecated This property has no effect. */

/**
* @deprecated This property has no effect.
*/
url?: string;
/** @deprecated This property has no effect. */

/**
* @deprecated This property has no effect.
*/
urls?: Record<'url' | 'name', string>[];
jsonDocumentUrl?: string;
yamlDocumentUrl?: string;
patchDocumentOnRequest?: <TRequest = any, TResponse = any>(
req: TRequest,
res: TResponse,
document: OpenAPIObject
) => OpenAPIObject;

}