diff --git a/fern/products/docs/pages/api-references/api-explorer.mdx b/fern/products/docs/pages/api-references/api-explorer.mdx index e370c862ec..6c9c2162cc 100644 --- a/fern/products/docs/pages/api-references/api-explorer.mdx +++ b/fern/products/docs/pages/api-references/api-explorer.mdx @@ -7,7 +7,7 @@ subtitle: Reduce "time to 200" by allowing users to make real calls to your API Fern's API Explorer allows users to make authenticated requests to your API without ever leaving your documentation. ## Autopopulate with examples -Fern will automatically populate the fields of the endpoint with the values set in your API specification. +Fern will automatically populate the fields of the endpoint with the values set in your API specification. Optional parameters that declare a default are only pre-filled and sent when you enable [`playground.send-optional-defaults`](/learn/docs/api-references/customize-api-reference-layout#sending-defaults-for-optional-parameters) in your `docs.yml`.
diff --git a/fern/products/docs/pages/api-references/customize-api-ref.mdx b/fern/products/docs/pages/api-references/customize-api-ref.mdx index 5184e5c180..f079d833f6 100644 --- a/fern/products/docs/pages/api-references/customize-api-ref.mdx +++ b/fern/products/docs/pages/api-references/customize-api-ref.mdx @@ -220,7 +220,7 @@ You can hide an endpoint from the API Reference by setting `hidden` to `true`. T ### Setting API Explorer options -The `playground` property sets two API Explorer options: `oauth` enables the [OAuth client-credentials flow](/learn/api-definitions/openapi/authentication), and `environments` restricts which server environments are available (an empty list disables the Explorer). Set it on the `- api` entry to apply a default across all endpoints, then override it on a section or endpoint in `layout`: +The `playground` property sets three API Explorer options: `oauth` enables the [OAuth client-credentials flow](/learn/api-definitions/openapi/authentication), `environments` restricts which server environments are available (an empty list disables the Explorer), and `send-optional-defaults` pre-fills and sends declared defaults for optional parameters. Set it on the `- api` entry to apply a default across all endpoints, then override it on a section or endpoint in `layout`: ```yaml title="docs.yml" {4-5,8-9,13-14} navigation: @@ -237,6 +237,17 @@ navigation: oauth: false # Override for this endpoint ``` +### Sending defaults for optional parameters + +The API Explorer always sends the declared `default` (or [`x-fern-default`](/learn/api-definitions/openapi/extensions/default-values)) of a required parameter. Optional header, query, and path parameters are left empty unless `send-optional-defaults` is `true`, which pre-fills their declared default and includes it in the request. This is useful when an API expects an optional header, such as a mock-response selector, on every request. It defaults to `false`. + +```yaml title="docs.yml" {3-4} +navigation: + - api: API Reference + playground: + send-optional-defaults: true +``` + ### 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`. @@ -428,6 +439,7 @@ The following properties can be set on the `- api` entry in your `docs.yml` navi - `oauth` (`boolean`): When `true`, enables the [OAuth client-credentials flow](/learn/docs/api-references/api-explorer#authentication) in the API Explorer. - `environments` (`list