From bdd0ac81a8a8058623b4a0f6a1ce3f9de07fadd4 Mon Sep 17 00:00:00 2001 From: nadavhalfon <32557985+nadavhalfon@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:25:02 +0300 Subject: [PATCH] feat: support x-enumNames param for client code generations, supporting numeric enums --- lib/decorators/api-property.decorator.ts | 1 + lib/services/schema-object-factory.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/decorators/api-property.decorator.ts b/lib/decorators/api-property.decorator.ts index 5f5fe7416..6d239a20c 100644 --- a/lib/decorators/api-property.decorator.ts +++ b/lib/decorators/api-property.decorator.ts @@ -8,6 +8,7 @@ export interface ApiPropertyOptions name?: string; enum?: any[] | Record | (() => (any[] | Record)); enumName?: string; + 'x-enumNames'?: string[] } const isEnumArray = (obj: ApiPropertyOptions): boolean => diff --git a/lib/services/schema-object-factory.ts b/lib/services/schema-object-factory.ts index 27dd5feb8..09fd6fc3a 100644 --- a/lib/services/schema-object-factory.ts +++ b/lib/services/schema-object-factory.ts @@ -288,7 +288,8 @@ export class SchemaObjectFactory { (param.isArray ? param.schema?.['items']?.['type'] : param.schema?.['type']) ?? 'string', - enum: _enum + enum: _enum, + ...(param['x-enumNames'] ? {'x-enumNames': param['x-enumNames']} : {}) }; } @@ -297,7 +298,7 @@ export class SchemaObjectFactory { ? { type: 'array', items: { $ref } } : { $ref }; - return omit(param, ['isArray', 'items', 'enumName', 'enum']); + return omit(param, ['isArray', 'items', 'enumName', 'enum', 'x-enumNames']); } createEnumSchemaType(