---
lang: en
title: 'API docs: rest.restapplication.exportopenapispec'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/strongloop/loopback-next/tree/master/packages/rest
permalink: /doc/en/lb4/apidocs.rest.restapplication.exportopenapispec.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; [exportOpenApiSpec](./rest.restapplication.exportopenapispec.md)

## RestApplication.exportOpenApiSpec() method

Export the OpenAPI spec to the given json or yaml file

<b>Signature:</b>

```typescript
exportOpenApiSpec(outFile?: string, log?: {
        (...data: any[]): void;
        (message?: any, ...optionalParams: any[]): void;
    }): Promise<void>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  outFile | string | File name for the spec. The extension of the file determines the format of the file. - <code>yaml</code> or <code>yml</code>: YAML - <code>json</code> or other: JSON If the outFile is not provided or its value is <code>''</code> or <code>'-'</code>, the spec is written to the console using the <code>log</code> function. |
|  log | { (...data: any\[\]): void; (message?: any, ...optionalParams: any\[\]): void; } | Log function, default to <code>console.log</code> |

<b>Returns:</b>

Promise&lt;void&gt;


