Module openapi

Module openapi 

Source
Expand description

§OpenAPI Module

This module provides OpenAPI documentation generation capabilities for Gotcha web applications. It is enabled by default but can be disabled by opting out of the “openapi” feature.

§Features

  • Automatic OpenAPI spec generation from route definitions
  • Support for operation parameters, request bodies, and responses
  • Built-in Redoc and Scalar UI for API documentation viewing
  • Grouping operations by tags
  • Parameter validation and type information

§Example

use gotcha::{GotchaRouter, Operable};

#[openapi(group = "Users")]
async fn get_user() -> impl Responder {
    // Handler implementation
}

fn routes(router: GotchaRouter) -> GotchaRouter {
    router.get("/users/:id", get_user)
}

The OpenAPI documentation will be automatically generated and served at /docs and /docs/scalar endpoints when the feature is enabled.

Structs§

Operable

Functions§

generate_openapi

Type Aliases§

ParamConstructor
ParamType