Skip to content

Commit

Permalink
Validate entry types
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRobb committed Jul 16, 2021
1 parent bdfce47 commit 2af69fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
16 changes: 16 additions & 0 deletions src/beacon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 11 additions & 4 deletions src/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf, Json>,
}

Expand Down Expand Up @@ -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(),
};

Expand Down Expand Up @@ -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();
}
}

0 comments on commit 2af69fd

Please sign in to comment.