# contractdiff/openapi

> Every export of contractdiff/openapi, with its signature and doc comment: OpenApiError, detect, read, openapi.

Source: https://contractdiff.interlace.tools/docs/api/openapi

<!-- Generated by scripts/api-reference.ts from the built dist/*.d.ts. Do not edit; run `npx tsx scripts/api-reference.ts`. -->

The OpenAPI input format (spec.md R1, R2): an OpenAPI 3.0, 3.1 or 3.2 document read into the
model. It imports only `contractdiff/core`, and the core never imports it.

```ts
import { OpenApiError, detect, read, … } from 'contractdiff/openapi';
```

## Classes

### OpenApiError

A document this adapter does not read. The message ends in a `fix:` line.

```ts
class OpenApiError extends Error {
    constructor(reason: string, fix: string);
}
```

## Constants

### detect

Whether `document` declares itself as OpenAPI 3.x.

```ts
const detect: (document: unknown) => boolean;
```

### openapi

The adapter as the plugin host will register it (spec.md R-PL1).

```ts
const openapi: Readonly<{
    name: "openapi";
    description: "OpenAPI 3.0, 3.1 and 3.2 documents, including webhooks";
    detect: (document: unknown) => boolean;
    read: (document: unknown) => Contract;
}>;
```

### read

Read an OpenAPI 3.x document into the model.

```ts
const read: (document: unknown) => Contract;
```
