Page Contents

Home > @loopback/openapi-v3 > api

api() function

Decorate the given Controller constructor with metadata describing the HTTP/REST API the Controller implements/provides.

@api can be applied to controller classes.

Signature:

export declare function api(spec: Partial<ControllerSpec>): ClassDecorator;

Parameters

Parameter Type Description
spec Partial<ControllerSpec> OpenAPI specification describing the endpoints handled by this controller

Returns:

ClassDecorator

Example

@api({basePath: '/my'})
class MyController {
  // ...
}