Skip to content

Support displaying multiple production servers when displayAllServers is false #1088

@fpracht

Description

@fpracht

Problem

Currently, when displayAllServers is false (the default), only a single server URL is shown - the first one with production: true, or the first server in the array. There is no way to display multiple production endpoints while hiding non-production ones.

This is a problem when an API exposes multiple endpoints for the same environment, e.g. a GraphQL HTTP endpoint and a WebSocket endpoint. The AWS AppSync GraphQL does that for example:

servers:
  - url: https://dev.example.com/graphql
    description: Dev GraphQL
  - url: wss://dev.example.com/realtime
    description: Dev WebSocket
  - url: https://example.com/graphql
    description: GraphQL API
    production: true
  - url: wss://example.com/realtime
    description: WebSocket
    production: true

With the current behavior, only https://example.com/graphql is displayed. Setting displayAllServers: true would show all four servers, including the dev ones.

Expected behavior

When displayAllServers is false and multiple servers have production: true, all production servers should be displayed with their descriptions - not just the first one.

Proposed solution

In src/themes/default/helpers/generateApiEndpoints.js, filter servers by production: true when there are multiple production entries, and render them in the same format used by displayAllServers: true. When only one (or zero) servers have production: true, the existing behavior is preserved - no breaking change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions