-
Notifications
You must be signed in to change notification settings - Fork 474
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
Changes from all commits
c373d51
de2d695
8b2c6a3
25942eb
d56087c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,107 @@ | ||
import { SwaggerUiOptions } from './swagger-ui-options.interface'; | ||
import { SwaggerDocumentOptions } from './swagger-document-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; | ||
Comment on lines
+12
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 for aligning the code with what's actually documented at https://docs.nestjs.com/openapi/introduction#setup-options There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it in the docs but not in the code? Made me scratch my head for half an hour.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreeing to @motabass, the docs are live already, can this be merged please? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, would be nice if this would be merged, it's quite confusing that it's in the docs but you can't actually use it 😬 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i agree merge it, the docs are live already, i want use selfdefine openapi-ui There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry that both PRs haven't been merged simultaneously (or at least the code before the docs). The PR for the docs was merged in 1 day, while this one has been waiting (and ready) for 4 months 😿 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For those who want to try this feature before its release, I've published a forked package Change this in your - "@nestjs/swagger": "7.4.0",
+ "@nestjs/swagger": "npm:@lsge/[email protected]", |
||
|
||
/** | ||
* 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; | ||
|
||
/** | ||
* 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. | ||
*/ | ||
url?: string; | ||
|
||
/** | ||
* @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; | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All Swagger UI resources are throwing 404 when disabled