-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement data sanitation workaround
Implement a workaround in dealing with potentially unsanitary response data with NetBox. * Add a list of confirmed troublesome structs * Add checks at struct generation and mark all fields of unsanitary structs as Option
- Loading branch information
Showing
6 changed files
with
88 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//! Various supporting functionality. | ||
/// Names of NetBox API objects which can cause the client to crash at response data serialization. | ||
/// | ||
/// This workaround is necessary as a lot of the time, some database entries can have fieds set to | ||
/// `null` even though the API schema states that they are not nullable. | ||
/// This leads to problems when creating an API client crate just by using the YAML schema as the | ||
/// client then expects all response data to be correct, otherwise `serde` cannot build the | ||
/// required structs. | ||
/// | ||
/// To work around this, the `--workaround` flag was added to Thanix, which will check at struct | ||
/// generation, whether the struct is part of this **manually maintained list of troublemakers** | ||
/// | ||
/// > [!Note] | ||
/// > This list is maintained manually by the Nazara Team, as there is currently no real way to | ||
/// automate this. | ||
/// > If you have problems and need something to be added to it, please open a bug in our [issues | ||
/// section](https://github.com/The-Nazara-Project/Thanix/issues/). | ||
static UNSANITARY_OBJECTS: &[&str] = &["interface"]; | ||
|
||
/// Check if a given struct's name contains any entry from the `UNSANITARY_OBJECTS` list. | ||
pub fn is_unsanitary(name: &str) -> bool { | ||
UNSANITARY_OBJECTS.iter().any(|&word| name.contains(word)) | ||
} |