-
-
Notifications
You must be signed in to change notification settings - Fork 286
/
any.ts
44 lines (43 loc) · 815 Bytes
/
any.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import {Type} from "@tsed/core";
import {JSONSchema6TypeName} from "json-schema";
import {JsonEntityFn} from "./jsonEntityFn";
/**
* Set the type of the array items.
*
* ## Example
*
* ```typescript
* class Model {
* @Any()
* property: any;
*
* @Any(String, Number, Boolean)
* property: string | number | boolean;
* }
* ```
*
* Will produce:
*
* ```json
* {
* "type": "object",
* "properties": {
* "property": {
* "type": ["integer", "number", "string", "boolean", "array", "object", "null"]
* }
* }
* }
* ```
*
* @returns {Function}
* @decorator
* @validation
* @swagger
* @schema
* @input
*/
export function Any(...types: (JSONSchema6TypeName | Type<any> | any)[]) {
return JsonEntityFn((store) => {
store.itemSchema.any(...types);
});
}