From 6b584cdd5bf5444560b72a6fbfbb33728de13670 Mon Sep 17 00:00:00 2001 From: GalTidhar <39020298+tatarco@users.noreply.github.com> Date: Mon, 25 Nov 2024 21:52:55 +0100 Subject: [PATCH] fix(api): remove openApi Methods (#7128) --- apps/api/src/app/change/changes.controller.ts | 2 ++ .../app/environments-v2/environments.controller.ts | 2 ++ apps/api/src/app/feeds/feeds.controller.ts | 2 ++ apps/api/src/app/layouts/layouts.controller.ts | 2 ++ .../app/organization/organization.controller.ts | 2 ++ .../dtos/update-subscriber-channel-request.dto.ts | 14 +++++++++++--- apps/api/src/app/tenant/tenant.controller.ts | 2 ++ .../src/app/workflows-v1/workflow-v1.controller.ts | 5 +++-- 8 files changed, 26 insertions(+), 5 deletions(-) diff --git a/apps/api/src/app/change/changes.controller.ts b/apps/api/src/app/change/changes.controller.ts index 33d8ee233e6..7b04f225f7c 100644 --- a/apps/api/src/app/change/changes.controller.ts +++ b/apps/api/src/app/change/changes.controller.ts @@ -1,6 +1,7 @@ import { Body, ClassSerializerInterceptor, Controller, Get, Param, Post, Query, UseInterceptors } from '@nestjs/common'; import { ApiRateLimitCostEnum, UserSessionData } from '@novu/shared'; import { ApiOperation, ApiTags } from '@nestjs/swagger'; +import { ApiExcludeController } from '@nestjs/swagger/dist/decorators/api-exclude-controller.decorator'; import { UserSession } from '../shared/framework/user.decorator'; import { ApplyChange, ApplyChangeCommand } from './usecases'; import { GetChanges } from './usecases/get-changes/get-changes.usecase'; @@ -24,6 +25,7 @@ import { SdkMethodName } from '../shared/framework/swagger/sdk.decorators'; @UseInterceptors(ClassSerializerInterceptor) @UserAuthentication() @ApiTags('Changes') +@ApiExcludeController() export class ChangesController { constructor( private applyChange: ApplyChange, diff --git a/apps/api/src/app/environments-v2/environments.controller.ts b/apps/api/src/app/environments-v2/environments.controller.ts index 8ea8f4673d8..468fd41cd84 100644 --- a/apps/api/src/app/environments-v2/environments.controller.ts +++ b/apps/api/src/app/environments-v2/environments.controller.ts @@ -1,6 +1,7 @@ import { ClassSerializerInterceptor, Controller, Get, Param, UseInterceptors } from '@nestjs/common'; import { UserSessionData } from '@novu/shared'; import { ApiTags } from '@nestjs/swagger'; +import { ApiExcludeController } from '@nestjs/swagger/dist/decorators/api-exclude-controller.decorator'; import { UserSession } from '../shared/framework/user.decorator'; import { GetEnvironmentTags, GetEnvironmentTagsCommand } from './usecases/get-environment-tags'; import { ExternalApiAccessible } from '../auth/framework/external-api.decorator'; @@ -13,6 +14,7 @@ import { GetEnvironmentTagsDto } from './dtos/get-environment-tags.dto'; @UseInterceptors(ClassSerializerInterceptor) @UserAuthentication() @ApiTags('Environments') +@ApiExcludeController() export class EnvironmentsController { constructor(private getEnvironmentTagsUsecase: GetEnvironmentTags) {} diff --git a/apps/api/src/app/feeds/feeds.controller.ts b/apps/api/src/app/feeds/feeds.controller.ts index 16a1938bcba..bdde9070382 100644 --- a/apps/api/src/app/feeds/feeds.controller.ts +++ b/apps/api/src/app/feeds/feeds.controller.ts @@ -10,6 +10,7 @@ import { } from '@nestjs/common'; import { UserSessionData } from '@novu/shared'; import { ApiOperation, ApiTags } from '@nestjs/swagger'; +import { ApiExcludeController } from '@nestjs/swagger/dist/decorators/api-exclude-controller.decorator'; import { UserSession } from '../shared/framework/user.decorator'; import { CreateFeed } from './usecases/create-feed/create-feed.usecase'; import { CreateFeedCommand } from './usecases/create-feed/create-feed.command'; @@ -28,6 +29,7 @@ import { UserAuthentication } from '../shared/framework/swagger/api.key.security @UseInterceptors(ClassSerializerInterceptor) @UserAuthentication() @ApiTags('Feeds') +@ApiExcludeController() export class FeedsController { constructor( private createFeedUsecase: CreateFeed, diff --git a/apps/api/src/app/layouts/layouts.controller.ts b/apps/api/src/app/layouts/layouts.controller.ts index 4779e1c36b0..02665b08de1 100644 --- a/apps/api/src/app/layouts/layouts.controller.ts +++ b/apps/api/src/app/layouts/layouts.controller.ts @@ -15,6 +15,7 @@ import { import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger'; import { OrderByEnum, OrderDirectionEnum, UserSessionData } from '@novu/shared'; import { GetLayoutCommand, GetLayoutUseCase, OtelSpan } from '@novu/application-generic'; +import { ApiExcludeController } from '@nestjs/swagger/dist/decorators/api-exclude-controller.decorator'; import { ApiBadRequestResponse, ApiCommonResponses, @@ -56,6 +57,7 @@ import { SdkMethodName } from '../shared/framework/swagger/sdk.decorators'; @Controller('/layouts') @ApiTags('Layouts') @UserAuthentication() +@ApiExcludeController() export class LayoutsController { constructor( private createLayoutUseCase: CreateLayoutUseCase, diff --git a/apps/api/src/app/organization/organization.controller.ts b/apps/api/src/app/organization/organization.controller.ts index 50404a6d41b..f77afb23070 100644 --- a/apps/api/src/app/organization/organization.controller.ts +++ b/apps/api/src/app/organization/organization.controller.ts @@ -13,6 +13,7 @@ import { import { OrganizationEntity } from '@novu/dal'; import { MemberRoleEnum, UserSessionData } from '@novu/shared'; import { ApiExcludeEndpoint, ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger'; +import { ApiExcludeController } from '@nestjs/swagger/dist/decorators/api-exclude-controller.decorator'; import { UserSession } from '../shared/framework/user.decorator'; import { CreateOrganizationDto } from './dtos/create-organization.dto'; import { CreateOrganizationCommand } from './usecases/create-organization/create-organization.command'; @@ -48,6 +49,7 @@ import { SdkGroupName, SdkMethodName } from '../shared/framework/swagger/sdk.dec @UserAuthentication() @ApiTags('Organizations') @ApiCommonResponses() +@ApiExcludeController() export class OrganizationController { constructor( private createOrganizationUsecase: CreateOrganization, diff --git a/apps/api/src/app/subscribers/dtos/update-subscriber-channel-request.dto.ts b/apps/api/src/app/subscribers/dtos/update-subscriber-channel-request.dto.ts index 06121822068..88bcd77e1a1 100644 --- a/apps/api/src/app/subscribers/dtos/update-subscriber-channel-request.dto.ts +++ b/apps/api/src/app/subscribers/dtos/update-subscriber-channel-request.dto.ts @@ -1,15 +1,23 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsDefined, IsObject, IsOptional, IsString } from 'class-validator'; +import { IsDefined, IsEnum, IsObject, IsOptional, IsString } from 'class-validator'; import { ChatProviderIdEnum, ISubscriberChannel, PushProviderIdEnum } from '@novu/shared'; import { ChannelCredentials } from '../../shared/dtos/subscriber-channel'; +export function getEnumValues(enumObj: T): Array { + return Object.values(enumObj || {}) as Array; +} export class UpdateSubscriberChannelRequestDto implements ISubscriberChannel { @ApiProperty({ - enum: [ChatProviderIdEnum, PushProviderIdEnum], + enum: [...getEnumValues(ChatProviderIdEnum), ...getEnumValues(PushProviderIdEnum)], description: 'The provider identifier for the credentials', }) - @IsString() + @IsEnum( + { ...ChatProviderIdEnum, ...PushProviderIdEnum }, + { + message: 'providerId must be a valid provider ID', + } + ) @IsDefined() providerId: ChatProviderIdEnum | PushProviderIdEnum; diff --git a/apps/api/src/app/tenant/tenant.controller.ts b/apps/api/src/app/tenant/tenant.controller.ts index a055d3e974b..e263e24da72 100644 --- a/apps/api/src/app/tenant/tenant.controller.ts +++ b/apps/api/src/app/tenant/tenant.controller.ts @@ -26,6 +26,7 @@ import { UpdateTenant, UpdateTenantCommand, } from '@novu/application-generic'; +import { ApiExcludeController } from '@nestjs/swagger/dist/decorators/api-exclude-controller.decorator'; import { UserSession } from '../shared/framework/user.decorator'; import { ExternalApiAccessible } from '../auth/framework/external-api.decorator'; import { @@ -62,6 +63,7 @@ const v2TenantsApiDescription = ' Tenants is not supported in code first version @ApiTags('Tenants') @UseInterceptors(ClassSerializerInterceptor) @UserAuthentication() +@ApiExcludeController() export class TenantController { constructor( private createTenantUsecase: CreateTenant, diff --git a/apps/api/src/app/workflows-v1/workflow-v1.controller.ts b/apps/api/src/app/workflows-v1/workflow-v1.controller.ts index 77df980baf5..7d33635642f 100644 --- a/apps/api/src/app/workflows-v1/workflow-v1.controller.ts +++ b/apps/api/src/app/workflows-v1/workflow-v1.controller.ts @@ -26,6 +26,7 @@ import { } from '@novu/shared'; import { ApiOperation, ApiTags } from '@nestjs/swagger'; +import { ApiExcludeController } from '@nestjs/swagger/dist/decorators/api-exclude-controller.decorator'; import { UserSession } from '../shared/framework/user.decorator'; import { GetNotificationTemplates } from './usecases/get-notification-templates/get-notification-templates.usecase'; import { GetNotificationTemplatesCommand } from './usecases/get-notification-templates/get-notification-templates.command'; @@ -45,7 +46,7 @@ import { WorkflowResponse } from './dto/workflow-response.dto'; import { WorkflowsResponseDto } from './dto/workflows.response.dto'; import { ExternalApiAccessible } from '../auth/framework/external-api.decorator'; import { WorkflowsRequestDto } from './dto/workflows-request.dto'; -import { ApiCommonResponses, ApiOkResponse, ApiResponse } from '../shared/framework/response.decorator'; +import { ApiOkResponse, ApiResponse } from '../shared/framework/response.decorator'; import { DataBooleanDto } from '../shared/dtos/data-wrapper-dto'; import { CreateWorkflowQuery } from './queries'; import { DeleteNotificationTemplateCommand } from './usecases/delete-notification-template/delete-notification-template.command'; @@ -57,7 +58,7 @@ import { SdkGroupName } from '../shared/framework/swagger/sdk.decorators'; /** * @deprecated use controllers in /workflows directory */ -@ApiCommonResponses() +@ApiExcludeController() @Controller('/workflows') @UseInterceptors(ClassSerializerInterceptor) @UserAuthentication()