Crate rustapi_openapi

Crate rustapi_openapi 

Source
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")
    .await

Modules§

utoipa_types

Structs§

ApiInfo
API information for OpenAPI spec
ErrorSchema
Standard error response body
FieldErrorSchema
Field-level validation error
MediaType
Media type in OpenAPI spec
OpenApiConfig
Configuration for OpenAPI documentation
OpenApiSpec
OpenAPI specification builder
Operation
Operation (endpoint) in OpenAPI spec
Parameter
Parameter in OpenAPI spec
PathItem
Path item in OpenAPI spec
RequestBody
Request body in OpenAPI spec
ResponseSpec
Response specification
ValidationErrorSchema
Validation error response (422)

Enums§

SchemaRef
Schema reference or inline schema

Traits§

IntoParams
Trait used to convert implementing type to OpenAPI parameters.
OperationModifier
Trait for types that can modify an OpenAPI operation
ResponseModifier
Schema
Trait for implementing OpenAPI Schema object.

Functions§

openapi_json
Generate OpenAPI JSON response
swagger_ui_html
Generate Swagger UI HTML response

Derive Macros§

IntoParams
Generate path parameters from struct’s fields.
Schema
Generate reusable OpenAPI schema to be used together with OpenApi.