Configuring the “Test it” button
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
You can configure the "Test It" button and accompanying window in GitBook using several OpenAPI extensions. These extensions can help improve and configure the testing suite for users.
You can hide the “Test it” button from your endpoints by adding the x-hideTryItPanel
to an endpoint, or at the root of your OpenAPI spec.
components.securitySchemes
, then attach them either globally via security
(applies to all operations) or per-operation (overrides global).Below are common patterns. Use straight quotes in YAML.
openapi: '3.0.3'
security:
- bearerAuth: []
paths: ...
The request runner targets the URL(s) you define in the servers
array. Declare one or more servers; you can also parameterize them with variables.
openapi: '3.0'
info: ...
tags: [...]
paths:
/example:
get:
summary: Example summary
description: Example description
operationId: examplePath
responses: [...]
parameters: [...]
x-hideTryItPanel: true
openapi: '3.0.3'
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
openapi: '3.0.3'
components:
securitySchemes:
apiKeyAuth:
type: apiKey
in: header
name: X-API-Key
openapi: '3.0.3'
components:
securitySchemes:
oauth2:
type: oauth2
flows:
authorizationCode:
authorizationUrl: 'https://auth.example.com/oauth/authorize'
tokenUrl: 'https://auth.example.com/oauth/token'
scopes:
read:items: 'Read items'
write:items: 'Write items'
openapi: '3.0.3'
servers:
- url: https://instance.api.region.example.cloud
servers:
- url: https://api.example.com
description: Production
- url: https://staging-api.example.com
description: Staging
servers:
- url: https://{instance}.api.{region}.example.cloud
variables:
instance:
default: acme
description: Your tenant or instance slug
region:
default: eu
enum:
- eu
- us
- ap
description: Regional deployment
paths:
/reports:
get:
summary: Get reports
servers:
- url: https://reports.api.example.com
responses:
'200':
description: OK