Test it button
You can configure the “Test it” button and accompanying window in GitBook using several OpenAPI extensions. These extensions help improve and configure the testing suite for users. The interactive test functionality is powered by Scalar and allows users to execute live API requests directly from your documentation.Hiding the test it button
You can hide the “Test it” button from your endpoints by adding thex-hideTryItPanel extension to an endpoint, or at the root of your OpenAPI spec.
For a specific endpoint:
openapi.yaml
openapi.yaml
Hiding the test functionality is useful for documentation-only endpoints, webhooks, or operations that require complex setup that can’t be easily replicated in the browser.
Enable authentication in the testing window
The request runner can only present and apply auth if your spec declares it. Define schemes undercomponents.securitySchemes, then attach them either globally via security (applies to all operations) or per-operation (overrides global).
Declare your auth scheme
Below are common patterns. Use straight quotes in YAML.Apply schemes globally or per operation
When you define security schemes, GitBook automatically adds an authentication input field to the “Test it” panel, allowing users to provide their credentials.
Control the endpoint URL with servers
The request runner targets the URL(s) you define in theservers array. Declare one or more servers; you can also parameterize them with variables.
Single server
openapi.yaml
Multiple servers
openapi.yaml
Server variables
For dynamic server URLs, use variables that users can customize:openapi.yaml
Per-operation servers
You can override the global servers array for specific operations:openapi.yaml
Complete example
Here’s a complete example showing authentication, servers, and test configuration:openapi.yaml
Best practices
Configure CORS properly
Ensure your API allows cross-origin requests from your documentation domain. Test the “Test it” functionality thoroughly.
Provide sandbox environments
Include a sandbox or staging server in your
servers array so users can test without affecting production data.Document authentication clearly
In your security scheme descriptions, explain how users can obtain valid credentials for testing.
Use realistic examples
Provide example values in your spec so the test panel is pre-populated with sensible defaults.