> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/openapi/guides/configuring-the-test-it-button.md).

# 「テストする」ボタンの設定

GitBook では、いくつかの OpenAPI 拡張を使って「Test It」ボタンとそれに付随するウィンドウを設定できます。これらの拡張は、ユーザー向けのテストスイートの改善と設定に役立ちます。

### 「Test it」ボタンを非表示にする

エンドポイントに `x-hideTryItPanel` を追加することで、または OpenAPI 仕様のルートで「Test it」ボタンを非表示にできます。

{% code title="openapi.yaml" %}

```yaml
openapi: '3.0'
info: ...
tags: [...]
paths:
  /example:
    get:
      summary: 例の概要
      description: 例の説明
      operationId: examplePath
      responses: [...]
      parameters: [...]
      x-hideTryItPanel: true
```

{% endcode %}

### 「Test it」リクエストをプロキシする

一部の API ではブラウザからのリクエストがブロックされます。多くの場合、その理由は CORS です。

ルート **テストする** GitBook 経由でトラフィックを中継するには、 `x-enable-proxy` を仕様に追加してください。

以下を参照 [OpenAPI プロキシの使用](/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/openapi/guides/using-openapi-proxy.md) して例を確認してください。

### テストウィンドウで認証を有効にする

リクエストランナーが認証を表示して適用できるのは、仕様でそれが宣言されている場合のみです。スキームを `components.securitySchemes`の下に定義し、次に `security` を使ってグローバルに、または操作ごとに（グローバル設定を上書き）関連付けます。

#### 認証スキームを宣言する

以下は一般的なパターンです。YAML では通常の引用符を使用してください。

{% tabs %}
{% tab title="HTTP Bearer（例: JWT）" %}

```yaml
openapi: '3.0.3'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
```

{% endtab %}

{% tab title="ヘッダー内の API キー" %}

```yaml
openapi: '3.0.3'
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
```

{% endtab %}

{% tab title="OAuth2（authorizationCode）" %}

```yaml
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: 'アイテムを読む'
            write:items: 'アイテムを書き込む'
```

{% endtab %}
{% endtabs %}

#### スキームをグローバルまたは操作ごとに適用する

{% tabs %}
{% tab title="グローバル" %}

```yaml
openapi: '3.0.3'
security:
  - bearerAuth: []
paths: ...
```

{% endtab %}

{% tab title="操作ごと" %}

```yaml
paths:
  /reports:
    get:
      summary: レポートを取得
      security:
        - apiKeyAuth: []
      responses:
        '200':
          description: OK
```

{% endtab %}
{% endtabs %}

### でエンドポイントURLを制御する `servers`

リクエストランナーは、あなたが `servers` 配列で定義した URL を対象にします。1 つ以上のサーバーを宣言できます。変数を使ってパラメータ化することもできます。

{% tabs %}
{% tab title="単一サーバー" %}

```yaml
openapi: '3.0.3'
servers:
  - url: https://instance.api.region.example.cloud
```

{% endtab %}

{% tab title="複数のサーバー" %}

```yaml
servers:
  - url: https://api.example.com
    description: 本番
  - url: https://staging-api.example.com
    description: ステージング
```

{% endtab %}

{% tab title="サーバー変数" %}

```yaml
servers:
  - url: https://{instance}.api.{region}.example.cloud
    variables:
      instance:
        default: acme
        description: あなたのテナントまたはインスタンスのスラッグ
      region:
        default: eu
        enum:
          - eu
          - us
          - ap
        description: 地域ごとのデプロイ
```

{% endtab %}

{% tab title="操作ごとのサーバー" %}

<pre class="language-yaml"><code class="lang-yaml"><strong>paths:
</strong>  /reports:
    get:
      summary: レポートを取得
      servers:
        - url: https://reports.api.example.com
      responses:
        '200':
          description: OK
</code></pre>

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/openapi/guides/configuring-the-test-it-button.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
