How to use the koa-swagger-decorator.responsesAll function in koa-swagger-decorator

To help you get started, we’ve selected a few koa-swagger-decorator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github javieraviles / node-typescript-koa-rest / src / controller / user.ts View on Github external
import { BaseContext } from 'koa';
import { getManager, Repository, Not, Equal } from 'typeorm';
import { validate, ValidationError } from 'class-validator';
import { request, summary, path, body, responsesAll, tagsAll } from 'koa-swagger-decorator';
import { User, userSchema } from '../entity/user';

@responsesAll({ 200: { description: 'success'}, 400: { description: 'bad request'}, 401: { description: 'unauthorized, missing/wrong jwt token'}})
@tagsAll(['User'])
export default class UserController {

    @request('get', '/users')
    @summary('Find all users')
    public static async getUsers(ctx: BaseContext) {

        // get a user repository to perform operations with user
        const userRepository: Repository = getManager().getRepository(User);

        // load all users
        const users: User[] = await userRepository.find();

        // return OK status code and loaded users array
        ctx.status = 200;
        ctx.body = users;
github autoai-org / AID / components / discovery / src / controllers / ping.ts View on Github external
import { request, summary, path, body, responsesAll, tagsAll, tags } from 'koa-swagger-decorator';
import { BaseContext } from 'koa';

@responsesAll({ 200: { description: 'Success'}, 500: { description: 'Server Error'}})
@tagsAll(['ping'])
export default class PingController {
    @request('get', '/ping')
    @summary('test if the server is running')
    public static async pong(ctx: BaseContext) {
        ctx.status = 200;
        ctx.body = 'pong';
    }
}