- Documentation
- API reference
- Set up OpenAPI
Set up OpenAPI
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 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
Section titled “Add the spec”Put the file in your docs folder, then add openapi to a group or tab in 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:
{ "api": { "openapi": "openapi.yaml" }}openapistring | 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.openapistring | string[]The spec used wherever a navigation node names none.
api.baseUrlstring | string[]The server to use when a spec has no
serversof its own. Must start withhttp://orhttps://.
What the spec controls
Section titled “What the spec controls”Specly writes each page from the spec, so the page is only as good as the spec.
summarystringThe page’s title and its sidebar label. Without one, the title is the method and path.
descriptionstringMarkdown shown under the title. Raw HTML in it is shown as text, and unsafe links are dropped.
tagsstring[]The first tag names the sub-group in the sidebar.
serversobject[]The address requests go to. The first server is the one examples and Try it use.
exampleanyWhat the page shows for a request or response. Without one, Specly makes one from the schema.
x-codeSamplesobject[]Your own request samples, each with
lang,labelandsource. They come before the generated ones.
x-hiddenbooleanLeaves the operation out of the generated pages.
x-excludeddoes the same. Use it for an operation you want to document by hand, as in Hand-written endpoint pages.
deprecatedbooleanMarks 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
Section titled “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.