Expand description
OpenAPI documentation for RustAPI
This crate provides OpenAPI specification generation and Swagger UI serving
for RustAPI applications. It wraps utoipa internally while providing a
clean public API.
§Features
- Automatic OpenAPI spec generation
- Swagger UI serving at
/docs - JSON spec at
/openapi.json - Schema derivation via
#[derive(Schema)]
§Usage
ⓘ
use rustapi_rs::prelude::*;
#[derive(Serialize, Schema)]
struct User {
id: i64,
name: String,
}
RustApi::new()
.route("/users", get(list_users))
.docs("/docs")
.run("127.0.0.1:8080")
.awaitModules§
Structs§
- ApiInfo
- API information for OpenAPI spec
- Error
Schema - Standard error response body
- Field
Error Schema - Field-level validation error
- Media
Type - Media type in OpenAPI spec
- Open
ApiConfig - Configuration for OpenAPI documentation
- Open
ApiSpec - OpenAPI specification builder
- Operation
- Operation (endpoint) in OpenAPI spec
- Parameter
- Parameter in OpenAPI spec
- Path
Item - Path item in OpenAPI spec
- Request
Body - Request body in OpenAPI spec
- Response
Spec - Response specification
- Validation
Error Schema - Validation error response (422)
Enums§
- Schema
Ref - Schema reference or inline schema
Traits§
- Into
Params - Trait used to convert implementing type to OpenAPI parameters.
- Operation
Modifier - Trait for types that can modify an OpenAPI operation
- Response
Modifier - Schema
- Trait for implementing OpenAPI Schema object.
Functions§
- openapi_
json - Generate OpenAPI JSON response
- swagger_
ui_ html - Generate Swagger UI HTML response
Derive Macros§
- Into
Params - Generate path parameters from struct’s fields.
- Schema
- Generate reusable OpenAPI schema to be used
together with
OpenApi.