How to use the @tsed/swagger.Summary 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 / base / BaseController.ts View on Github external
@Get("/:resources/test/:id")
  @Summary("Return an element by his resource")
  async getTest(
    @Description("The resource")
    @PathParams("resources")
    resources: string,
    @Description("Id of the resource")
    @PathParams("id")
    id: string
  ): Promise {
    return {_id: id};
  }

  @Get("/list")
  @Summary("Return all elements from a service")
  async index(): Promise {
    return [{_id: "test"}];
  }
}
github TypedProject / ts-express-decorators / examples / mongoose / src / controllers / events / EventsCtrl.ts View on Github external
async get(@Description("The event id")
            @PathParams("id") id: string): Promise {
    return this.calendarEventsService
      .find(id)
      .catch((err) => {
        throw new NotFound("Event not found");
      });
  }

  /**
   *
   * @returns {null}
   */
  @Put("/")
  @UseBefore(CheckCalendarIdMiddleware)
  @Summary("Create an event")
  @Status(201, {description: "Created"})
  async save(@Description("The calendar id of the event")
             @Required() @PathParams("calendarId") calendarId: string,
             @BodyParams() calendarEvent: CalendarEvent): Promise {

    calendarEvent.calendarId = calendarId;

    return this.calendarEventsService.save(calendarEvent);
  }

  /**
   *
   * @returns {null}
   */
  @Post("/:id")
  @UseBefore(CheckCalendarIdMiddleware)
github TypedProject / ts-express-decorators / examples / mongoose / src / controllers / calendars / CalendarsCtrl.ts View on Github external
}

  /**
   *
   * @param id
   * @returns {{id: string, name: string}}
   */
  @Delete("/:id")
  @Summary("Remove a calendar.")
  @Status(204, {description: "No content"})
  async remove(@PathParams("id") id: string): Promise {
    await this.calendarsService.remove(id);
  }

  @Delete("/")
  @Summary("Remove all calendars.")
  @Status(204, {description: "No content"})
  async clear(@PathParams("id") id: string): Promise {
    await this.calendarsService.clear();
  }

  /**
   *
   * @returns {Promise}
   */
  @Get("/")
  @Summary("Return all calendars")
  @Status(200, {description: "Success", type: Calendar, collectionType: Array})
  async getAllCalendars(): Promise {
    return this.calendarsService.query();
  }
}
github TypedProject / ts-express-decorators / examples / mongoose / src / controllers / events / EventsCtrl.ts View on Github external
import {CalendarEventsService} from "../../services/calendars/CalendarEventsService";

@Controller("/:calendarId/events")
@MergeParams(true)
export class EventsCtrl {
  constructor(private calendarEventsService: CalendarEventsService) {

  }

  /**
   *
   * @returns {null}
   */
  @Get("/:id")
  @UseBefore(CheckCalendarIdMiddleware)
  @Summary("Get an event from his ID")
  @Status(200, {description: "Success"})
  async get(@Description("The event id")
            @PathParams("id") id: string): Promise {
    return this.calendarEventsService
      .find(id)
      .catch((err) => {
        throw new NotFound("Event not found");
      });
  }

  /**
   *
   * @returns {null}
   */
  @Put("/")
  @UseBefore(CheckCalendarIdMiddleware)
github TypedProject / ts-express-decorators / examples / mongoose / src / controllers / calendars / CalendarsCtrl.ts View on Github external
async update(@PathParams("id") @Required() id: string,
               @BodyParams() calendar: Calendar): Promise {

    calendar._id = id;

    return this.calendarsService.save
    (calendar);
  }

  /**
   *
   * @param id
   * @returns {{id: string, name: string}}
   */
  @Delete("/:id")
  @Summary("Remove a calendar.")
  @Status(204, {description: "No content"})
  async remove(@PathParams("id") id: string): Promise {
    await this.calendarsService.remove(id);
  }

  @Delete("/")
  @Summary("Remove all calendars.")
  @Status(204, {description: "No content"})
  async clear(@PathParams("id") id: string): Promise {
    await this.calendarsService.clear();
  }

