Skip to navigation

Customize API Reference layout

View as Markdown

When you include an API in your docs.yml file, you can customize how the endpoints and sections are displayed in the sidebar navigation. By default, the reference will generate a navigation hierarchy based on the structure of the API spec, but several customizations can be configured.

API Sections

For OpenAPI specifications, sections are created based on the tags property, converted to lowerCamelCase convention (e.g., createUser).

If you would like to only display a subset of endpoints, read more about the Audiences property for OpenAPI specifications.

Ordering the API Reference

Alphabetizing endpoints and sections

To sort all sections and endpoints alphabetically, unless explicitly ordered in layout, set alphabetized to true.

docs.yml
navigation:
- api: API Reference
alphabetized: true

Sorting endpoints by availability

To order endpoints by their availability, unless explicitly ordered in layout, set sort-by-availability to a list of availability values. Endpoints are sorted within each section.

Listed values come first, in the order you provide. Any values you leave out follow in the default order:

  1. unset (no availability set)
  2. generally-available
  3. alpha
  4. beta
  5. preview
  6. legacy
  7. deprecated

Example:

docs.yml
navigation:
- api: API Reference
sort-by-availability:
- beta
- deprecated

In the example above, endpoints appear in this order: beta, deprecated, unset, generally-available, alpha, preview, legacy. Endpoints with the same availability keep their existing order. To sort them alphabetically, also set alphabetized: true.

For example, take a section with these endpoints, using alphabetized: true and sort-by-availability: [beta, deprecated]:

Final positionEndpointAvailability
1Graft plantbeta
2Repot plantbeta
3Compost plantdeprecated
4Water plantdeprecated
5Harvest plantunset
6List plantsunset
7Create plantgenerally-available
8Prune plantalpha
9Mist plantpreview
10Fertilize plantlegacy

The two listed values, beta and deprecated, come first. The rest follow in the default order, without beta and deprecated. Within each availability, endpoints are alphabetical.

To control where endpoints without an availability appear, include unset in the list. For example, [beta, unset] puts beta endpoints first, then endpoints with no availability.

Ordering top-level sections

The layout option allows you to specify the order of sub-packages, sections, endpoints, and pages at the top level of your API Reference.

docs.yml
navigation:
- api: API Reference
layout:
- POST /user
- user
- store
- plant

If your API uses namespaces, prefix the endpoint with the namespace and :::

docs.yml
navigation:
- api: API Reference
layout:
- payments::POST /user
- user
- store
Ordered API Reference

Ordering section contents

You can reference an endpoint using the format METHOD /path.

docs.yml
navigation:
- api: API Reference
layout:
- user:
- POST /user
- PUT /user/{username}
- DELETE /user/{username}
Content ordered in the API Reference

Ordering properties within a schema

The layout option orders sections, endpoints, and pages, but not the properties within a request, response, or schema. Property order follows a fixed set of rules:

  1. Required properties render before optional ones. A property is required when its name appears in the schema’s required array, regardless of its position in the properties block.
  2. Within each group, properties follow their definition order in the properties block. To reorder properties within a group, reorder them in your API definition.

    Schemas composed with allOf are an exception: their properties sort alphabetically within each group instead of by definition order. To keep definition order, inline the composed properties by setting inline-all-of-schemas to true in generators.yml. A oneOf nested inside an allOf renders as one object of optional properties instead of a variant selector unless preserve-one-of-in-all-of is enabled.

  3. Deprecated properties render after non-deprecated ones within each group.

Required and optional properties always render as separate groups. You can’t mix the two or set an arbitrary order across them.

Customizing the API Reference

Nested object fields

Nested object fields render as indented branches with a connector line and a breadcrumb showing each field’s full path. To render them as bordered cards instead, set layout.api-reference-layout to cards. The setting applies site-wide.

docs.yml
layout:
api-reference-layout: cards

Renaming sections

By default, section display names come from tag names in your OpenAPI spec.

To override the display name of a section, use the section property in your docs.yml.

docs.yml
navigation:
- api: API Reference
layout:
- section: "Billing" # New section display name
referenced-packages:
- billing # lowerCamelCase version of original tag name from your spec
contents: []
- section: "Bank Accounts"
referenced-packages:
- bankAccounts
contents: []

You can alternatively customize tag display names directly in your spec (or overlays file) using the x-displayName extension.

Flattening sections

To remove the API Reference title and display the section contents, set flattened to true.

docs.yml
navigation:
- api: API Reference
flattened: true
Flattened API Reference

Paginating endpoints

By default, the API Reference renders as a single long-scrolling page containing every endpoint. Set paginated to true to split it into one page per endpoint instead.

