@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
77 lines (42 loc) • 1.3 kB
Markdown
---
lang: en
title: 'API docs: openapi-v3.api'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/openapi-v3
permalink: /doc/en/lb4/apidocs.openapi-v3.api.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/openapi-v3](./openapi-v3.md) > [api](./openapi-v3.api.md)
## 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:**
```typescript
export declare function api(spec: Partial<ControllerSpec>): ClassDecorator;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td markdown="1">
spec
</td><td markdown="1">
Partial<[ControllerSpec](./openapi-v3.controllerspec.md)<!-- -->>
</td><td markdown="1">
OpenAPI specification describing the endpoints handled by this controller
</td></tr>
</tbody></table>
**Returns:**
ClassDecorator
## Example
```ts
@api({basePath: '/my'})
class MyController {
// ...
}
```