---
title: "Set up OpenAPI"
description: "Add an OpenAPI file, and Specly builds a page for every endpoint."
---

Add your OpenAPI file to the docs folder and name it in `docs.json`. Specly builds a page for each operation, with its
parameters, request body, responses and request examples. [Specly's own API reference](/api-reference/introduction) is
built this way.

Specly reads OpenAPI 3.0 and 3.1, in JSON or YAML. A spec can be a file in your docs folder or an `https://` address.

## Add the spec

Put the file in your docs folder, then add `openapi` to a group or tab in `docs.json`:

```json docs.json
{
  "navigation": {
    "tabs": [
      {
        "tab": "API reference",
        "groups": [
          { "group": "Endpoints", "openapi": "openapi.yaml" }
        ]
      }
    ]
  }
}
```

A group with `openapi` and no `pages` lists every operation in the spec. Operations are grouped by their first tag, and
each tag becomes a sub-group. An operation with no tag goes straight in the group. Pages are built under
`api-reference/`.

To use one spec everywhere, set `api.openapi` once instead. Every group that has no spec of its own uses it:

```json docs.json
{
  "api": { "openapi": "openapi.yaml" }
}
```

- `openapi` (string | string[]): On a tab, group or other navigation node: the spec's path in your docs folder, or its `https://` address. A list uses
  several specs.

- `api.openapi` (string | string[]): The spec used wherever a navigation node names none.

- `api.baseUrl` (string | string[]): The server to use when a spec has no `servers` of its own. Must start with `http://` or `https://`.

## What the spec controls

Specly writes each page from the spec, so the page is only as good as the spec.

- `summary` (string): The page's title and its sidebar label. Without one, the title is the method and path.

- `description` (string): Markdown shown under the title. Raw HTML in it is shown as text, and unsafe links are dropped.

- `tags` (string[]): The first tag names the sub-group in the sidebar.

- `servers` (object[]): The address requests go to. The first server is the one examples and Try it use.

- `example` (any): What the page shows for a request or response. Without one, Specly makes one from the schema.

- `x-codeSamples` (object[]): Your own request samples, each with `lang`, `label` and `source`. They come before the generated ones.

- `x-hidden` (boolean): Leaves the operation out of the generated pages. `x-excluded` does the same. Use it for an operation you want to
  document by hand, as in [Hand-written endpoint pages](/api-docs/hand-written).

- `deprecated` (boolean): Marks the page and its sidebar entry as deprecated.

Fields that are `readOnly` are left out of the request body. Schemas that point to each other are followed, up to a depth
limit, past which a field shows its type without its children.

## What isn't built

Swagger 2 files aren't read, and webhooks aren't built. Specly warns in the build for each. Convert a Swagger 2 file to
OpenAPI 3 first.

To choose which operations get pages, and where, see [Endpoint pages and Try it](/api-docs/endpoint-pages).
