Skip to content

Commit

Permalink
Preserve key order of objects in JSON responses
Browse files Browse the repository at this point in the history
Closes #405
  • Loading branch information
LucasPickering committed Oct 23, 2024
1 parent daba9e6 commit ac9249a
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

## [Unreleased] - ReleaseDate

### Changes

- Preserve key order of objects in JSON responses [#405](https://github.com/LucasPickering/slumber/issues/405)

## [2.2.0] - 2024-10-22

### Added
Expand Down
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ ratatui = {version = "0.28.0", default-features = false}
reqwest = {version = "0.12.5", default-features = false}
rstest = {version = "0.21.0", default-features = false}
serde = {version = "1.0.204", default-features = false}
serde_json = {version = "1.0.120", default-features = false}
serde_json_path = "0.6.3"
serde_test = "1.0.176"
serde_yaml = {version = "0.9.0", default-features = false}
slumber_cli = {path = "./crates/cli", version = "2.2.0" }
slumber_config = {path = "./crates/config", version = "2.2.0" }
slumber_core = {path = "./crates/core", version = "2.2.0" }
slumber_tui = {path = "./crates/tui", version = "2.2.0" }
slumber_cli = {path = "./crates/cli", version = "2.2.0"}
slumber_config = {path = "./crates/config", version = "2.2.0"}
slumber_core = {path = "./crates/core", version = "2.2.0"}
slumber_tui = {path = "./crates/tui", version = "2.2.0"}
strum = {version = "0.26.3", default-features = false}
tokio = {version = "1.39.2", default-features = false}
tracing = "0.1.40"
Expand Down
3 changes: 1 addition & 2 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ version = "2.2.0"
[dependencies]
anyhow = {workspace = true}
clap = {version = "4.4.2", features = ["derive"]}
clap_complete = { version = "4.5.29", features = ["unstable-dynamic"] }
clap_complete = {version = "4.5.29", features = ["unstable-dynamic"]}
dialoguer = {version = "0.11.0", default-features = false, features = ["password"]}
indexmap = {workspace = true}
itertools = {workspace = true}
Expand All @@ -28,7 +28,6 @@ tracing = {workspace = true}
env-lock = {workspace = true}
pretty_assertions = {workspace = true}
rstest = {workspace = true}
serde_json = {workspace = true}
slumber_core = {workspace = true, features = ["test"]}
tokio = {workspace = true, features = ["rt", "macros"]}

Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ mod tests {
use indexmap::indexmap;
use pretty_assertions::assert_eq;
use rstest::rstest;
use serde_json::json;
use slumber_core::{
collection::{
Chain, ChainSource, Collection, Folder, Method, Profile, Recipe,
Expand Down Expand Up @@ -138,7 +137,8 @@ mod tests {
method: Method::Post,
url: "{{host}}/anything".into(),
body: Some(RecipeBody::Raw {
body: json!({"data": "{{chains.example}}"}).into(),
body: "{\n \"data\": \"{{chains.example}}\"\n}"
.into(),
content_type: Some(ContentType::Json),
}),
..Recipe::factory(())
Expand Down
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rstest = {workspace = true, optional = true}
rusqlite = {version = "0.31.0", default-features = false, features = ["bundled", "chrono", "uuid"]}
rusqlite_migration = "1.2.0"
serde = {workspace = true, features = ["derive"]}
serde_json = {workspace = true}
serde_json = {version = "1.0.120", default-features = false, features = ["preserve_order"]}
serde_json_path = "0.6.3"
serde_yaml = {workspace = true}
strum = {workspace = true, features = ["derive"]}
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/http/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ mod tests {
#[case::object("$.object", r#"{"a":1,"b":2}"#)]
fn test_query_to_string_types(#[case] query: &str, #[case] expected: &str) {
let content = json(json!({
"int": 3,
"bool": true,
"string": "hi!",
"array": ["hi", 1],
"bool": true,
"int": 3,
"object": {"a": 1, "b": 2},
"string": "hi!",
}));
let query = Query::from_str(query).unwrap();
let out = query
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,11 @@ mod tests {

let database = CollectionDatabase::factory(());
let response_body = json!({
"string": "Hello World!",
"number": 6,
"bool": false,
"array": [1, 2],
"bool": false,
"number": 6,
"object": {"a": 1},
"string": "Hello World!",
});
let response_headers =
header_map(indexmap! {"Token" => "Secret Value"});
Expand Down
1 change: 0 additions & 1 deletion crates/tui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ persisted = {version = "0.3.1", features = ["serde"]}
ratatui = {workspace = true, features = ["crossterm", "underline-color", "unstable-widget-ref"]}
reqwest = {workspace = true}
serde = {workspace = true}
serde_json = {workspace = true}
serde_json_path = {workspace = true}
serde_yaml = {workspace = true}
slumber_config = {workspace = true}
Expand Down

0 comments on commit ac9249a

Please sign in to comment.