UNPKG

nestjs-swagger-dto

Version:
33 lines (32 loc) 1.24 kB
import { ApiPropertyOptions } from '@nestjs/swagger'; export type PropertyOptions<T, CustomOptions = Record<string, never>> = BasePropertyOptions & CustomOptions & (SingularPropertyOptions<T> | ArrayPropertyOptions<T>); export type BasePropertyOptions = { name?: string; optional?: true; description?: string; deprecated?: true; nullable?: true; }; export type SingularPropertyOptions<T> = { example?: T; default?: T; isArray?: undefined; }; export type ArrayPropertyOptions<T> = { example?: T[]; default?: T[]; isArray: true | { minLength?: number; maxLength?: number; length?: number; /** * Wheter to put singular value into an array of it's own. * Useful if the decorated class is the query DTO. * * *NOTE*: This doesn't create an empty array if the value is not present. */ force?: boolean; }; }; export declare const noop: () => void; export declare const compose: <T, CustomOptions>(apiPropertyOptions: ApiPropertyOptions, { isArray, nullable, example, optional, description, deprecated, default: def, name, }: PropertyOptions<T, CustomOptions>, ...decorators: PropertyDecorator[]) => PropertyDecorator;