How to use the @tsed/swagger.Responses 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 / examples / passport-azure-ad / packages / server / src / decorators / OAuthBearer.ts View on Github external
UseAuth(Passport.authenticate("oauth-bearer", {session: false, ...options}) as any),

    // Metadata for swagger
    Security("oauth", ...(options.scopes || [])),
    Operation({
      "parameters": [
        {
          "in": "header",
          "name": "Authorization",
          "type": "string",
          "required": true
        }
      ]
    }),
    Responses(401, {description: "Unauthorized"}),
    Responses(403, {description: "Forbidden"}),
    OAuthHead()
  );
}
github TypedProject / ts-express-decorators / examples / passport-azure-ad / packages / server / src / decorators / OAuthBearer.ts View on Github external
AuthOptions(OAuthBearerOptions as any, options), // Add this to store all options and retrieve it in verify function
    UseAuth(Passport.authenticate("oauth-bearer", {session: false, ...options}) as any),

    // Metadata for swagger
    Security("oauth", ...(options.scopes || [])),
    Operation({
      "parameters": [
        {
          "in": "header",
          "name": "Authorization",
          "type": "string",
          "required": true
        }
      ]
    }),
    Responses(401, {description: "Unauthorized"}),
    Responses(403, {description: "Forbidden"}),
    OAuthHead()
  );
}
github TypedProject / ts-express-decorators / test / integration / app / controllers / calendars / EventCtrl.ts View on Github external
})
@MergeParams()
export class EventCtrl extends BaseController {
  /**
   *
   */
  @Head("/")
  head() {
  }

  /**
   *
   * @returns {string}
   */
  @Patch("/:id")
  @Responses("404", {description: "Not found"})
  patch(
    @Title("Title event")
    @Required()
    @BodyParams()
      event: EventModel
  ): EventModel {
    if (event.id === "0" || event.id === "") {
      throw new NotFound("Not found");
    }

    return event;
  }

  /**
   *
   * @param response
github TypedProject / ts-express-decorators / examples / multer / src / controllers / upload / UploadCtrl.ts View on Github external
import {Controller, Put, Status} from "@tsed/common";
import {MulterOptions, MultipartFile} from "@tsed/multipartfiles";
import {Responses} from "@tsed/swagger";

@Controller("/upload")
export class UploadController {

  constructor() {
  }

  @Put("/")
  @Status(201)
  @Responses("201", {description: "Created"})
  @Responses("400", {description: "Bad Request"})
  @MulterOptions({dest: `${process.cwd()}/.tmp`})
  async add(@MultipartFile("file") file: Express.Multer.File): Promise {

    console.log("file: ", file);

    return true;
  }
}
github TypedProject / ts-express-decorators / examples / multer / src / controllers / upload / UploadCtrl.ts View on Github external
import {Controller, Put, Status} from "@tsed/common";
import {MulterOptions, MultipartFile} from "@tsed/multipartfiles";
import {Responses} from "@tsed/swagger";

@Controller("/upload")
export class UploadController {

  constructor() {
  }

  @Put("/")
  @Status(201)
  @Responses("201", {description: "Created"})
  @Responses("400", {description: "Bad Request"})
  @MulterOptions({dest: `${process.cwd()}/.tmp`})
  async add(@MultipartFile("file") file: Express.Multer.File): Promise {

    console.log("file: ", file);

    return true;
  }
}
github TypedProject / ts-express-decorators / docs / docs / snippets / authentication / auth-decorator-example.ts View on Github external
export function CustomAuth(options: ICustomAuthOptions = {}): Function {
  return applyDecorators(
    UseAuth(CustomAuthMiddleware, options),
    Security("oauth", ...(options.scopes || [])),
    Responses(401, {description: "Unauthorized"}),
    Responses(403, {description: "Forbidden"})
  );
}
github TypedProject / ts-express-decorators / docs / docs / snippets / authentication / auth-decorator-example.ts View on Github external
export function CustomAuth(options: ICustomAuthOptions = {}): Function {
  return applyDecorators(
    UseAuth(CustomAuthMiddleware, options),
    Security("oauth", ...(options.scopes || [])),
    Responses(401, {description: "Unauthorized"}),
    Responses(403, {description: "Forbidden"})
  );
}