---
lang: en
title: 'API docs: rest.restserver.api'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/rest
permalink: /doc/en/lb4/apidocs.rest.restserver.api.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/rest](./rest.md) &gt; [RestServer](./rest.restserver.md) &gt; [api](./rest.restserver.api.md)

## RestServer.api() method

Set the OpenAPI specification that defines the REST API schema for this server. All routes, parameter definitions and return types will be defined in this way.

Note that this will override any routes defined via decorators at the controller level (this function takes precedent).

**Signature:**

```typescript
api(spec: OpenApiSpec): Binding;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

spec


</td><td>

[OpenApiSpec](./openapi-v3.openapispec.md)


</td><td>

The OpenAPI specification, as an object.


</td></tr>
</tbody></table>

**Returns:**

[Binding](./context.binding.md)

Binding for the spec


