@origins-digital/nestjs-swagger 2.1.4 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -38,11 +38,16 @@ export class AppModule {
|
|
|
38
38
|
```typescript
|
|
39
39
|
import { Module } from '@nestjs/common';
|
|
40
40
|
import { initSwagger } from '@origins-digital/nestjs-swagger';
|
|
41
|
+
import { SwaggerDocumentOptions } from '@nestjs/swagger';
|
|
41
42
|
import { UsersModule } from './users/users.module';
|
|
42
43
|
|
|
43
44
|
@Module({})
|
|
44
45
|
export class AppModule {
|
|
45
46
|
constructor(private readonly app: INestApplication) {
|
|
47
|
+
const options: SwaggerDocumentOptions = {
|
|
48
|
+
include: [UsersModule],
|
|
49
|
+
};
|
|
50
|
+
|
|
46
51
|
initSwagger(
|
|
47
52
|
app,
|
|
48
53
|
'My API',
|
|
@@ -58,7 +63,7 @@ export class AppModule {
|
|
|
58
63
|
},
|
|
59
64
|
},
|
|
60
65
|
'api-docs',
|
|
61
|
-
|
|
66
|
+
options,
|
|
62
67
|
);
|
|
63
68
|
}
|
|
64
69
|
}
|
|
@@ -99,7 +104,7 @@ The `initSwagger` function accepts the following parameters:
|
|
|
99
104
|
- `version`: The API version
|
|
100
105
|
- `schemas`: Optional additional OpenAPI schemas to include
|
|
101
106
|
- `uri`: Optional custom Swagger UI path (defaults to 'docs')
|
|
102
|
-
- `
|
|
107
|
+
- `options`: Optional `SwaggerDocumentOptions` passed to `SwaggerModule.createDocument`
|
|
103
108
|
|
|
104
109
|
## API Documentation
|
|
105
110
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { INestApplication } from '@nestjs/common';
|
|
2
|
+
import { SwaggerDocumentOptions } from '@nestjs/swagger';
|
|
2
3
|
import { ReferenceObject, SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
|
|
3
|
-
export declare const initSwagger: <T = any>(app: INestApplication<T>, packageName: string, version: string, schemas?: Record<string, SchemaObject | ReferenceObject>, uri?: string,
|
|
4
|
+
export declare const initSwagger: <T = any>(app: INestApplication<T>, packageName: string, version: string, schemas?: Record<string, SchemaObject | ReferenceObject>, uri?: string, options?: SwaggerDocumentOptions) => void;
|
|
4
5
|
//# sourceMappingURL=swagger-setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swagger-setup.d.ts","sourceRoot":"","sources":["../../src/openapi/swagger-setup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"swagger-setup.d.ts","sourceRoot":"","sources":["../../src/openapi/swagger-setup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAEL,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,YAAY,EACb,MAAM,yDAAyD,CAAC;AAGjE,eAAO,MAAM,WAAW,GAAI,CAAC,GAAG,GAAG,EACjC,KAAK,gBAAgB,CAAC,CAAC,CAAC,EACxB,aAAa,MAAM,EACnB,SAAS,MAAM,EACf,UAAU,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAAC,EACxD,MAAM,MAAM,EACZ,UAAU,sBAAsB,SA8BjC,CAAC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.initSwagger = void 0;
|
|
4
4
|
const swagger_1 = require("@nestjs/swagger");
|
|
5
5
|
const patch_1 = require("./patch");
|
|
6
|
-
const initSwagger = (app, packageName, version, schemas, uri,
|
|
6
|
+
const initSwagger = (app, packageName, version, schemas, uri, options) => {
|
|
7
7
|
const serviceConfig = new swagger_1.DocumentBuilder()
|
|
8
8
|
.setTitle(packageName)
|
|
9
9
|
.addBearerAuth()
|
|
@@ -11,9 +11,7 @@ const initSwagger = (app, packageName, version, schemas, uri, modules) => {
|
|
|
11
11
|
.setVersion(version)
|
|
12
12
|
.build();
|
|
13
13
|
(0, patch_1.patchNestJsSwagger)();
|
|
14
|
-
const serviceDocument = swagger_1.SwaggerModule.createDocument(app, serviceConfig,
|
|
15
|
-
include: modules || undefined,
|
|
16
|
-
});
|
|
14
|
+
const serviceDocument = swagger_1.SwaggerModule.createDocument(app, serviceConfig, options);
|
|
17
15
|
if (!serviceDocument.components) {
|
|
18
16
|
serviceDocument.components = { schemas: {} };
|
|
19
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swagger-setup.js","sourceRoot":"","sources":["../../src/openapi/swagger-setup.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"swagger-setup.js","sourceRoot":"","sources":["../../src/openapi/swagger-setup.ts"],"names":[],"mappings":";;;AAEA,6CAIyB;AAKzB,mCAA6C;AAEtC,MAAM,WAAW,GAAG,CACzB,GAAwB,EACxB,WAAmB,EACnB,OAAe,EACf,OAAwD,EACxD,GAAY,EACZ,OAAgC,EAChC,EAAE;IACF,MAAM,aAAa,GAAG,IAAI,yBAAe,EAAE;SACxC,QAAQ,CAAC,WAAW,CAAC;SACrB,aAAa,EAAE;SACf,cAAc,CACb,eAAe,WAAW,uFAAuF,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,EAAE,2BAA2B,CACtJ;SACA,UAAU,CAAC,OAAO,CAAC;SACnB,KAAK,EAAE,CAAC;IAEX,IAAA,0BAAkB,GAAE,CAAC;IACrB,MAAM,eAAe,GAAG,uBAAa,CAAC,cAAc,CAClD,GAAG,EACH,aAAa,EACb,OAAO,CACR,CAAC;IAEF,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;QAChC,eAAe,CAAC,UAAU,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/C,CAAC;IAED,eAAe,CAAC,UAAU,CAAC,OAAO,mCAC7B,eAAe,CAAC,UAAU,CAAC,OAAO,GAClC,OAAO,CACX,CAAC;IAEF,uBAAa,CAAC,KAAK,CAAC,GAAG,IAAI,MAAM,EAAE,GAAG,EAAE,eAAe,EAAE;QACvD,eAAe,EAAE,WAAW;KAC7B,CAAC,CAAC;AACL,CAAC,CAAC;AApCW,QAAA,WAAW,eAoCtB"}
|