$ show paperclip-rs/paperclip
Paperclip is a Rust toolkit for working with OpenAPI specifications. It provides code generation for type-safe HTTP clients and servers from OpenAPI v2/v3 specs, procedural macros to derive OpenAPI annotations from Rust code, and an Actix-web plugin for serving generated specs and integrating with handlers. The architecture is modular with separate crates for core types, macros, Actix integration, and CLI tools. Key features include reference resolution with cycle detection, emitter-based code generation strategy, builder patterns with compile-time field validation, and macro-driven spec generation. The project is actively maintained with recent commits, CI workflows, and frequent version updates.
The LLM identified 4 files worth highlighting for reuse:
Implements a Resolvable<S> enum that handles JSON Schema reference ($ref) resolution with cycle detection using interior mutability. This isolated pattern solves a complex problem in schema processing and can be extracted for use in any JSON Schema toolkit.
Defines a trait-based Emitter interface for code generation, allowing different output formats (languages/frameworks) to be plugged in without modifying core parsing logic. Demonstrates clean separation of concerns and extensibility strategy.
Generates Rust builder patterns that use phantom types to track required field completion, providing compile-time guarantees for struct construction. This advanced type-system application ensures safety in generated API client builders.
Provides derive macros (Apiv2Schema, Apiv2Operation) that convert Rust types/functions into OpenAPI specification components. Reduces boilerplate and keeps specs synchronized with code through non-trivial procedural macro logic.