Page Contents

Home > @loopback/openapi-v3 > tags

tags() function

Add tags for an endpoint. When applied to a class, this decorator adds the tags to all endpoints.

Signature:

export declare function tags(...tagNames: string[]): (target: any, method?: string, methodDescriptor?: TypedPropertyDescriptor<any>) => any;

Parameters

Parameter Type Description
tagNames string[] A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier.

Returns:

(target: any, method?: string, methodDescriptor?: TypedPropertyDescriptor<any>) => any

Example

@oas.tags('greeting', 'public')
class MyController {
  @get('/greet')
  greet() {
    return 'Hello world!';
  }

  @get('/echo')
  echo() {
    return 'Hello world!';
  }
}

or

class MyController {
  @oas.tags('greeting', 'public')
  @get('/greet')
  greet() {
    return 'Hello world!';
  }

  @get('/echo')
  echo() {
    return 'Hello world!';
  }
}