forked from lukeautry/tsoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethodController.ts
106 lines (91 loc) · 2.55 KB
/
methodController.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
import {
Controller,
Delete,
Get,
Patch,
Post,
Put,
Response,
Route,
Security,
SuccessResponse,
Tags,
} from '../../../src';
import { ModelService } from '../services/modelService';
import { ErrorResponseModel, TestModel } from '../testModel';
@Route('MethodTest')
export class MethodController extends Controller {
@Get('Get')
public async getMethod(): Promise<TestModel> {
return new ModelService().getModel();
}
@Post('Post')
public async postMethod(): Promise<TestModel> {
return new ModelService().getModel();
}
@Patch('Patch')
public async patchMethod(): Promise<TestModel> {
return new ModelService().getModel();
}
@Put('Put')
public async putMethod(): Promise<TestModel> {
return new ModelService().getModel();
}
@Delete('Delete')
public async deleteMethod(): Promise<TestModel> {
return new ModelService().getModel();
}
/**
* method description
*/
@Get('Description')
public async description(): Promise<TestModel> {
return new ModelService().getModel();
}
@Tags('Tag1', 'Tag2', 'Tag3')
@Get('Tags')
public async tags(): Promise<TestModel> {
return new ModelService().getModel();
}
@Response<ErrorResponseModel>('400', 'Bad Request')
@Response<ErrorResponseModel>('401', 'Unauthorized')
@Response<ErrorResponseModel>('default', 'Unexpected error')
@Get('MultiResponse')
public async multiResponse(): Promise<TestModel> {
return new ModelService().getModel();
}
@SuccessResponse('201', 'Created')
@Get('SuccessResponse')
public async successResponse(): Promise<void> {
this.setStatus(201);
return Promise.resolve();
}
@Security('api_key')
@Get('ApiSecurity')
public async apiSecurity(): Promise<TestModel> {
return new ModelService().getModel();
}
@Security('tsoa_auth', ['write:pets', 'read:pets'])
@Get('OauthSecurity')
public async oauthSecurity(): Promise<TestModel> {
return new ModelService().getModel();
}
/**
* @deprecated
*/
@Get('DeprecatedMethod')
public async deprecatedMethod(): Promise<TestModel> {
return new ModelService().getModel();
}
/**
* @summary simple summary
*/
@Get('SummaryMethod')
public async summaryMethod(): Promise<TestModel> {
return new ModelService().getModel();
}
@Get('returnAnyType')
public async returnAnyType(): Promise<any> {
return 'Hello Word';
}
}