How to use the swagger-express-ts.ApiOperationPost function in swagger-express-ts

To help you get started, we’ve selected a few swagger-express-ts 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 dimeloper / ts-simple-backend / server / controllers / user.controller.ts View on Github external
},
    },
    /* security: { - use if route is protected
      apiKeyHeader: [],
    }, */
    summary: 'Get users list',
  })
  private async getUsers(
    request: express.Request,
    response: express.Response
  ): Promise {
    const users = await UserModel.find({}).exec();
    response.status(200).json(users);
  }

  @ApiOperationPost({
    description: 'Post user object',
    parameters: {
      body: {
        description: 'New user',
        model: 'User',
        required: true,
      },
    },
    responses: {
      200: {
        model: 'User',
      },
      400: { description: 'Parameters fail' },
    },
    /* security: { - use if route is protected
      apiKeyHeader: [],
github olivierlsc / swagger-express-ts / src / cars / cars.controller.ts View on Github external
},
        },
        security: {
            apiKeyHeader: [],
        },
    })
    @httpGet('/')
    public getCars(
        request: express.Request,
        response: express.Response,
        next: express.NextFunction
    ): void {
        response.json(this.carsService.getCars());
    }

    @ApiOperationPost({
        description: 'Post car object',
        summary: 'Post new car',
        parameters: {
            body: {
                description: 'New car',
                required: true,
                model: 'Car',
            },
        },
        responses: {
            200: {
                model: 'Car',
            },
            400: { description: 'Parameters fail' },
        },
    })