Skip to content

Commit b06e08a

Browse files
Merge pull request #3697 from ismaildasci/feat/add-format-type-definition
feat: add type definition for format option in @ApiProperty decorator
2 parents 0eeb8af + 6457a58 commit b06e08a

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

lib/interfaces/open-api-spec.interface.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export interface SchemaObject {
214214
additionalProperties?: SchemaObject | ReferenceObject | boolean;
215215
patternProperties?: SchemaObject | ReferenceObject | any;
216216
description?: string;
217-
format?: string;
217+
format?: OpenAPIFormat;
218218
default?: any;
219219
title?: string;
220220
multipleOf?: number;
@@ -289,3 +289,37 @@ export type ScopesObject = Record<string, any>;
289289
export type SecurityRequirementObject = Record<string, string[]>;
290290

291291
export type ExtensionLocation = 'root' | 'info';
292+
293+
/**
294+
* OpenAPI format values as defined in the specification.
295+
* @see https://spec.openapis.org/oas/v3.0.3#data-types
296+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#section-7.3
297+
*/
298+
export type OpenAPIFormat =
299+
| 'int32'
300+
| 'int64'
301+
| 'float'
302+
| 'double'
303+
| 'byte'
304+
| 'binary'
305+
| 'date'
306+
| 'date-time'
307+
| 'time'
308+
| 'duration'
309+
| 'password'
310+
| 'email'
311+
| 'idn-email'
312+
| 'hostname'
313+
| 'idn-hostname'
314+
| 'ipv4'
315+
| 'ipv6'
316+
| 'uri'
317+
| 'uri-reference'
318+
| 'uri-template'
319+
| 'iri'
320+
| 'iri-reference'
321+
| 'uuid'
322+
| 'json-pointer'
323+
| 'relative-json-pointer'
324+
| 'regex'
325+
| (string & {});

0 commit comments

Comments
 (0)