Skip to content

Commit 892ea06

Browse files
authored
docs(swagger): add ui/raws description, hint
1 parent d51e129 commit 892ea06

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

content/openapi/introduction.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,30 @@ export interface SwaggerCustomOptions {
174174
useGlobalPrefix?: boolean;
175175
176176
/**
177-
* If `false`, only API definitions (JSON and YAML) will be served (on `/{path}-json` and `/{path}-yaml`).
178-
* This is particularly useful if you are already hosting a Swagger UI somewhere else and just want to serve API definitions.
177+
* If `false`, the Swagger UI will not be served. Only API definitions (JSON and YAML)
178+
* will be accessible (on `/{path}-json` and `/{path}-yaml`). To fully disable both the Swagger UI and API definitions, use `raw: false`.
179179
* Default: `true`.
180+
* @deprecated Use `ui` instead.
180181
*/
181182
swaggerUiEnabled?: boolean;
182183
184+
/**
185+
* If `false`, the Swagger UI will not be served. Only API definitions (JSON and YAML)
186+
* will be accessible (on `/{path}-json` and `/{path}-yaml`). To fully disable both the Swagger UI and API definitions, use `raw: false`.
187+
* Default: `true`.
188+
*/
189+
ui?: boolean;
190+
191+
/**
192+
* If `true`, raw definitions for all formats will be served.
193+
* Alternatively, you can pass an array to specify the formats to be served, e.g., `raw: ['json']` to serve only JSON definitions.
194+
* If omitted or set to an empty array, no definitions (JSON or YAML) will be served.
195+
* Use this option to control the availability of Swagger-related endpoints.
196+
* Default: `true`.
197+
*/
198+
raw?: boolean | Array<'json' | 'yaml'>;
199+
200+
183201
/**
184202
* Url point the API definition to load in Swagger UI.
185203
*/
@@ -270,6 +288,20 @@ export interface SwaggerCustomOptions {
270288
271289
}
272290
```
291+
> info **Hint** `ui` and `raw` are independent options. Disabling Swagger UI (`ui: false`) does not disable API definitions (JSON/YAML).
292+
> Conversely, disabling API definitions (`raw: []`) does not disable the Swagger UI.
293+
>
294+
> For example, the following configuration will disable the Swagger UI but still allow access to API definitions:
295+
> ```typescript
296+
>const options: SwaggerCustomOptions = {
297+
> ui: false, // Swagger UI is disabled
298+
> raw: ['json'], // JSON API definition is still accessible (YAML is disabled)
299+
>};
300+
>SwaggerModule.setup('api', app, options);
301+
> ```
302+
>
303+
> In this case, http://localhost:3000/api-json will still be accessible, but http://localhost:3000/api (Swagger UI) will not.
304+
273305
274306
#### Example
275307

0 commit comments

Comments
 (0)