Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(auth): publish the API key name length bounds in the schema
Yudhi Armyndharise37512221c3d
diff --git a/src/modules/auth/dto/api-key.dto.spec.ts b/src/modules/auth/dto/api-key.dto.spec.tsindex b4267c307..ed4d20aa9 100644--- a/src/modules/auth/dto/api-key.dto.spec.ts+++ b/src/modules/auth/dto/api-key.dto.spec.ts@@ -2,13 +2,18 @@ import 'reflect-metadata';import { plainToInstance } from 'class-transformer';import { validate } from 'class-validator';import type { Repository } from 'typeorm';-import { ApiKeyResponseDto, UpdateApiKeyDto } from './api-key.dto';+import { ApiKeyResponseDto, CreateApiKeyDto, UpdateApiKeyDto } from './api-key.dto';import { AuthService } from '../auth.service';import type { ApiKey } from '../entities/api-key.entity';import type { ApiKeyUsageTracker } from '../api-key-usage-tracker.service';const property = (dto: object, name: string) =>- Reflect.getMetadata('swagger/apiModelProperties', dto, name) as { description?: string; nullable?: boolean };+ Reflect.getMetadata('swagger/apiModelProperties', dto, name) as {+ description?: string;+ nullable?: boolean;+ minLength?: number;+ maxLength?: number;+ };describe('API key DTO contract', () => {it('describes keyPrefix with the length the service stores', async () => {@@ -29,4 +34,8 @@ describe('API key DTO contract', () => {expect(await errors(null)).toEqual([]);expect(await errors('')).toEqual(['expiresAt']);});++ it.each([CreateApiKeyDto, UpdateApiKeyDto])('publishes the name length bounds %p validates', dto => {+ expect(property(dto.prototype, 'name')).toEqual(expect.objectContaining({ minLength: 3, maxLength: 100 }));+ });});diff --git a/src/modules/auth/dto/api-key.dto.ts b/src/modules/auth/dto/api-key.dto.tsindex 2ea1e146b..163225a26 100644--- a/src/modules/auth/dto/api-key.dto.ts+++ b/src/modules/auth/dto/api-key.dto.ts@@ -10,6 +10,8 @@ export class CreateApiKeyDto {@ApiProperty({description: 'Friendly name for the API key',example: 'Production Bot',+ minLength: 3,+ maxLength: 100,})@IsString()@MinLength(3)@@ -137,7 +139,7 @@ export class ValidateApiKeyResponseDto {}export class UpdateApiKeyDto {- @ApiPropertyOptional()+ @ApiPropertyOptional({ minLength: 3, maxLength: 100 })@IsOptional()@IsString()@MinLength(3)