Skip to main content

openapi_routes

Macro openapi_routes 

Source
openapi_routes!() { /* proc-macro */ }
Expand description

Generate and return a closure that can be used to generate the routes.

This closure take 2 arguments:

  • spec_opt: Option<rocket_okapi::animi_okapi::openapi3::OpenApi>
  • settings: rocket_okapi::settings::OpenApiSettings

It returns Vec<::rocket::Route>.

If spec_opt is set to None it will not add a route to serve the openapi.json file.

Example:

let settings = animi_rocket_okapi::settings::OpenApiSettings::new();
let spec = animi_rocket_okapi::openapi_spec![get_message, post_message](settings.clone());
let routes = animi_rocket_okapi::openapi_routes![get_message, post_message](Some(spec), settings);