docs.yml
navigation:
- api: API Reference
paginated: true

paginated controls page layout only. It’s unrelated to endpoint pagination, which navigates through a response using cursors or offsets and requires no docs.yml configuration.

Documenting standalone types

By default, the API Reference only documents a schema inline on the pages of the endpoints, webhooks, and WebSockets that reference it. A schema that no operation references doesn’t appear anywhere, so a spec whose value lives in its schemas (for example, a paths: {} document of XML element schemas, or shared models and event payloads never wired to an operation) renders nothing. Set types to true to give each of those schemas its own page.

docs.yml
navigation:
- api: API Reference
types: true

Fern adds a Types section as the last section of the API Reference, with one page per unreferenced schema sorted by title, at <api-reference>/types/<type-name>. Schemas that an operation references, directly or through another schema, stay inline on that operation’s page, and enums or objects declared inline inside another schema stay nested on their parent’s page.

Each type page lists the schema’s properties, enum values, or union variants, and shows an example in the side panel. For an OpenAPI object schema, the example is the schema’s first example or examples entry. A schema without one gets an example assembled from its properties’ example values, but only when every required property has an example. Otherwise, the example uses placeholder values.

openapi.yml
components:
schemas:
Say:
type: object
xml:
name: Say
properties:
voice:
type: string
xml:
attribute: true
message:
type: string
example:
voice: alice
message: Thanks for calling.

Types with XML encoding metadata (the OpenAPI xml object or x-fern-xml-text) get an XML example; all other types get a JSON example. An XML example built from a schema example writes only the properties the example sets and one element per list item, rendering each item of a oneOf list as the variant it matches. Type pages are included in search, llms.txt, and the Markdown version of each page.

If the API Reference also includes a GraphQL schema, which has its own Types section, the standalone section is titled Schemas and lives at <api-reference>/schemas/<type-name> instead.

Styling endpoints

To customize the display of an endpoint, you can add a title. You can also use slug to customize the endpoint URL.

docs.yml
navigation:
- api: API Reference
layout:
- user:
- endpoint: POST /user
title: Create a User
slug: user-creation
- DELETE /user/{username}
Setting an endpoint title

Hiding endpoints

You can hide an endpoint from the API Reference by setting hidden to true. The endpoint will still be accessible at its URL but is automatically excluded from search engine indexing (noindex), so you don’t need to set noindex.

docs.yml
navigation:
- api: API Reference
layout:
- user:
- endpoint: POST /user
title: Create a User
slug: user-creation
- endpoint: DELETE /user/{username}
hidden: true

Setting API Explorer options

The playground property sets four API Explorer options: oauth enables the OAuth client-credentials flow, environments restricts which server environments are available (an empty list disables the Explorer), send-optional-defaults pre-fills and sends the declared defaults of optional parameters, and hidden: true hides the Try it button for every endpoint under the API reference (the Explorer isn’t shown at all). Set it on the - api entry to apply a default across all endpoints, then override it on a section or endpoint in layout:

docs.yml
navigation:
- api: API Reference
playground: # Defaults for every endpoint in this API
oauth: true
environments:
- Production
- Sandbox
send-optional-defaults: true
hidden: false
layout:
- section: Auth
playground:
oauth: true # Override for this section
contents:
- endpoint: POST /token
playground:
oauth: false # Override for this endpoint

To hide the Try it button across an entire API section:

docs.yml
navigation:
- api: API Reference
playground:
hidden: true

Environment names are the server names from your API definition.

Adding custom sections

You can add arbitrary folders in the sidebar by adding a section to your API Reference layout. A section can comprise entire groups of endpoints, individual endpoints, or even just Markdown pages. Sections can be customized by adding properties like a icon, summary, slug (or skip-slug), availability, and contents.

docs.yml
navigation:
- api: API Reference
layout:
- section: My Section
icon: flower
contents:
- PUT /user/{username}
- plant
- plantInfo # tag names are converted to camelCase convention
Custom section in the API Reference

Adding a section overview

You can add overview pages to your API Reference or individual sections in two ways:

The summary property allows you to add an .md or .mdx page as an overview.

docs.yml
navigation:
- api: API Reference
summary: pages/api-overview.mdx
layout:
- user:
summary: pages/user-overview.mdx

If you’re using an OpenAPI spec, set tag-description-pages: true to use tag descriptions as summary pages for each section.

docs.yml
navigation:
- api: API Reference
tag-description-pages: true

If you enable tag-description-pages: true and manually specify a summary for a section, the manual summary will take precedence.

API Reference with a summary page

You can add regular pages and external links within your API Reference.

