-
Notifications
You must be signed in to change notification settings - Fork 516
Open
Labels
Description
Is there an existing issue that is already proposing this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe it
Yes. When using @ApiProperty({ format: 'date-time' }), TypeScript allows any string value, which can lead to typos or unsupported formats being used without any warning. A stricter type would help ensure correctness and better IDE support.
Describe the solution you'd like
Define a union type such as:
type OpenAPIFormat =
| 'date-time'
| 'time'
| 'date'
| 'email'
| 'uuid'
| 'uri'
| 'hostname'
| 'ipv4'
| 'ipv6'
| 'int32'
| 'int64'
| 'float'
| 'double'
| 'password'
| 'binary';Then apply this type to the format field in the ApiPropertyOptions interface:
interface ApiPropertyOptions {
...
format?: OpenAPIFormat;
...
}Teachability, documentation, adoption, migration strategy
No response
What is the motivation / use case for changing the behavior?
The main motivation is to improve type safety and developer experience when using the @ApiProperty() decorator. Currently, the format field accepts any string, which allows for invalid or misspelled values without any feedback from the TypeScript compiler.