  /**
   *
   * @returns {Promise}
   */
github TypedProject / ts-express-decorators / examples / mongoose / src / controllers / calendars / CalendarsCtrl.ts View on Github external
await this.calendarsService.remove(id);
  }

  @Delete("/")
  @Summary("Remove all calendars.")
  @Status(204, {description: "No content"})
  async clear(@PathParams("id") id: string): Promise {
    await this.calendarsService.clear();
  }

  /**
   *
   * @returns {Promise}
   */
  @Get("/")
  @Summary("Return all calendars")
  @Status(200, {description: "Success", type: Calendar, collectionType: Array})
  async getAllCalendars(): Promise {
    return this.calendarsService.query();
  }
}
github TypedProject / ts-express-decorators / examples / mongoose / src / controllers / events / EventsCtrl.ts View on Github external
return this
      .calendarEventsService
      .find(id)
      .then(() => this.calendarEventsService.save(calendarEvent))
      .catch((err) => {
        throw new NotFound("Calendar id not found");
      });
  }

  /**
   *
   */
  @Delete("/:id")
  @UseBefore(CheckCalendarIdMiddleware)
  @Summary("Remove an event")
  @Status(204, {description: "No content"})
  async remove(@Description("The calendar id of the event")
               @Required() @PathParams("calendarId") calendarId: string,
               @Description("The event id")
               @PathParams("id") id: string): Promise {
    return this.calendarEventsService.remove(id);
  }

  @Get("/")
  @Summary("Get all events for a calendar")
  @Status(200, {description: "Success"})
  async getEvents(@Description("The calendar id of the event")
                  @Required() @PathParams("calendarId") calendarId: string): Promise {
    return this.calendarEventsService.query(calendarId);
  }
}
github TypedProject / ts-express-decorators / examples / mongoose / src / controllers / calendars / CalendarsCtrl.ts View on Github external
* All routes of EventsCtrl will be mounted on the `/calendars` path.
 */
@Controller("/calendars", EventsCtrl)
export class CalendarsCtrl {

  constructor(private calendarsService: CalendarsService) {

  }

  /**
   *
   * @param {string} id
   * @returns {Promise}
   */
  @Get("/:id")
  @Summary("Return a calendar from his ID")
  @Status(200, {description: "Success", type: Calendar})
  async get(@Required() @PathParams("id") id: string): Promise {

    const calendar = await this.calendarsService.find(id);

    if (calendar) {
      return calendar;
    }

    throw new NotFound("Calendar not found");
  }

  /**
   *
   * @param {Calendar} calendar
   * @returns {Promise}
github TypedProject / ts-express-decorators / examples / mongoose / src / controllers / events / EventsCtrl.ts View on Github external
/**
   *
   */
  @Delete("/:id")
  @UseBefore(CheckCalendarIdMiddleware)
  @Summary("Remove an event")
  @Status(204, {description: "No content"})
  async remove(@Description("The calendar id of the event")
               @Required() @PathParams("calendarId") calendarId: string,
               @Description("The event id")
               @PathParams("id") id: string): Promise {
    return this.calendarEventsService.remove(id);
  }

  @Get("/")
  @Summary("Get all events for a calendar")
  @Status(200, {description: "Success"})
  async getEvents(@Description("The calendar id of the event")
                  @Required() @PathParams("calendarId") calendarId: string): Promise {
    return this.calendarEventsService.query(calendarId);
  }
}
github TypedProject / ts-express-decorators / examples / mongoose / src / controllers / calendars / CalendarsCtrl.ts View on Github external
const calendar = await this.calendarsService.find(id);

    if (calendar) {
      return calendar;
    }

    throw new NotFound("Calendar not found");
  }

  /**
   *
   * @param {Calendar} calendar
   * @returns {Promise}
   */
  @Put("/")
  @Summary("Create a new Calendar")
  @Status(201, {description: "Created", type: Calendar})
  save(@Description("Calendar model")
       @BodyParams() calendar: Calendar) {
    return this.calendarsService.save(calendar);
  }

  /**
   *
   * @param id
   * @param calendar
   * @returns {Promise}
   */
  @Post("/:id")
  @Summary("Update calendar information")
  @Status(200, {description: "Success", type: Calendar})
  async update(@PathParams("id") @Required() id: string,