How to use the @tsed/swagger.Docs function in @tsed/swagger

To help you get started, we’ve selected a few @tsed/swagger 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 TypedProject / ts-express-decorators / test / integration / app / controllers / responses / ResponseScenarioCtrl.ts View on Github external
import {ContentType, Controller, Get, Next, PathParams, Post, Req, Res, Status} from "@tsed/common";
import {Docs, Hidden} from "@tsed/swagger";
import {createReadStream} from "fs";
import {join} from "path";
import {of} from "rxjs";


@Controller("/response")
@Hidden()
@Docs("responses")
export class ResponseScenarioCtrl {
  @Get("/scenario1/:id")
  public testScenario1Assert(@PathParams("id") id: number, @Req() request: Req) {
    request.ctx.test = "value";
  }

  @Get("/scenario1/:id")
  public testScenario1Get(@PathParams("id") id: number, @Req() request: Req) {
    return id + request.ctx.test;
  }


  @Get("/scenario2/:id")
  public testScenario2Assert(@PathParams("id") id: number, @Req() request: Req, @Next() next: Next) {
    setTimeout(() => {
      request.ctx.test = "value";
github TypedProject / ts-express-decorators / test / integration / app / app.ts View on Github external
import * as Path from "path";
import {$log} from "ts-log-debug";
import {ErrorsCtrl} from "./controllers/errors/ErrorsCtrl";
import {SocketPageCtrl} from "./controllers/pages/SocketPageCtrl";
import {ProductsCtrl} from "./controllers/products/ProductsCtrl";

import {RestCtrl} from "./controllers/RestCtrl";
import TestAcceptMimeMiddleware from "./middlewares/acceptmime";
import "./middlewares/CustomAuthMiddleware";
import {InitSessionMiddleware} from "./middlewares/InitSessionMiddleware";
import {NotFoundMiddleware} from "./middlewares/NotFoundMiddleware";

const rootDir = Path.resolve(__dirname);
const spec = require(`${rootDir}/spec/swagger.default.json`);

Docs("authentication")(PassportCtrl);

@ServerSettings({
  rootDir,
  port: 8001,
  httpsPort: false,
  logger: {
    level: "info",
    logRequest: true
  },
  mount: {
    "/": [SocketPageCtrl],
    "/rest": [
      "${rootDir}/controllers/Base/**.ts",
      "${rootDir}/controllers/calendars/**.ts",
      ErrorsCtrl,
      RestCtrl,
github TypedProject / ts-express-decorators / test / integration / app / controllers / products / ProductsCtrl.ts View on Github external
import {BodyParams, Controller, Get, Post, Scope} from "@tsed/common";
import {Docs, Hidden} from "@tsed/swagger";
import {$log} from "ts-log-debug";
import {CalendarModel} from "../../models/Calendar";
import {AdminProductPostModel, UserProductPostModel} from "../../models/Product";
import {InnerService} from "../../services/InnerService";
import {OuterService} from "../../services/OuterService";

@Controller("/products")
@Scope("request")
@Hidden()
@Docs("hidden")
export class ProductsCtrl {
  constructor(public innerService: InnerService, public outerService: OuterService) {
    $log.debug("Controller New Instance");
    $log.debug("innerService == outerService.innerService? ", innerService === outerService.innerService);
  }

  @Get("/")
  async renderCalendars(): Promise {
    return [{id: "1", name: "test"}];
  }

  $onDestroy() {
    $log.debug("Destroy controller");
  }

  @Post("/admin")