# OpenAPI 仕様を追加する

OpenAPI の仕様がある場合は、ファイルを直接アップロードするか、ホストされた URL にリンクするか、または [GitBook CLI](https://gitbook.com/docs/developers/integrations/reference).

<figure><img src="/files/7c83552fb49ef2b7054e9bedf79ab72626b89f23" alt="A GitBook screenshot showing the modal for generating API docs automatically"><figcaption></figcaption></figure>

### 仕様を追加する方法

1. 開く **OpenAPI** サイドバーのセクション
2. 次をクリックします **仕様を追加**
3. 仕様に名前を付けてください。特に複数の仕様を管理している場合、識別しやすくなります
4. 次のいずれかを選択してください:
   * ファイルをアップロードする（例: *openapi.yaml*)
   * ホストされた仕様の URL を入力する
   * CLI を使用して仕様を公開する

<figure><img src="/files/880216b917ea19b045695a7a770f2ebffb670fdf" alt="A GitBook screenshot showing the Add an OpenAPI specification modal"><figcaption><p>OpenAPI 仕様の追加モーダル。</p></figcaption></figure>

### 仕様を更新する

GitBook の UI または CLI を使用して、OpenAPI 仕様はいつでも更新できます。最初にどの方法で追加したかは関係ありません。

#### GitBook アプリケーションで

OpenAPI パネルで:

* 仕様が URL にリンクされている場合:
  * GitBook は更新を自動的に確認します **6 時間ごとに**.
  * 更新をすぐに取得するには、 **更新を確認**.
* 仕様がファイルとしてアップロードされている場合:
  * クリック **更新** をクリックして新しいバージョンをアップロードします。
* パンくずのアクションメニューで **編集** をクリックすると、ファイルから URL ソースに切り替えることができます。

#### CLI を使用する

同じコマンドを使用して仕様を更新します:

```bash
gitbook openapi publish --spec api-spec-name --organization organization_id <path-or-url>
```

CLI を使用して **更新を確認** 同じ URL で publish コマンドを実行することでもできます。

こちらの [CI/CD との統合](/docs/documentation/ja-gitbook-documentation/api-references/guides/support-for-ci-cd-with-api-blocks.md) ガイドを読んで、仕様の更新を自動化する方法をご確認ください。


---

# 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/openapi/add-an-openapi-specification.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.
