Expand description
§OpenAPI Specification (OAS) 3.0 Rust Implementation
This crate provides a complete implementation of the OpenAPI Specification 3.0 in Rust, with comprehensive support for serialization/deserialization and convenient builder patterns for programmatic API specification creation.
§Features
- Complete OAS 3.0 Support: All OpenAPI 3.0 specification features including schemas, operations, parameters, responses, security, callbacks, and links
- Serde Integration: Full JSON/YAML serialization and deserialization support
- Builder Patterns: Fluent APIs for easy specification construction
- Type Safety: Leverages Rust’s type system to prevent invalid specifications
- Reference System: Support for both inline definitions and
$refreferences
§Quick Start
use oas::{builders, Referenceable, PathItem, Tag, Server};
let api = builders::api("My API", "1.0.0")
.with_description("A sample API")
.add_server(Server::new("https://api.example.com"))
.add_path("/users", PathItem::new()
.with_get(builders::get("List users")
.response("200", Referenceable::ok("User list"))
.build()));
println!("{}", api.to_string());§Core Types
OpenAPIV3- The root OpenAPI documentReferenceable<T>- Wrapper for inline data or referencesbuilders- Module containing builder utilitiesOperationBuilder- Builder for complex operations
§Reference vs Inline Data
The Referenceable<T> type allows you to specify either inline data or references
to reusable components:
use oas::{Referenceable, Schema};
// Inline schema
let inline = Referenceable::data(Schema::string());
// Reference to component
let reference = Referenceable::schema_ref("User");Re-exports§
Modules§
- builders
- Builder patterns and utilities for constructing OpenAPI specifications.
- extensions
- Extension methods and convenience constructors for OpenAPI types.
- security
- Security-related types for OpenAPI 3.0 specifications.
- types
- Core OpenAPI 3.0 type definitions.