> 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/features/yard-comments.md).

# Summaries & Descriptions (YARD)

The generator reads YARD-style comments directly above controller action methods and maps them to OpenAPI operation fields.

## Basic usage

```ruby
# Search users
# Returns the users matching the given filters, newest first.
# Results are paginated; use the `page` and `per_page` parameters to navigate.
def index
  # ...
end
```

The first line becomes the OpenAPI `summary`. Every subsequent paragraph becomes the `description`. Both fields are plain strings in the spec — you can include Markdown tables, fenced code blocks, or inline links, and they will pass through verbatim to renderers like Redoc or Swagger UI.

## What gets picked up

| YARD position      | OpenAPI field |
| ------------------ | ------------- |
| First comment line | `summary`     |
| Remaining lines    | `description` |

Multi-paragraph descriptions work:

```ruby
# Create a user
#
# Creates a new user and sends a welcome email.
#
# ## Roles
#
# | Role   | Permissions          |
# |--------|----------------------|
# | admin  | all resources        |
# | member | own resources only   |
#
# Returns `422` if validation fails.
def create
  # ...
end
```

## What does NOT get picked up

* `@param` tags — parameters come from `param!` calls (see [Parameters](/rails-openapi-generator/features/parameters.md))
* `@return` tags — response schemas come from jbuilder templates or `.schema.json` files
* `@deprecated`, `@since`, and other YARD metadata tags — ignored

The generator intentionally separates human-written prose (YARD) from machine-readable schemas (`param!`, views), so you don't duplicate type information.

## No comment → no summary

If an action has no YARD comment, the `summary` and `description` fields are omitted from the operation. The endpoint is still generated with its parameters and response schema.

## Inherited and concern-level comments

YARD comments are read from the file that defines the action. If an action is defined in a controller concern and mixed in, the comment in the concern file is used. Comments are not inherited from parent class methods when the action is overridden.


---

# 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/features/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.
