Add swagger for validator-api (#1239)
* validator-api: add swagger openapi * Lock file
This commit is contained in:
@@ -19,6 +19,8 @@ use rocket::fairing::AdHoc;
|
||||
use rocket::http::Method;
|
||||
use rocket::{Ignite, Rocket};
|
||||
use rocket_cors::{AllowedHeaders, AllowedOrigins, Cors};
|
||||
use rocket_okapi::settings::UrlObject;
|
||||
use rocket_okapi::swagger_ui::{make_swagger_ui, SwaggerUIConfig};
|
||||
use std::process;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -398,6 +400,7 @@ async fn setup_rocket(
|
||||
) -> Result<Rocket<Ignite>> {
|
||||
// let's build our rocket!
|
||||
let rocket = rocket::build()
|
||||
.mount("/swagger", make_swagger_ui(&get_docs()))
|
||||
.attach(setup_cors()?)
|
||||
.attach(setup_liftoff_notify(liftoff_notify))
|
||||
.attach(ValidatorCache::stage());
|
||||
@@ -436,6 +439,16 @@ async fn setup_rocket(
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_docs() -> SwaggerUIConfig {
|
||||
SwaggerUIConfig {
|
||||
urls: vec![
|
||||
UrlObject::new("Contract cache", "../v1/openapi.json"),
|
||||
UrlObject::new("Node status", "../v1/status/openapi.json"),
|
||||
],
|
||||
..SwaggerUIConfig::default()
|
||||
}
|
||||
}
|
||||
|
||||
async fn run_validator_api(matches: ArgMatches<'static>) -> Result<()> {
|
||||
let system_version = env!("CARGO_PKG_VERSION");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user