> 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/readme.md).

# Introduction

Generate a complete OpenAPI 3.1 document for your Rails application through **static source analysis** — no controller code is executed, no test server is spun up.

The gem reads your route set, parses your controllers and jbuilder templates with Ruby's `Ripper` AST parser, and writes a byte-identical spec file every time.

## What it produces

A single JSON or YAML file — `doc/openapi.json` by default — containing every route as an OpenAPI 3.1 operation with:

* **Parameters** extracted from `param!` (rails\_param) declarations
* **Request bodies** inferred from POST/PUT/PATCH `param!` blocks
* **Response schemas** derived from jbuilder templates, inline `render json:`, or `.schema.json` sidecars
* **Status codes** read from `head`, `render status:`, and `redirect_to` calls
* **Error responses** from `rescue_from` declarations
* **Summaries and descriptions** from YARD comments on controller actions

## Why static analysis

Static analysis means the spec is always in sync with your source code, not with what ran last. There is no flaky "record mode", no running migrations, no seeding a test database. Run `rake openapi:generate` from CI and diff the output.

## Quick look

```sh
# Gemfile
gem "rails-openapi-generator"

bundle install
bundle exec rake openapi:generate
# → doc/openapi.json
```

See [Installation](/rails-openapi-generator/getting-started/installation.md) to get started.

## Navigation

* **Getting Started** — install, configure, and run your first generation
* **Features** — deep dives into parameters, responses, status codes, and more
* **Guides** — schema sidecars, route filtering, previewing docs, and programmatic use
* **Reference** — complete configuration option listing
* **Examples** — end-to-end worked examples with real controller + view code


---

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