Skip to content

Commit

Permalink
Merge pull request #3067 from nadavhalfon/feat/x-enumNames
Browse files Browse the repository at this point in the history
feat: support x-enumNames param for client code generations
  • Loading branch information
kamilmysliwiec authored Sep 17, 2024
2 parents fdf9c1c + bdd0ac8 commit 5cb058e
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 5cb058e

Please sign in to comment.