swagger-decorator
Version:
Decorator for Koa2 and koa-router, Auto-Generate Swagger Docs
38 lines (33 loc) • 871 B
JavaScript
// @flow
import {
apiDescription,
apiRequestMapping,
apiResponse,
bodyParameter,
pathParameter,
queryParameter
} from "../../src/swagger/decorator";
import User from "../entity/User";
import UserControllerDoc from "./UserControllerDoc";
/**
* Description 用户相关控制器
*/
export default class UserController extends UserControllerDoc {
("get", "/users")
("get all users list")
static async getUsers(ctx, next): [User] {
ctx.body = [new User()];
}
("get", "/user/:id")
("get user object by id, only access self or friends")
static async getUserByID(ctx, next): User {
ctx.body = new User();
}
("post", "/user")
("create new user")
static async postUser(): number {
ctx.body = {
statusCode: 200
};
}
}