Skip to content

Commit

Permalink
refactor(@nestjs/swagger): rename the option to patchDocumentOnRequest
Browse files Browse the repository at this point in the history
Rename the option as pointed out here.
#2505 (comment)
  • Loading branch information
botflux committed Jun 30, 2023
1 parent ab23696 commit 83c3e8d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions e2e/express.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('Express Swagger', () => {
SwaggerModule.setup('api', app, swaggerDocument, {
jsonDocumentUrl: JSON_CUSTOM_URL,
yamlDocumentUrl: YAML_CUSTOM_URL,
patchDocument: (req, res, document) => ({
patchDocumentOnRequest: (req, res, document) => ({
...document,
info: {
...document.info,
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('Express Swagger', () => {
customfavIcon: CUSTOM_FAVICON,
customSiteTitle: CUSTOM_SITE_TITLE,
customCssUrl: CUSTOM_CSS_URL,
patchDocument<ExpressRequest, ExpressResponse> (req, res, document) {
patchDocumentOnRequest<ExpressRequest, ExpressResponse> (req, res, document) {
return {
...document,
info: {
Expand Down Expand Up @@ -301,7 +301,7 @@ describe('Express Swagger', () => {
);

SwaggerModule.setup('/:customer/', app, swaggerDocument, {
patchDocument<ExpressRequest, ExpressResponse> (req, res, document) {
patchDocumentOnRequest<ExpressRequest, ExpressResponse> (req, res, document) {
return {
...document,
info: {
Expand Down
6 changes: 3 additions & 3 deletions e2e/fastify.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('Fastify Swagger', () => {
SwaggerModule.setup('api', app, swaggerDocument, {
jsonDocumentUrl: JSON_CUSTOM_URL,
yamlDocumentUrl: YAML_CUSTOM_URL,
patchDocument: (req, res, document) => ({
patchDocumentOnRequest: (req, res, document) => ({
...document,
info: {
...document.info,
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('Fastify Swagger', () => {
customfavIcon: CUSTOM_FAVICON,
customSiteTitle: CUSTOM_SITE_TITLE,
customCssUrl: CUSTOM_CSS_URL,
patchDocument: (req, res, document) => ({
patchDocumentOnRequest: (req, res, document) => ({
...document,
info: {
...document.info,
Expand Down Expand Up @@ -318,7 +318,7 @@ describe('Fastify Swagger', () => {
);

SwaggerModule.setup('/:tenantId/', app, swaggerDocument, {
patchDocument<ExpressRequest, ExpressResponse> (req, res, document) {
patchDocumentOnRequest<ExpressRequest, ExpressResponse> (req, res, document) {
return {
...document,
info: {
Expand Down
2 changes: 1 addition & 1 deletion e2e/manual-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async function bootstrap() {
});

SwaggerModule.setup("/:tenantId/api-docs", app, document, {
patchDocument: (req, res, document1) => ({
patchDocumentOnRequest: (req, res, document1) => ({
...document1,
info: {
...document1.info,
Expand Down
2 changes: 1 addition & 1 deletion lib/interfaces/swagger-custom-options.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export interface SwaggerCustomOptions {
urls?: Record<'url' | 'name', string>[];
jsonDocumentUrl?: string;
yamlDocumentUrl?: string;
patchDocument?: <TRequest = any, TResponse = any> (req: TRequest, res: TResponse, document: OpenAPIObject) => OpenAPIObject;
patchDocumentOnRequest?: <TRequest = any, TResponse = any> (req: TRequest, res: TResponse, document: OpenAPIObject) => OpenAPIObject;
}
24 changes: 12 additions & 12 deletions lib/swagger-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ export class SwaggerModule {
if (!document) {
document = lazyBuildDocument();

if (options.swaggerOptions.patchDocument) {
document = options.swaggerOptions.patchDocument(req, res, document);
if (options.swaggerOptions.patchDocumentOnRequest) {
document = options.swaggerOptions.patchDocumentOnRequest(req, res, document);
}
}

Expand All @@ -131,8 +131,8 @@ export class SwaggerModule {
if (!document) {
document = lazyBuildDocument();

if (options.swaggerOptions.patchDocument) {
document = options.swaggerOptions.patchDocument(
if (options.swaggerOptions.patchDocumentOnRequest) {
document = options.swaggerOptions.patchDocumentOnRequest(
req,
res,
document
Expand Down Expand Up @@ -163,8 +163,8 @@ export class SwaggerModule {
if (!document) {
document = lazyBuildDocument();

if (options.swaggerOptions.patchDocument) {
document = options.swaggerOptions.patchDocument(req, res, document);
if (options.swaggerOptions.patchDocumentOnRequest) {
document = options.swaggerOptions.patchDocumentOnRequest(req, res, document);
}
}

Expand All @@ -187,8 +187,8 @@ export class SwaggerModule {
if (!document) {
document = lazyBuildDocument();

if (options.swaggerOptions.patchDocument) {
document = options.swaggerOptions.patchDocument(req, res, document);
if (options.swaggerOptions.patchDocumentOnRequest) {
document = options.swaggerOptions.patchDocumentOnRequest(req, res, document);
}
}

Expand Down Expand Up @@ -220,8 +220,8 @@ export class SwaggerModule {
if (!document) {
document = lazyBuildDocument();

if (options.swaggerOptions.patchDocument) {
document = options.swaggerOptions.patchDocument(req, res, document);
if (options.swaggerOptions.patchDocumentOnRequest) {
document = options.swaggerOptions.patchDocumentOnRequest(req, res, document);
}
}

Expand All @@ -238,8 +238,8 @@ export class SwaggerModule {
if (!document) {
document = lazyBuildDocument();

if (options.swaggerOptions.patchDocument) {
document = options.swaggerOptions.patchDocument(req, res, document);
if (options.swaggerOptions.patchDocumentOnRequest) {
document = options.swaggerOptions.patchDocumentOnRequest(req, res, document);
}
}

Expand Down

0 comments on commit 83c3e8d

Please sign in to comment.