#snake_case for query objects

4 messages · Page 1 of 1 (latest)

woven patrol
#

I am writing an GET api that have query param snake_case(for example: is_active). But I want the fields in my query class to be camelCase to be match the convention (for example isActive: boolean).
How can do this in nestjs in the cleanest way?

fiery path
#

I believe class-transformer has an @Expose() decorator that can do this

craggy valve
#

Yes, if you also want swagger docs, you can do it like this:

@ApiProperty({ name: 'snake_case' })
@Transform({ name: 'snake_case' })
snakeCase: string