---
lang: en
title: 'API docs: rest.restapplication.api'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.rest.restapplication.api.html
---

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

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

## RestApplication.api() method

Set the OpenAPI specification that defines the REST API schema for this application. 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).

<b>Signature:</b>

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

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  spec | <code>OpenApiSpec</code> | The OpenAPI specification, as an object. |

<b>Returns:</b>

`Binding`

Binding for the api spec


