tsoa-custom-decorators
Version:
Build swagger-compliant REST APIs using TypeScript and Node
57 lines (46 loc) • 1.71 kB
text/typescript
import { Route } from '../../../src/decorators/route';
import { Body, Query } from '../../../src/decorators/parameter';
import { Post, Patch } from '../../../src/decorators/methods';
import { GenericRequest, TestModel, TestClassModel } from '../testModel';
import { ModelService } from '../services/modelService';
('PostTest')
export class PostTestController {
()
public async postModel(() model: TestModel): Promise<TestModel> {
return model;
}
()
public async updateModel(() model: TestModel): Promise<TestModel> {
return await new ModelService().getModel();
}
('WithClassModel')
public async postClassModel(() model: TestClassModel): Promise<TestClassModel> {
const augmentedModel = new TestClassModel('test', 'test2', 'test3');
augmentedModel.id = 700;
return augmentedModel;
}
('Location')
public async postModelAtLocation(): Promise<TestModel> {
return new ModelService().getModel();
}
('Multi')
public async postWithMultiReturn(): Promise<TestModel[]> {
const model = new ModelService().getModel();
return [
model,
model
];
}
('WithId/{id}')
public async postWithId(id: number): Promise<TestModel> {
return new ModelService().getModel();
}
('WithBodyAndQueryParams')
public async postWithBodyAndQueryParams(() model: TestModel, () query: string): Promise<TestModel> {
return new ModelService().getModel();
}
('GenericBody')
public async getGenericRequest(() genericReq: GenericRequest<TestModel>): Promise<TestModel> {
return genericReq.value;
}
}