From 2af69fdce4ef1fe5209c6a0f6370dc92fafb2f66 Mon Sep 17 00:00:00 2001 From: Roberto Date: Fri, 16 Jul 2021 18:56:37 +0200 Subject: [PATCH] Validate entry types --- src/beacon.rs | 16 ++++++++++++++++ src/framework.rs | 15 +++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/beacon.rs b/src/beacon.rs index b90675b..02124c5 100644 --- a/src/beacon.rs +++ b/src/beacon.rs @@ -171,6 +171,22 @@ impl Beacon { valid, }); + // Validate entry types + let mut entry_types_url = self.url.clone(); + entry_types_url.set_path(Path::new(self.url.path()).join("entry_types").to_str().unwrap_or("")); + let valid = match utils::ping_url(&entry_types_url) { + Ok(entry_types_json) => self.valid_schema(&self.framework.entry_types_json, &entry_types_json), + Err(e) => { + log::error!("{}", e); + None + }, + }; + output.push(EndpointOutput { + name: "EntryTypes".into(), + url: entry_types_url, + valid, + }); + // Validate endpoints configuration // TODO: Validate OpenAPI 3.0 diff --git a/src/framework.rs b/src/framework.rs index dcbb134..c019841 100644 --- a/src/framework.rs +++ b/src/framework.rs @@ -13,6 +13,7 @@ use crate::{utils, Json}; pub struct Framework { pub configuration_json: Json, pub beacon_map_json: Json, + pub entry_types_json: Json, files: HashMap, } @@ -51,6 +52,7 @@ impl Framework { let mut framework = Self { configuration_json: Json::Null, beacon_map_json: Json::Null, + entry_types_json: Json::Null, files: HashMap::new(), }; @@ -78,13 +80,18 @@ impl Framework { fn load_configuration(&mut self, base_path: &Path) { self.beacon_map_json = self .files - .get(&base_path.join("configuration").join("beaconMapSchema.json")) - .expect("beaconMapSchema.json not found") + .get(&base_path.join("responses").join("beaconMapResponse.json")) + .expect("beaconMapResponse.json not found") .clone(); self.configuration_json = self .files - .get(&base_path.join("configuration").join("beaconConfigurationSchema.json")) - .expect("beaconConfigurationSchema.json not found") + .get(&base_path.join("responses").join("beaconConfigurationResponse.json")) + .expect("beaconConfigurationResponse.json not found") + .clone(); + self.entry_types_json = self + .files + .get(&base_path.join("responses").join("beaconEntryTypesResponse.json")) + .expect("beaconEntryTypesResponse.json not found") .clone(); } }