diff --git a/fern/products/api-def/openapi/extensions/availability.mdx b/fern/products/api-def/openapi/extensions/availability.mdx index 0d52666a3..b181ca57b 100644 --- a/fern/products/api-def/openapi/extensions/availability.mdx +++ b/fern/products/api-def/openapi/extensions/availability.mdx @@ -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 | | --- | --- | --- | @@ -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. ![Screenshot of API Reference endpoint with tag showing deprecated](https://fern-image-hosting.s3.amazonaws.com/fern/x-fern-availability-example.png) +### 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 { ... } + + /** @beta This endpoint is in pre-release and may change. */ + public getPetById( ... ): Promise { ... } +} +``` + + +![Deprecated method with strikethrough and @deprecated tag in VS Code](../../../sdks/images/availability-deprecated-ide.png) + + +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 + diff --git a/fern/products/sdks/deep-dives/generated-sdk.mdx b/fern/products/sdks/deep-dives/generated-sdk.mdx index edeb02507..770bc778c 100644 --- a/fern/products/sdks/deep-dives/generated-sdk.mdx +++ b/fern/products/sdks/deep-dives/generated-sdk.mdx @@ -39,6 +39,14 @@ The inline documentation comes from your API definition. During the SDK generati +## 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. + + +![Deprecated method with strikethrough and @deprecated tag in VS Code](../images/availability-deprecated-ide.png) + + ## 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. diff --git a/fern/products/sdks/images/availability-deprecated-ide.png b/fern/products/sdks/images/availability-deprecated-ide.png new file mode 100644 index 000000000..240cce529 Binary files /dev/null and b/fern/products/sdks/images/availability-deprecated-ide.png differ