Macro rocket_okapi::openapi_get_routes_spec
source · [−]macro_rules! openapi_get_routes_spec {
($settings:ident :
$($route:expr),* $(,)*) => { ... };
($($route:expr),* $(,)*) => { ... };
}
Expand description
A replacement macro for rocket::routes
. This parses the routes and provides
a tuple with 2 parts (Vec<rocket::Route>, OpenApi)
:
Vec<rocket::Route>
: A list of all the routes thatrocket::routes![]
would have provided.OpenApi
: Theokapi::openapi3::OpenApi
spec for all the routes.
NOTE: This marco is different from openapi_get_routes
in that this does not add
the openapi.json
file to the list of routes. This is done so the OpenApi
spec can be changed
before serving it.
Example:
ⓘ
use okapi::openapi3::OpenApi;
let settings = rocket_okapi::settings::OpenApiSettings::new();
let (routes, spec): (Vec<rocket::Route>, OpenApi) =
openapi_get_routes_spec![settings: create_message, get_message];
Or
ⓘ
use okapi::openapi3::OpenApi;
let (routes, spec): (Vec<rocket::Route>, OpenApi) =
openapi_get_routes_spec![create_message, get_message];