|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +`openapi-tui` is a terminal UI application for browsing and running APIs defined with OpenAPI v3.0/v3.1 specifications. Built with Rust using `ratatui` for the TUI layer and `tokio` for async runtime. |
| 6 | + |
| 7 | +## Build & Development Commands |
| 8 | + |
| 9 | +```bash |
| 10 | +# Build |
| 11 | +cargo build |
| 12 | + |
| 13 | +# Run tests |
| 14 | +cargo test --all-features --workspace |
| 15 | + |
| 16 | +# Format code |
| 17 | +cargo fmt --all |
| 18 | + |
| 19 | +# Lint (CI treats warnings as errors) |
| 20 | +cargo clippy --all-targets --all-features --workspace -- -D warnings |
| 21 | + |
| 22 | +# Check documentation |
| 23 | +cargo doc --no-deps --document-private-items --all-features --workspace --examples |
| 24 | + |
| 25 | +# Run locally |
| 26 | +cargo run -- -i examples/petstore.json |
| 27 | +cargo run -- -i path/to/spec.yml |
| 28 | +``` |
| 29 | + |
| 30 | +## CI Checks (all must pass) |
| 31 | + |
| 32 | +The CI pipeline (`.github/workflows/ci.yml`) runs on every push to `main` and all PRs: |
| 33 | + |
| 34 | +1. **Test** – `cargo test --all-features --workspace` |
| 35 | +2. **Rustfmt** – `cargo fmt --all --check` |
| 36 | +3. **Clippy** – `cargo clippy --all-targets --all-features --workspace -- -D warnings` |
| 37 | +4. **Docs** – `cargo doc --no-deps --document-private-items --all-features --workspace --examples` |
| 38 | + |
| 39 | +All CI jobs use the **nightly** Rust toolchain. |
| 40 | + |
| 41 | +## Architecture |
| 42 | + |
| 43 | +``` |
| 44 | +src/ |
| 45 | + main.rs # Entry point, tokio async runtime |
| 46 | + app.rs # Main application loop, event handling |
| 47 | + cli.rs # CLI argument parsing (clap) |
| 48 | + tui.rs # Terminal setup/teardown, Frame type alias |
| 49 | + state.rs # Application state |
| 50 | + action.rs # Actions dispatched through the app |
| 51 | + config.rs # Configuration loading |
| 52 | + request.rs # HTTP request logic |
| 53 | + response.rs # HTTP response handling |
| 54 | + pages/ # Full-screen page layouts |
| 55 | + home.rs # Main desktop layout |
| 56 | + phone.rs # Compact/phone layout |
| 57 | + panes/ # Individual UI panes (widgets) |
| 58 | + apis.rs # API list pane |
| 59 | + tags.rs # Tags pane |
| 60 | + header.rs # Header pane |
| 61 | + footer.rs # Footer/command input pane |
| 62 | + request.rs # Request details pane |
| 63 | + response.rs # Response details pane |
| 64 | + response_viewer.rs # Response body viewer |
| 65 | + body_editor.rs # Request body editor |
| 66 | + address.rs # URL/address pane |
| 67 | + parameter_editor.rs # Parameter editor pane |
| 68 | + history.rs # Request history pane |
| 69 | + components/ |
| 70 | + schema_viewer.rs # YAML schema viewer with syntax highlighting |
| 71 | +``` |
| 72 | + |
| 73 | +## Key Dependencies |
| 74 | + |
| 75 | +- `ratatui 0.30.0` – TUI framework |
| 76 | +- `crossterm 0.29.0` – Terminal backend (must stay in sync with ratatui) |
| 77 | +- `ratatui-textarea 0.8.0` – Multi-line text editor widget (replaces `tui-textarea`) |
| 78 | +- `tui-input 0.15.0` – Single-line input widget |
| 79 | +- `syntect 5.2.0` – Syntax highlighting for schema viewer |
| 80 | +- `tokio` – Async runtime (full features) |
| 81 | +- `reqwest` – HTTP client for running API calls |
| 82 | +- `openapi-31` – OpenAPI spec parsing |
| 83 | + |
| 84 | +## Dependency Notes |
| 85 | + |
| 86 | +- **crossterm** must match the version used by ratatui's crossterm backend. ratatui 0.30.0 uses crossterm 0.29.0. |
| 87 | +- **ratatui-textarea** (`ratatui-textarea = "0.8.0"`) is the ratatui-org maintained fork of `tui-textarea`, updated for ratatui 0.30+. Use `ratatui_textarea::TextArea` in imports. |
| 88 | +- **syntect-tui** was removed; its style translation logic is inlined in `schema_viewer.rs` to avoid ratatui version conflicts. |
| 89 | +- In ratatui 0.30.0, `Block`, `BorderType`, `Borders`, `Padding` moved out of `ratatui::widgets::block` and are now exported directly from `ratatui::widgets`. Do not use `widgets::{block::*, *}`. |
| 90 | + |
| 91 | +## Code Conventions |
| 92 | + |
| 93 | +- 2-space indentation |
| 94 | +- `use ratatui::{prelude::*, widgets::*}` is the standard ratatui import pattern |
| 95 | +- Panes implement the `Pane` trait; pages compose panes via layout splits |
| 96 | +- Error handling uses `color_eyre::eyre::Result` |
0 commit comments