Skip to content

Commit bdd0ac8

Browse files
authored
feat: support x-enumNames param for client code generations, supporting numeric enums
1 parent ea25697 commit bdd0ac8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/decorators/api-property.decorator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface ApiPropertyOptions
88
name?: string;
99
enum?: any[] | Record<string, any> | (() => (any[] | Record<string, any>));
1010
enumName?: string;
11+
'x-enumNames'?: string[]
1112
}
1213

1314
const isEnumArray = (obj: ApiPropertyOptions): boolean =>

lib/services/schema-object-factory.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ export class SchemaObjectFactory {
288288
(param.isArray
289289
? param.schema?.['items']?.['type']
290290
: param.schema?.['type']) ?? 'string',
291-
enum: _enum
291+
enum: _enum,
292+
...(param['x-enumNames'] ? {'x-enumNames': param['x-enumNames']} : {})
292293
};
293294
}
294295

@@ -297,7 +298,7 @@ export class SchemaObjectFactory {
297298
? { type: 'array', items: { $ref } }
298299
: { $ref };
299300

300-
return omit(param, ['isArray', 'items', 'enumName', 'enum']);
301+
return omit(param, ['isArray', 'items', 'enumName', 'enum', 'x-enumNames']);
301302
}
302303

303304
createEnumSchemaType(

0 commit comments

Comments
 (0)