Skip to content

Commit

Permalink
feat: support x-enumNames param for client code generations, supporti…
Browse files Browse the repository at this point in the history
…ng numeric enums
  • Loading branch information
nadavhalfon authored Sep 10, 2024
1 parent ea25697 commit bdd0ac8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/decorators/api-property.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface ApiPropertyOptions
name?: string;
enum?: any[] | Record<string, any> | (() => (any[] | Record<string, any>));
enumName?: string;
'x-enumNames'?: string[]
}

const isEnumArray = (obj: ApiPropertyOptions): boolean =>
Expand Down
5 changes: 3 additions & 2 deletions lib/services/schema-object-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']} : {})
};
}

Expand All @@ -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(
Expand Down

0 comments on commit bdd0ac8

Please sign in to comment.