Skip to content

Commit 1f2d40e

Browse files
feat(docs): add API Reference config documentation (#4379)
* progress so far * update docs * paginated docs * add fix * remove words * API reference docs update --------- Co-authored-by: Danny Sheridan <83524670+dannysheridan@users.noreply.github.com>
1 parent 7be85ab commit 1f2d40e

30 files changed

+310
-112
lines changed

fern/docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ navigation:
273273

274274
- section: API References
275275
contents:
276-
- page: Generate API reference
276+
- page: Generate API Reference
277277
icon: fa-regular fa-gear-code
278278
path: ./pages/fern-docs/content/generate-api-ref.mdx
279279
slug: generate-api-ref
@@ -283,9 +283,9 @@ navigation:
283283
- page: Endpoint errors
284284
icon: fa-regular fa-exclamation-triangle
285285
path: ./pages/fern-docs/config/endpoint-errors.mdx
286-
- page: Reorder API Reference pages
286+
- page: Customize API Reference layout
287287
icon: fa-regular fa-arrow-up-arrow-down
288-
path: ./pages/fern-docs/content/reorder-api-ref.mdx
288+
path: ./pages/fern-docs/content/customize-api-ref.mdx
289289
- page: Write markdown in API Reference
290290
icon: fa-regular fa-pencil
291291
path: ./pages/fern-docs/content/api-ref-content.mdx

fern/pages/api-definition/fern-definition/api-yml/overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ name: api
2828
2929
## API description
3030
31-
You can define a top level API description. This description will come through in the OpenAPI spec and Postman collection.
31+
You can define a top level API description. This description will come through in the OpenAPI Specification and Postman collection.
3232
3333
<CodeBlock title="api.yml">
3434
```yaml {2-4}

fern/pages/api-definition/fern-definition/audiences.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Audiences in Fern Definition
33
subtitle: Use audiences in your Fern Definition to segment your API for different groups of consumers.
44
---
55

6-
Audiences are a useful tool for segmenting your API for different consumers. You can configure your Fern Docs to publish documentation specific to an `Audience`. You can use [audiences in your OpenAPI specification](/learn/api-definition/openapi/extensions#audiences), too.
6+
Audiences are a useful tool for segmenting your API for different consumers. You can configure your Fern Docs to publish documentation specific to an `Audience`. You can use [audiences in your OpenAPI Specification](/learn/api-definition/openapi/extensions#audiences), too.
77

88
Common examples of audiences include:
99

fern/pages/api-definition/fern-definition/examples.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Examples in Fern Definition
3-
subtitle: Use Fern Definition to add API examples that are shown in comments of SDKs, API reference documentation, and a Postman collection.
3+
subtitle: Use Fern Definition to add API examples that are shown in comments of SDKs, API Reference documentation, and a Postman collection.
44
---
55

66
You can add examples for types and endpoints. Examples are shown as

fern/pages/api-definition/introduction/what-is-an-api-definition.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Fern integrates with several API definition formats:
1717
Formerly known as Swagger, [OpenAPI](https://swagger.io/specification/) is the most popular API definition format.
1818
OpenAPI can be used to document RESTful APIs and is defined in a YAML or JSON file.
1919

20-
Check out an example OpenAPI spec for the Petstore API [here](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
20+
Check out an example OpenAPI Specification for the Petstore API [here](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
2121

2222
```yaml maxLines={0}
2323
openapi: 3.0.2
@@ -218,7 +218,7 @@ Fern integrates with several API definition formats:
218218
## Why create an API Definition ?
219219
220220
Once you have an API definition, Fern will use it as an input to generate artifacts
221-
like SDKs and API reference documentation. Every time you update the API definition,
221+
like SDKs and API Reference documentation. Every time you update the API definition,
222222
you can regenerate these artifacts and ensure they are always up-to-date.
223223
224224
<CardGroup cols={2}>

fern/pages/api-definition/introduction/what-is-the-fern-folder.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ fern/
1818
└─ imdb.yml
1919
```
2020

21-
If you want to intialize Fern with an OpenAPI spec, run `fern init --openapi path/to/openapi` instead.
22-
```bash
21+
If you want to intialize Fern with an OpenAPI Specification, run `fern init --openapi path/to/openapi` instead.
22+
```yaml
2323
fern/
2424
├─ fern.config.json
2525
├─ generators.yml

fern/pages/api-definition/openapi/extensions/others.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,11 @@ shown in the third tab.
472472

473473
## Embedding extensions
474474

475-
If instead of overlaying your extensions within an overrides file, as mentioned above. Certain frameworks that generate OpenAPI specs make it easy to embed extensions directly from code.
475+
If instead of overlaying your extensions within an overrides file, as mentioned above. Certain frameworks that generate OpenAPI Specifications make it easy to embed extensions directly from code.
476476

477477
### FastAPI
478478

479-
Please view our page on [FastAPI](/learn/api-definition/openapi/frameworks/fastapi) for more information on how to extend your OpenAPI spec within FastAPI.
479+
Please view our page on [FastAPI](/learn/api-definition/openapi/frameworks/fastapi) for more information on how to extend your OpenAPI Specification within FastAPI.
480480

481481
## Request + response examples
482482

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
title: Use OpenAPI for your API definition
3-
description: An overview of how to define your API using an OpenAPI specification, then use Fern to generate SDKs and API reference documentation for the API.
3+
description: An overview of how to define your API using an OpenAPI Specification, then use Fern to generate SDKs and API Reference documentation for the API.
44
---
55

6-
Fern supports the use of the [OpenAPI specification](https://www.openapis.org/) (up to and including version 3.1) to define APIs. Alternatively, you can use Fern's simpler format called [Fern Definition](/learn/api-definition/fern/overview).
6+
Fern supports the use of the [OpenAPI Specification](https://www.openapis.org/) (up to and including version 3.1) to define APIs. Alternatively, you can use Fern's simpler format called [Fern Definition](/learn/api-definition/fern/overview).
77

8-
Fern generates SDKs and API reference documentation from your OpenAPI spec. Get started by creating a `fern/` project through one of our [Quickstarts](/learn/docs/getting-started/quickstart), then replace the file in the `fern/openapi/` folder with your own. You can use either JSON or YAML for your file.
8+
Fern generates SDKs and API Reference documentation from your OpenAPI Specification. Get started by creating a `fern/` project through one of our [Quickstarts](/learn/docs/getting-started/quickstart), then replace the file in the `fern/openapi/` folder with your own. You can use either JSON or YAML for your file.
99

10-
Run `fern check` to validate the OpenAPI spec. Resolve any errors.
10+
Run `fern check` to validate the OpenAPI Specification. Resolve any errors.
1111
Having trouble? Reach out in the [Fern Discord server](https://discord.com/invite/JkkXumPzcG).
1212

1313
If you're having trouble understanding the errors, run the command [`fern write-definition`](/learn/cli-api/cli-reference/commands#fern-write-definition).
14-
This command will convert your OpenAPI spec into a Fern Definition.
14+
This command will convert your OpenAPI Specification into a Fern Definition.
1515

1616
If there are no errors, you can run [fern generate](/learn/cli-api/cli-reference/commands#fern-generate) to generate SDKs or [fern generate --docs](/learn/cli-api/cli-reference/commands#fern-generate) to generate docs.

fern/pages/api-definition/openapi/overrides.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ title: How to use OpenAPI Overrides
33
subtitle: Use overrides to customize user-facing documentation fields, examples, and naming.
44
---
55

6-
When you generate your OpenAPI from server code, you may want to further customize portions of your OpenAPI spec. You can do this with OpenAPI Overrides. When you run `fern generate`, Fern will automatically apply these overrides on top of your OpenAPI spec.
6+
When you generate your OpenAPI from server code, you may want to further customize portions of your OpenAPI Specification. You can do this with OpenAPI Overrides. When you run `fern generate`, Fern will automatically apply these overrides on top of your OpenAPI Specification.
77

88
## How to use OpenAPI Overrides
99

10-
To use OpenAPI Overrides, create a file named `openapi-overrides.yml`. You can put the file anywhere in your project. This file contains the overrides you want to apply to your OpenAPI spec. For more on the extensions available, visit our page on [OpenAPI Extensions](https://buildwithfern.com/learn/api-definition/openapi/extensions).
10+
To use OpenAPI Overrides, create a file named `openapi-overrides.yml`. You can put the file anywhere in your project. This file contains the overrides you want to apply to your OpenAPI Specification. For more on the extensions available, visit our page on [OpenAPI Extensions](https://buildwithfern.com/learn/api-definition/openapi/extensions).
1111

1212
### Example
1313

fern/pages/api-definition/openapi/server-frameworks/fastapi.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: FastAPI Instrumentation
3-
description: Learn about best practices for creating rich OpenAPI specs when instrumenting FastAPI applications.
3+
description: Learn about best practices for creating rich OpenAPI Specifications when instrumenting FastAPI applications.
44
---
55

66
[FastAPI](https://fastapi.tiangolo.com/) is a popular Python web framework developed by [tiangolo](https://github.com/tiangolo).
@@ -9,38 +9,38 @@ The offering brands itself as
99

1010
> FastAPI is a modern, fast (high-performance), web framework for building APIs with Python based on standard Python type hints.
1111
12-
FastAPI plays very nicely with Fern because it has the power to output OpenAPI specs! Below we'll outline some tips for generating a rich OpenAPI with FastAPI.
12+
FastAPI plays very nicely with Fern because it has the power to output OpenAPI Specifications! Below we'll outline some tips for generating a rich OpenAPI with FastAPI.
1313

1414

1515
## OpenAPI generation
1616

17-
By default, FastAPI will generate an OpenAPI spec for you based on your routes and your data models! You can access this spec by visiting `/docs` on your FastAPI server.
17+
By default, FastAPI will generate an OpenAPI Specification for you based on your routes and your data models! You can access this spec by visiting `/docs` on your FastAPI server.
1818

19-
If you are not seeing any OpenAPI spec (or the Swagger UI), you may need to review your FastAPI server configuration as the path may have been changed, or completely omitted.
19+
If you are not seeing any OpenAPI Specification (or the Swagger UI), you may need to review your FastAPI server configuration as the path may have been changed, or completely omitted.
2020

2121
```python {6-8}
2222
from fastapi import FastAPI
2323

2424
...
2525

2626
FastAPI(
27-
openapi_url="/openapi.json", # <-- this is the file and URL needed to access the OpenAPI spec, `docs_url` and `redoc_url` are convenient wrappers that display the file in a UI!
28-
docs_url="/docs", # <-- this is the URL to access the Swagger UI, which will point to your OpenAPI spec
29-
redoc_url="/redoc" # <-- this is the URL to access the ReDoc UI, which will point to your OpenAPI spec
27+
openapi_url="/openapi.json", # <-- this is the file and URL needed to access the OpenAPI Specification, `docs_url` and `redoc_url` are convenient wrappers that display the file in a UI!
28+
docs_url="/docs", # <-- this is the URL to access the Swagger UI, which will point to your OpenAPI Specification
29+
redoc_url="/redoc" # <-- this is the URL to access the ReDoc UI, which will point to your OpenAPI Specification
3030
)
3131
```
3232

3333
## Specifying servers
3434

35-
Fern will automatically generate clients that point to the servers you configure within your OpenAPI spec, so it's important to specify the servers that your API will be hosted on.
35+
Fern will automatically generate clients that point to the servers you configure within your OpenAPI Specification, so it's important to specify the servers that your API will be hosted on.
3636

3737
```python {5}
3838
from fastapi import FastAPI
3939

4040
...
4141

4242
app = FastAPI(servers=[{"url": "http://prod.test.com", "description": "Production server"}])
43-
# This creates the following server object in your OpenAPI spec:
43+
# This creates the following server object in your OpenAPI Specification:
4444
# "servers":[{"url":"http://prod.test.com","description":"Production server"}],
4545
```
4646

@@ -52,7 +52,7 @@ Below, we've annotated a "good" route within FastAPI that has it's typings as we
5252
```python {5-9}
5353
@router.post(
5454
"/your/post/endpoint",
55-
response_model=YourResponseModel, # <-- with FastAPI, it is important to specify your response model so that it comes through to the OpenAPI spec
55+
response_model=YourResponseModel, # <-- with FastAPI, it is important to specify your response model so that it comes through to the OpenAPI Specification
5656
summary="Get some response for your req", # <-- if you'd like to add a description to your endpoint, you can do so here
5757
openapi_extra={ # <-- finally, you can add in your Fern extensions here, these extensions will produce SDK code that looks something like: `client.endpoints.create(...)` in python
5858
"x-fern-sdk-method-name": "create",
@@ -89,4 +89,4 @@ class MyObject(BaseModel):
8989

9090
## Additional customization
9191

92-
FastAPI has a lot of flexibility in how you can customize your OpenAPI spec. Please refer to the [FastAPI documentation](https://fastapi.tiangolo.com/how-to/extending-openapi/#modify-the-openapi-schema) for more information.
92+
FastAPI has a lot of flexibility in how you can customize your OpenAPI Specification. Please refer to the [FastAPI documentation](https://fastapi.tiangolo.com/how-to/extending-openapi/#modify-the-openapi-schema) for more information.

0 commit comments

Comments
 (0)