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

# OpenAPI スペックを追加する

GitBook アプリまたは CLI から 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/kontentsuwosuru/openapi.md#openapi-compatibility).

<figure><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2F6pg8vIZeVQESjhTw5yI2%2Fgenerate-api-docs%402x.png?alt=media&amp;token=6b72cd8d-7943-465a-88d5-04f8f0f13245" 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="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2FpTRwMrbHyYlKZy07CsAp%2Fapi_spec_modal%402x.png?alt=media&amp;token=77edbf02-aed7-43cc-a1e3-9a61fc001271" 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時間ごとに**.
  * 更新をすぐに取得するには、 **更新を確認**.
* 仕様がファイルとしてアップロードされている場合:
  * クリックして **更新** をクリックして新しいバージョンをアップロードします。
* パンくずアクションメニューの **編集** をクリックすると、File から URL ソースに切り替えられます。

#### CLI を使用する

仕様を更新するには、同じコマンドを使用します:

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

CLI を使って **更新を確認** 公開コマンドを同じURLで実行することで行えます。

こちらの [CI/CD との統合](/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/openapi/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/kontentsuwosuru/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.
