| Crates.io | next-web-api-doc |
| lib.rs | next-web-api-doc |
| version | 0.1.0 |
| created_at | 2026-01-18 07:43:16.610524+00 |
| updated_at | 2026-01-18 07:43:16.610524+00 |
| description | Api Doc |
| homepage | |
| repository | https://github.com/yuenxillar/next-web |
| max_upload_size | |
| id | 2051971 |
| size | 17,242 |
A crate for integrating utoipa with next-web Framework for automatic OpenAPI/Swagger documentation generation.
The rules are consistent with utoipa
Due to the limitations of the utoipa, you must add utoipa to your Cargo.toml
cargo add utoipa
use next_web::{
api_doc, application::Application, async_trait, extract::find_singleton::FindSingleton,
post_mapping, request_mapping,
};
use next_web_core::{context::properties::ApplicationProperties, ApplicationContext};
use utoipa::openapi::OpenApi;
#[derive(Default, Clone)]
pub struct TestApplication;
#[async_trait]
impl Application for TestApplication {
type ErrorSolve = ();
async fn init_middleware(
&self,
_ctx: &mut ApplicationContext,
_properties: &ApplicationProperties,
) {
}
}
#[api_doc(
responses(
(status = 200, description = "JSON file", body = ())
)
)]
#[request_mapping(method = "GET", path = "/test")]
async fn openapi(FindSingleton(open_api): FindSingleton<OpenApi>) -> String {
open_api.to_pretty_json().unwrap()
}
#[api_doc]
#[post_mapping(path = "/test1")]
async fn test() -> String {
String::from("Hello world!")
}
#[tokio::main]
async fn main() {
TestApplication::run().await;
}