> 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/api-references/openapi/add-an-openapi-specification.md).

# OpenAPI スペックを追加する

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

GitBook は [Swagger 2.0](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md), [OpenAPI 3.0](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md)、および [OpenAPI 3.1](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md) ファイルのアップロード、ホストされた URL、および CLI での公開に関する仕様を受け付けます。現在の互換性の概要については、 [OpenAPI の互換性](/docs/documentation/ja-gitbook-documentation/api-references/openapi.md#openapi-compatibility).

<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>

### 仕様書を更新する

OpenAPI 仕様書は、最初にどのように追加したかに関係なく、GitBook の UI または CLI を使っていつでも更新できます。

#### 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
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 dynamically by asking a question.

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

```
GET https://gitbook.com/docs/documentation/ja-gitbook-documentation/api-references/openapi/add-an-openapi-specification.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
