From bf458a02a2993a13e1106fcf9d9d05f1d65c890c Mon Sep 17 00:00:00 2001 From: Hamed Zaghaghi Date: Mon, 6 May 2024 17:04:59 +0200 Subject: [PATCH] hotfix(schema-viewer): invalid schema reference caused application to creash --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 -- src/components/schema_viewer.rs | 7 +++++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00861e4..ce0a773 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1965,7 +1965,7 @@ dependencies = [ [[package]] name = "openapi-tui" -version = "0.9.1" +version = "0.9.2" dependencies = [ "better-panic", "clap", diff --git a/Cargo.toml b/Cargo.toml index 3ddaf76..a226a4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openapi-tui" -version = "0.9.1" +version = "0.9.2" edition = "2021" description = "This TUI allows you to list and browse APIs described by the openapi specification." diff --git a/README.md b/README.md index 2ed70a3..a0e6b8b 100644 --- a/README.md +++ b/README.md @@ -190,8 +190,6 @@ Then, add `openapi-tui` to your `configuration.nix` - [X] Plain Response Viewer (Status + Headers + Body) - [X] History viewer - [X] Refactor footer, add flash footer messages - -# Next Release - [X] Import request body file - [X] Save response body and header - [X] Command history with ↑/↓ diff --git a/src/components/schema_viewer.rs b/src/components/schema_viewer.rs index 2727eba..d102cba 100644 --- a/src/components/schema_viewer.rs +++ b/src/components/schema_viewer.rs @@ -169,7 +169,10 @@ impl SchemaViewer { } fn set_styles_by_name(&mut self, schema_name: String) -> Result<()> { - let schema = self.components.get(schema_name.as_str()).unwrap(); - self.set_styles(schema.clone()) + if let Some(schema) = self.components.get(schema_name.as_str()) { + self.set_styles(schema.clone()) + } else { + Ok(()) + } } }