-
-
Notifications
You must be signed in to change notification settings - Fork 281
/
query-model-examples.spec.ts
124 lines (118 loc) · 2.61 KB
/
query-model-examples.spec.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import {
Default,
Examples,
GenericOf,
Generics,
getSpec,
In,
Maximum,
Minimum,
OperationPath,
Path,
Property,
SpecTypes
} from "../../src/index";
import {QueryParams} from "@tsed/platform-params";
class QueryParamModel {
@Property()
path: string;
@Property()
condition: string;
@Property()
value: string;
}
@Path("/query")
class QueryModelCtrl {
@OperationPath("GET", "/")
async get(
@QueryParams()
@Examples({
example1: {
description: "description1",
value: {
path: "path1",
condition: "condition1"
}
},
example2: {
description: "description1",
value: {
path: "path2",
condition: "condition2"
}
}
})
q: QueryParamModel
) {}
}
describe("Query Model example", () => {
it("should generate the spec for deep object", () => {
const spec = getSpec(QueryModelCtrl, {specType: SpecTypes.OPENAPI});
expect(spec).toEqual({
paths: {
"/query": {
get: {
operationId: "queryModelCtrlGet",
parameters: [
{
in: "query",
name: "path",
required: false,
examples: {
example1: {
description: "description1",
value: "path1"
},
example2: {
description: "description1",
value: "path2"
}
},
schema: {
type: "string"
}
},
{
examples: {
example1: {
description: "description1",
value: "condition1"
},
example2: {
description: "description1",
value: "condition2"
}
},
in: "query",
name: "condition",
required: false,
schema: {
type: "string"
}
},
{
in: "query",
name: "value",
required: false,
schema: {
type: "string"
}
}
],
responses: {
"200": {
description: "Success"
}
},
tags: ["QueryModelCtrl"]
}
}
},
tags: [
{
name: "QueryModelCtrl"
}
]
});
});
});