# OpenAPI Support

Source: https://docs.interop.io/manager/open-api-support/index.html

## OpenAPI / Swagger

Available since io.Manager Server 2.0

**io.Manager** offers support for [OpenAPI 3.0.0](https://www.openapis.org/) via [Swagger UI](https://swagger.io/tools/swagger-ui/).

By default, the Swagger UI can be accessed at route `/swagger`.

The Swagger UI is enabled by default and can be configured via the configuration object for initializing the **io.Manager** Server, or via environment variables, depending on your [deployment](https://docs.interop.io/manager/deployment/index.md) approach.

### Environment Variables

To configure the Swagger UI, register the following environment variables with the proper values:

| Environment Variable | Description |
|----------------------|-------------|
| `API_OPEN_API_ENABLE_SWAGGER_UI` | If `true` (default), **io.Manager** will serve the Swagger UI. |
| `API_OPEN_API_SWAGGER_UI_ROUTE` | Route on which **io.Manager** will serve the Swagger UI. Defaults to `swagger`. |

The following example demonstrates configuring the Swagger UI route:

```cmd
API_OPEN_API_SWAGGER_UI_ROUTE=my-swagger-ui
```

### Configuration Object

To configure the Swagger UI, use the `openApi` top-level key of the optional `Config` object for initializing the **io.Manager** Server.

The following example demonstrates how to configure the Swagger UI route:

```javascript
import { start } from "@interopio/manager";

const config = {
    openApi: {
        swaggerUIRoute: "my-swagger-ui"
    }
};

const server = await start(config);
```

The `openApi` object has the following properties:

| Property | Type | Description |
|----------|------|-------------|
| `customSecurityScheme` | `object` | [`SecuritySchemeObject`](https://github.com/nestjs/swagger/blob/master/lib/interfaces/open-api-spec.interface.ts) object. If present and if a custom authenticator is used, will be set as the security scheme. This allows making requests via the Swagger UI when custom authentication is used. For more details, see the [OpenAPI specification](https://swagger.io/docs/specification/v3_0/authentication/). |
| `enableSwaggerUI` | `boolean` | If `true` (default), **io.Manager** will serve the Swagger UI. |
| `processOpenAPIObject` | `function` | Function with the following signature: `(doc: OpenAPIObject) => OpenAPIObject`. Providing this function enables you to gain full control over the OpenAPI document described by the [`OpenAPIObject`](https://github.com/nestjs/swagger/blob/master/lib/interfaces/open-api-spec.interface.ts) object. |
| `swaggerCustomOptions` | `object` | [`Partial<SwaggerCustomOptions>`](https://github.com/nestjs/swagger/blob/master/lib/interfaces/swagger-custom-options.interface.ts) object. Custom options for the Swagger UI. This will be merged into an object that will be passed as an argument to the `setup()` method of the [`SwaggerModule`](https://github.com/nestjs/swagger/blob/master/lib/swagger-module.ts) instance. |
| `swaggerUIRoute` | `string` | Route on which **io.Manager** will serve the Swagger UI. Defaults to `"swagger"`. |
