forked from lukeautry/tsoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexampleController.ts
129 lines (120 loc) · 2.59 KB
/
exampleController.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
125
126
127
128
129
import { Route, Get, Path, Query, Header, Post, Body, BodyProp, Example, Res, TsoaResponse } from '@tsoa/runtime';
/**
* @example {
* "contry": "123",
* "city": "456"
* }
*/
export interface Location {
contry: string;
city: string;
}
@Route('ExampleTest')
export class ExampleTestController {
/**
* @example path "an_example_path"
* @example path "an_example_path2"
*/
@Get('/path/{path}')
public async path(@Path() path: string): Promise<void> {
return;
}
/**
* @example query "an_example_query"
* @example query "an_example_query2"
*/
@Get('/query')
public async query(@Query() query: string): Promise<void> {
return;
}
/**
* @example header "aaaaaaLongCookie"
* @example header "aaaaaaLongCookie2"
*/
@Get('/header')
public async header(@Header() header: string): Promise<void> {
return;
}
/**
* @example location {
* "contry": "1",
* "city": "1"
* }
* @example location {
* "contry": "2",
* "city": "2"
* }
*/
@Post('/post_body')
public async post(@Body() location: Location): Promise<void> {
return;
}
/**
* @example prop1 "prop1_1"
* @example prop1 "prop1_2"
* @example prop1 "prop1_3"
* @example prop2 "prop2_1"
* @example prop2 "prop2_2"
* @example prop2 "prop2_3"
*/
@Post('/post_body_prop')
public async postBodyProp(@BodyProp() prop1: string, @BodyProp() prop2: string): Promise<void> {
return;
}
/**
* @example location {
* "contry": "1",
* "city": "1"
* }
* @example location {
* "contry": "2",
* "city": "2"
* }
* @example s "aa0"
* @example s "aa1"
* @example s "aa2"
*/
@Post('/two_parameter/{s}')
public async twoParameter(@Body() location: Location, @Path() s: string): Promise<void> {
return;
}
/**
*
* @example locations [
* {
* "contry": "1",
* "city": "1"
* },
* {
* "contry": "2",
* "city": "2"
* }
* ]
* @example locations [
* {
* "contry": "22",
* "city": "22"
* },
* {
* "contry": "33",
* "city": "33"
* }
* ]
*/
@Post('/array_with_object')
public async arrayWithObject(@Body() locations: Location[]): Promise<void> {
return;
}
/**
* @param res The alternate response
* @example res 123
* @example res 1
*/
@Example<string>('test 1')
@Example<string>('test 2')
@Get('MultiResponseExamples')
public async responseExamples(@Res() res: TsoaResponse<400, number, { 'custom-header': string }>): Promise<string> {
res?.(400, 123, { 'custom-header': 'hello' });
return 'test 1';
}
}