docs.yml
navigation:
- api: API Reference
layout:
- user:
contents:
- page: User Guide
path: ./docs/pages/user-guide.mdx
- link: Link Title
href: http://google.com

Adding availability

You can set the availability for the entire API Reference or for specific sections. Options are: stable, generally-available, in-development, pre-release, deprecated, or beta.

docs.yml
navigation:
- api: API Reference
availability: generally-available
layout:
- section: My Section
availability: beta
icon: flower
contents:
# endpoints here

When you set availability for a section, all endpoints in that section will inherit the section-level availability unless explicitly overridden in your API definition.

Non-default availability renders as a badge in the sidebar navigation next to the section or endpoint. The default available states (stable and generally-available) don’t render a sidebar badge.

You can’t set availability for individual OpenAPI endpoints in docs.yml — endpoint availability must be configured directly in your API definition. Learn more about availability for OpenAPI.

Displaying endpoint errors

Set display-errors to true to show error schemas on endpoint pages. The error names, status codes, and response objects are pulled from your API definition.

docs.yml
navigation:
- api: API Reference
display-errors: true

Endpoint errors

Clicking on an error expands it to show the error name, code, and object returned. The response also updates to show the error object.

Endpoint errors when expanded

Showing required scopes

Set show-scopes to true to list the scopes each endpoint requires in its Authentication section. Fern reads the scopes from the endpoint’s security requirements in your OpenAPI spec and shows them under the scheme that needs them, for example Required scopes: plants:read under the OAuth scheme. Schemes with no scopes, and endpoints with no security requirements, are unchanged. This option requires Fern CLI version 5.224.0 or later.

docs.yml
navigation:
- api: API Reference
show-scopes: true

With this security requirement, the endpoint’s Authentication section lists plants:write and garden:admin under oauth, and nothing extra under apiKey:

openapi.yml
paths:
/plants:
post:
security:
- oauth: [plants:write, garden:admin]
- apiKey: []

Configuration options reference

The following properties can be set on the - api entry in your docs.yml navigation.

alphabetized
boolean

When true, organizes all sections and endpoints in alphabetical order.

api
stringRequired

Title of the API Reference section.

audiences
list<string>

List of audiences that determines which endpoints, schemas, and properties are displayed in your API Reference.

availability
string

Set the availability status for the entire API Reference or specific sections.

display-errors
boolean

Displays error schemas on endpoint pages of your API Reference.

flattened
boolean

Displays all endpoints at the top level and hides the API Reference section title.

icon
string

Icon to display next to the API section in the navigation.

layout
list

Customize the order that your API endpoints are displayed in the docs site. See Ordering the API Reference for details.

paginated
boolean

When true, splits the API Reference into one page per endpoint instead of a single long-scrolling page (the default). Controls page layout only; unrelated to endpoint pagination.

show-scopes
boolean

When true, lists the scopes each endpoint requires under each scheme in the endpoint’s Authentication section, based on the endpoint’s security requirements. Defaults to false.

skip-slug
boolean

When true, skips slug generation for the API section.

slug
string

Customize the slug for the API section. By default, the slug is generated from the API title.

sort-by-availability
list<string>

Orders endpoints within each section by availability. Listed values come first, in the order provided, followed by the remaining values in the default order. Use unset for endpoints with no availability.

summary
string

Relative path to a Markdown file displayed at the top of the API section.

tag-description-pages
boolean

When true, uses OpenAPI tag descriptions as summary pages for each section.

types
boolean

When true, gives every schema that no endpoint, webhook, or WebSocket references its own page under a Types section at the end of the API Reference. Defaults to false.

playground
object

Settings for the API Explorer that affect all endpoints in this API section. Can also be set on individual sections or endpoints in layout to override.

playground.oauth
boolean

When true, enables the OAuth client-credentials flow in the API Explorer.

playground.environments
list<string>

Restricts which server environments are available in the API Explorer. An empty list disables the Explorer.

playground.send-optional-defaults
boolean

When true, pre-fills and sends the declared defaults of optional header, query, and path parameters. Defaults to false.

playground.hidden
boolean

When true, hides the Try it button for every endpoint in this API section. The API Explorer isn’t shown. Can also be set on individual sections or endpoints in layout to override.

api-name
string

Only used when your project has multiple APIs. The value must match the folder name containing the API definition. Don’t set this property if you only have a single API, as it will cause errors.

specs
list<object>

API specification files to load directly from docs.yml instead of through generators.yml. Each entry has a type (openapi, asyncapi, or graphql) and a path, plus optional overrides, overlays, and namespace. Paths are relative to the configuration file that contains them. When set, api-name is ignored.