> For the complete documentation index, see [llms.txt](https://tonystrawberry.gitbook.io/rails-openapi-generator/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tonystrawberry.gitbook.io/rails-openapi-generator/ja/ji-neng/yard-comments.md).

# サマリーと説明（YARD）

ジェネレーターはコントローラアクションメソッドの直上にあるYARDスタイルのコメントを読み取り、OpenAPIオペレーションフィールドにマッピングします。

## 基本的な使い方

```ruby
# ユーザーを検索
# 指定されたフィルターに一致するユーザーを新しい順で返します。
# 結果はページネーションされます。`page`と`per_page`パラメータで移動できます。
def index
  # ...
end
```

最初の行がOpenAPIの`summary`になります。それ以降の段落が`description`になります。どちらのフィールドも仕様ではプレーン文字列です。Markdownのテーブル、コードブロック、インラインリンクなどはすべてそのまま通過し、RedocやSwagger UIなどのレンダラーで表示されます。

## 取得されるもの

| YARDの位置  | OpenAPIフィールド  |
| -------- | ------------- |
| 最初のコメント行 | `summary`     |
| それ以降の行   | `description` |

複数段落の説明も機能します。

```ruby
# ユーザーを作成
#
# 新しいユーザーを作成し、ウェルカムメールを送信します。
#
# ## ロール
#
# | ロール  | 権限                  |
# |--------|----------------------|
# | admin  | 全リソース            |
# | member | 自分のリソースのみ     |
#
# バリデーションに失敗した場合は`422`を返します。
def create
  # ...
end
```

## 取得されないもの

* `@param`タグ — パラメータは`param!`呼び出しから取得されます（[パラメータ](/rails-openapi-generator/ja/ji-neng/parameters.md)参照）
* `@return`タグ — レスポンススキーマはjbuilderテンプレートまたは`.schema.json`ファイルから取得されます
* `@deprecated`、`@since`などのYARDメタデータタグ — 無視されます

ジェネレーターは人間が書く文章（YARD）と機械読み取り可能なスキーマ（`param!`、ビュー）を意図的に分離しているため、型情報を重複して記述する必要はありません。

## コメントなし → サマリーなし

アクションにYARDコメントがない場合、`summary`と`description`フィールドはオペレーションから省略されます。エンドポイント自体はパラメータとレスポンススキーマと共に生成されます。

## コンサーン内のコメント

アクションがコントローラコンサーンで定義されてミックスインされている場合、コンサーンファイル内のコメントが使用されます。アクションがオーバーライドされた場合、親クラスのメソッドのコメントは継承されません。


---

# 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://tonystrawberry.gitbook.io/rails-openapi-generator/ja/ji-neng/yard-comments.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.
