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::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 = rocket_okapi::settings::OpenApiSettings::new();
let spec = rocket_okapi::openapi_spec![get_message, post_message](settings.clone());
let routes = rocket_okapi::openapi_routes![get_message, post_message](Some(spec), settings);