Skip to content

Commit bf62f9c

Browse files
authored
(docs, api definitions) Document how to specify section display names in API Reference (#1090)
1 parent 29c82a7 commit bf62f9c

File tree

5 files changed

+65
-14
lines changed

5 files changed

+65
-14
lines changed

fern/products/api-def/api-def.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ navigation:
5858
- page: SDK method names
5959
path: ./openapi-pages/extensions/method-names.mdx
6060
slug: method-names
61+
- page: Tag display names
62+
path: ./openapi-pages/extensions/tag-display-name.mdx
6163
- page: Parameter names
6264
path: ./openapi-pages/extensions/parameter-names.mdx
6365
- page: Property names

fern/products/api-def/ferndef-pages/endpoints.mdx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Each service defines:
2727
To define a service with an empty base path use the empty string: `base-path: ""`
2828
</Info>
2929

30+
### Section display name
31+
32+
By default, section names in your API Reference come from service file names (e.g., `user.yml` becomes "User"). To override the display name of a section, [use the `section` property in your `docs.yml`](/docs/api-references/customize-api-reference-layout#renaming-sections).
33+
3034
## Endpoints
3135

3236
An endpoint includes:
@@ -41,7 +45,7 @@ An endpoint includes:
4145
- **Successful (200) response** information _(Optional)_
4246
- **Error (non-200) responses** that this endpoint might return _(Optional)_
4347

44-
## URL path
48+
### URL path
4549

4650
Each endpoint has a URL path.
4751

@@ -63,7 +67,7 @@ The full path for the endpoint is the concatenation of:
6367
- The service `base-path`
6468
- The endpoint `path`
6569

66-
## Display name
70+
### Endpoint display name
6771

6872
The display name will appear as the title of an endpoint. By default, the display name is equal to the 'Title Case' of the endpoint name. If you would like to customize the endpoint name, you can **set the display name**.
6973

@@ -82,7 +86,7 @@ service:
8286
```
8387
</CodeBlock>
8488

85-
## Path parameters
89+
### Path parameters
8690

8791
Supply path parameters for your endpoints to create dynamic URLs.
8892

@@ -114,7 +118,7 @@ Services can also have path-parameters:
114118
```
115119
</CodeBlock>
116120

117-
## Query parameters
121+
### Query parameters
118122

119123
Each endpoint can specify query parameters:
120124

@@ -135,7 +139,7 @@ service:
135139
```
136140
</CodeBlock>
137141

138-
### `allow-multiple`
142+
#### `allow-multiple`
139143

140144
Use `allow-multiple` to specify that a query parameter is allowed
141145
multiple times in the URL, as in `?filter=jane&filter=smith`. This will alter
@@ -152,7 +156,7 @@ parameter.
152156
```
153157
</CodeBlock>
154158

155-
## Auth
159+
### Auth
156160

157161
Each endpoint can override the auth behavior specified in the service.
158162

@@ -171,7 +175,7 @@ Each endpoint can override the auth behavior specified in the service.
171175
```
172176
</CodeBlock>
173177

174-
## Headers
178+
### Headers
175179

176180
Each endpoint can specify request headers:
177181

@@ -213,7 +217,7 @@ Services can also specify request headers. These headers will cascade to the ser
213217
```
214218
</CodeBlock>
215219

216-
## Request body
220+
### Request body
217221

218222
Endpoints can specify a request body type.
219223

@@ -232,7 +236,7 @@ service:
232236
```
233237
</CodeBlock>
234238

235-
### Inlining a request body
239+
#### Inlining a request body
236240

237241
If the request body is an object, you can **inline the type declaration**. This
238242
makes the generated SDKs a bit more idiomatic.
@@ -255,7 +259,7 @@ makes the generated SDKs a bit more idiomatic.
255259
```
256260
</CodeBlock>
257261

258-
## Success response
262+
### Success response
259263

260264
Endpoints can specify a `response`, which is the type of the body that will be
261265
returned on a successful (200) call.
@@ -279,7 +283,7 @@ types:
279283
```
280284
</CodeBlock>
281285

282-
## Response status codes
286+
### Response status codes
283287

284288
You can also use the `status-code` field to specify a custom status code
285289
for a success response.
@@ -306,7 +310,7 @@ types:
306310
```
307311
</CodeBlock>
308312

309-
## Error responses
313+
### Error responses
310314

311315
Endpoints can specify error responses, which detail the non-200 responses that
312316
the endpoint might return.
@@ -453,7 +457,7 @@ the request body, path parameters, query parameters, headers, and response body.
453457
```
454458
</CodeBlock>
455459
456-
### Failed examples
460+
#### Failed examples
457461
458462
You can also specify examples of failed endpoints calls. Add the `error`
459463
property to a response example to designate which failure you're demonstrating.
@@ -490,7 +494,7 @@ errors:
490494
```
491495
</CodeBlock>
492496
493-
### Referencing examples from types
497+
#### Referencing examples from types
494498
495499
To avoid duplication, you can reference examples from types using `$`.
496500

fern/products/api-def/openapi-pages/extensions/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The table below shows all available extensions and links to detailed documentati
1818
| [`x-fern-bearer`](/api-definitions/openapi/authentication#bearer-security-scheme) | Customize bearer authentication parameter names and environment variables |
1919
| [`x-fern-availability`](./availability) | Mark availability status (beta, generally-available, deprecated) |
2020
| [`x-fern-base-path`](./base-path) | Set base path prepended to all endpoints |
21+
| [`x-displayName`](./tag-display-names) | Specify how tag names display in your API Reference |
2122
| [`x-fern-enum`](./enum-descriptions-and-names) | Add descriptions and custom names to enum values |
2223
| [`x-fern-examples`](./request-response-examples) | Associate request and response examples |
2324
| [`x-fern-global-headers`](./global-headers) | Configure headers used across all endpoints |
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Tag display names
3+
description: Customize how tag names appear in your API Reference using the `x-displayName` extension
4+
---
5+
6+
By default, tag names from your OpenAPI specification become section names in your API Reference. Use the `x-displayName` extension to control how these section names display in your generated documentation. This is helpful for controlling capitalization and creating user-friendly names.
7+
8+
You can set display names directly in your spec or in an overrides file.
9+
10+
```yaml title="openapi.yml"
11+
tags:
12+
- name: task
13+
x-displayName: Tasks
14+
- name: billing-and-payments
15+
x-displayName: Billing and Payments
16+
```
17+
18+
<Note>
19+
Alternatively, you can rename sections directly in your [`docs.yml` file](/docs/api-references/customize-api-reference-layout).
20+
</Note>

fern/products/docs/pages/api-references/customize-api-ref.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,30 @@ To reference an endpoint, you can use either:
9696

9797
## Customizing the API Reference
9898

99+
### Renaming sections
100+
101+
By default, section display names come from [service file names](/api-definition/fern/endpoints#service-definition) (Fern
102+
Definition) or tag names (OpenAPI) in your spec.
103+
104+
To override the display name of a section, use the `section` property in your `docs.yml` and reference the `lowerCamelCase` version of the original service file name (Fern Definition) or tag name (OpenAPI) in `referenced-packages`.
105+
106+
```yaml title="docs.yml" {4-6}
107+
navigation:
108+
- api: API Reference
109+
layout:
110+
- section: "Billing" # New section display name
111+
referenced-packages:
112+
- billing # lowerCamelCase version of original tag/service file name from your spec
113+
contents: []
114+
- section: "Bank Accounts"
115+
referenced-packages:
116+
- bankAccounts
117+
contents: []
118+
```
119+
<Note>
120+
For OpenAPI, you can alternatively customize tag display names directly in your spec (or `overrides.yml` file) using the [`x-displayName` extension](/api-definitions/openapi/extensions/tag-display-names).
121+
</Note>
122+
99123
### Flattening sections
100124
To remove the API Reference title and display the section contents, set `flattened` to `true`.
101125

0 commit comments

Comments
 (0)