Expand description
§OpenAPI models for Rust
OpenAPI models with Serde support and builders. Existing document constructors
default to OpenAPI 3.0.0; OpenAPIV3::new_v3_2 opts into 3.2 streaming schemas.
SchemaValue supports object and boolean schemas, with type unions and
string-encoded content in Schema. Coverage of OpenAPI 3.1/3.2 is partial;
see the migration guide
for source changes and remaining model differences. The crate does not validate
documents or evaluate schemas.
§Features
- OpenAPI Models: 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
- Modern Schemas: Type unions, boolean schemas, and references with sibling keywords
- Streaming Media Types: OpenAPI 3.2
itemSchemafor parsed stream items - 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 referencesSchemaValue- Object or boolean schema; schema references retain sibling keywordsbuilders- 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
- OpenAPI types with JSON Schema 2020-12 and OpenAPI 3.2 streaming support.