Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions fern/products/api-def/openapi/extensions/availability.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ description: Mark API endpoint availability in OpenAPI with `x-fern-availability
---


The `x-fern-availability` extension is used to mark the availability of an endpoint within your OpenAPI definition. The availability information propagates into the generated Fern Docs website as visual tags, SDKs, and [CLIs](/learn/cli-generator/get-started/openapi-extensions#availability-badges).

You can configure the `availability` of sections in your API Reference documentation in your [`docs.yml` file](/learn/docs/configuration/site-level-settings).
The `x-fern-availability` extension marks the availability of an endpoint within your OpenAPI definition. The availability information propagates into the generated Fern Docs website as visual tags, SDKs, and [CLIs](/learn/cli-generator/get-started/openapi-extensions#availability-badges).

## Endpoint

The options are:
Set `x-fern-availability` on an endpoint to one of the following values:

| Value | Description | Tag |
| --- | --- | --- |
Expand All @@ -31,12 +29,45 @@ paths:
x-fern-availability: deprecated
```

This renders as:
### API Reference output

The endpoint renders with the corresponding tag in your API Reference docs.

<Frame caption="A deprecated endpoint">
![Screenshot of API Reference endpoint with tag showing deprecated](https://fern-image-hosting.s3.amazonaws.com/fern/x-fern-availability-example.png)
</Frame>

### SDK output

Availability values propagate into [generated SDKs](/learn/sdks/deep-dives/sdk-user-features#availability) as doc comments on client methods (JSDoc in TypeScript, docstrings in Python, Javadoc in Java, etc.). IDEs surface these as warnings and strikethrough styling so SDK users see at a glance which endpoints to avoid.

```typescript title="Generated TypeScript SDK"
export class PetClient {
/** @deprecated */
public addPet( ... ): Promise<Pet> { ... }

/** @beta This endpoint is in pre-release and may change. */
public getPetById( ... ): Promise<Pet> { ... }
}
```

<Frame caption="Deprecated method with strikethrough in the [Square TypeScript SDK](https://github.com/square/square-nodejs-sdk/blob/master/src/api/resources/employees/client/Client.ts)">
![Deprecated method with strikethrough and @deprecated tag in VS Code](../../../sdks/images/availability-deprecated-ide.png)
</Frame>

To attach a custom message, write `x-fern-availability` as an object with `status` and `message` fields:

```yaml title="openapi.yml" {4-6}
paths:
/pet:
put:
x-fern-availability:
status: deprecated
message: Use PATCH /pet instead.
```


## Section

<Markdown src="/products/api-def/snippets/availability.mdx" />

8 changes: 8 additions & 0 deletions fern/products/sdks/deep-dives/generated-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ The inline documentation comes from your API definition. During the SDK generati
</video>
</Frame>

## Availability

When you mark an endpoint with an [availability](/learn/api-definitions/openapi/extensions/availability) status like `deprecated` or `beta`, the generated SDK includes the corresponding doc comment tag on the client method. IDEs display these as warnings and strikethrough styling so your users know which endpoints are stable and which to avoid.

<Frame caption="Deprecated method with strikethrough in the [Square TypeScript SDK](https://github.com/square/square-nodejs-sdk/blob/master/src/api/resources/employees/client/Client.ts)">
![Deprecated method with strikethrough and @deprecated tag in VS Code](../images/availability-deprecated-ide.png)
</Frame>

## Error handling

When the API returns a 4xx or 5xx status code, the SDK throws an error that includes the status code, error message, response body, and raw response object.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading