Replies: 2 comments
-
Hi, you can take a look at how it is currently done for the axum handlers, (it's a macro, but should be readable): aide/crates/aide/src/axum/routing.rs Line 79 in 556227c In the OpenAPI terminology an operation is a combination of http path and a method. In the code example a single |
Beta Was this translation helpful? Give feedback.
-
Again I know this is REALLY old(sorry). Here is an example of generating dynamic routes: async fn serve_docs(Extension(api): Extension<Arc<Mutex<OpenApi>>>, _state: State<AppState>) -> impl IntoApiResponse {
// use _state to save the generated routes
let mut api = api.lock().await.clone();
if let Some(paths) = api.paths.as_mut() {
paths.paths.insert(
"/events/foo_event".to_owned(),
aide::openapi::ReferenceOr::Item(aide::openapi::PathItem {
get: Some(aide::openapi::Operation {
description: Some("testing, adding dynamic routes".to_owned()),
..Default::default()
}),
..Default::default()
}),
);
}
Json(api).into_response()
} The axum let mut api = OpenApi::default();
let app = ApiRouter::new()
... // Your routes
.layer(Extension(Arc::new(Mutex::new(api)))); I don't understand the use case to be honest. |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm using aide with its ApiRouter like this:
The available event kinds are dynamically generated at runtime, but have known JSON Schemas.
I'd like to now generate a second OpenAPI document containing all the concrete paths such as
GET /events/foo_event
and its associated JSON Schema, and possibly add even more while the program is running.I can see that the
OpenApi
struct has itspaths
field public, but I'm unsure how I'd properly generate the documentation to insert there.Beta Was this translation helpful? Give feedback.
All reactions