Skip to content

Set up OpenAPI

Add an OpenAPI file, and Specly builds a page for every endpoint.

2 min read

Updated

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 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.

Put the file in your docs folder, then add openapi to a group or tab in docs.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:

docs.json
{
"api": { "openapi": "openapi.yaml" }
}
openapistring | string[]path

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.openapistring | string[]path

The spec used wherever a navigation node names none.

api.baseUrlstring | string[]path

The server to use when a spec has no servers of its own. Must start with http:// or https://.

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

summarystringpath

The page’s title and its sidebar label. Without one, the title is the method and path.

descriptionstringpath

Markdown shown under the title. Raw HTML in it is shown as text, and unsafe links are dropped.

tagsstring[]path

The first tag names the sub-group in the sidebar.

serversobject[]path

The address requests go to. The first server is the one examples and Try it use.

exampleanypath

What the page shows for a request or response. Without one, Specly makes one from the schema.

x-codeSamplesobject[]path

Your own request samples, each with lang, label and source. They come before the generated ones.

x-hiddenbooleanpath

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.

deprecatedbooleanpath

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.

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.

Was this page helpful?

Report a problem

What’s the problem?

The docs team sees this. Other readers don’t.