# OpenAPI プロキシの使用

GitBookはプロキシできます **テストする** リクエストをプロキシできるため、APIサーバーがCORSをサポートしていなくても動作します。

### これが存在する理由

ブラウザーは、APIサーバーがCORSヘッダーで許可しない限り、クロスオリジンリクエストをブロックします。CORSが設定されていないと、 **テストする** ブラウザーではリクエストが失敗します。プロキシは、それらのリクエストをGitBookを経由してサーバー側でルーティングし、その制限を回避します。

### スペック全体でプロキシを有効にする

追加する `x-enable-proxy: true` OpenAPIスペックのルートに。

<pre class="language-yaml"><code class="lang-yaml">openapi: '3.0.3'
<strong>x-enable-proxy: true
</strong>info:
  title: Example API
  version: '1.0.0'
servers:
  - url: https://api.example.com
</code></pre>

### 特定の操作で有効または無効にする

追加する `x-enable-proxy` を操作に対して。

<pre class="language-yaml"><code class="lang-yaml">openapi: '3.0.3'
info:
  title: Example API
  version: '1.0.0'
servers:
  - url: https://api.example.com
paths:
  /reports:
    get:
      summary: レポート一覧を取得
<strong>      x-enable-proxy: true
</strong>      responses:
        '200':
          description: OK
    post:
      summary: レポートを作成
<strong>      x-enable-proxy: false
</strong>      responses:
        '201':
          description: 作成済み
</code></pre>

{% hint style="info" %}
操作レベル `x-enable-proxy` はルートレベルの値より優先されます。
{% endhint %}

### プロキシがサポートするもの

GitBookはすべての `HTTP` メソッド（`GET`, `POST`, `PUT`, `DELETE`, `PATCH`）、ヘッダー、Cookie、リクエストボディを転送します。

### セキュリティ

プロキシは、スペックの `servers` 配列に記載されたURLにのみリクエストを転送します。任意のURLへ到達するためには使用できません。

{% hint style="info" %}
次の `servers` 配列に、テスト対象にしたいすべてのベースURLが含まれていることを確認してください。URLが記載されていない場合、 **テストする** そのホストへのリクエストはプロキシをバイパスします。
{% endhint %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.com/docs/documentation/ja-gitbook-documentation/api-references/guides/using-openapi-proxy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
