Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
428 changes: 402 additions & 26 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ repository = "https://github.com/PatOConnor43/heave"
clap = { version = "4.4.18", features = ["derive"] }
itertools = "0.12.1"
minijinja = "1.0.12"
openapiv3 = "2.0.0"
oas3 = { version = "0.21", features = ["yaml-spec"] }
regex-lite = "0.1.6"
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
serde_yaml = "0.9.31"
thiserror = "1.0.57"

[profile.dev.package]
Expand Down
972 changes: 566 additions & 406 deletions src/main.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/snapshots/allof/addPet_200.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ HTTP 200

[Asserts]
jsonpath "$" isCollection
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
#jsonpath "$.category" isCollection
#jsonpath "$.category.id" isInteger
#jsonpath "$.category.name" isString
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
jsonpath "$.photoUrls" isCollection
#jsonpath "$.photoUrls[0]" isString
#jsonpath "$.status" isString
#jsonpath "$.tags" isCollection
#jsonpath "$.tags[0]" isCollection
#jsonpath "$.tags[0].id" isInteger
#jsonpath "$.tags[0].name" isString
#jsonpath "$.status" isString
6 changes: 3 additions & 3 deletions src/snapshots/allof/getPetById_200.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ HTTP 200

[Asserts]
jsonpath "$" isCollection
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
#jsonpath "$.category" isCollection
#jsonpath "$.category.id" isInteger
#jsonpath "$.category.name" isString
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
jsonpath "$.photoUrls" isCollection
#jsonpath "$.photoUrls[0]" isString
#jsonpath "$.status" isString
#jsonpath "$.tags" isCollection
#jsonpath "$.tags[0]" isCollection
#jsonpath "$.tags[0].id" isInteger
#jsonpath "$.tags[0].name" isString
#jsonpath "$.status" isString
6 changes: 3 additions & 3 deletions src/snapshots/allof/updatePet_200.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ HTTP 200

[Asserts]
jsonpath "$" isCollection
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
#jsonpath "$.category" isCollection
#jsonpath "$.category.id" isInteger
#jsonpath "$.category.name" isString
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
jsonpath "$.photoUrls" isCollection
#jsonpath "$.photoUrls[0]" isString
#jsonpath "$.status" isString
#jsonpath "$.tags" isCollection
#jsonpath "$.tags[0]" isCollection
#jsonpath "$.tags[0].id" isInteger
#jsonpath "$.tags[0].name" isString
#jsonpath "$.status" isString
7 changes: 3 additions & 4 deletions src/snapshots/heave__tests__allof_inputs@addPet_200.hurl.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ HTTP 200

[Asserts]
jsonpath "$" isCollection
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
#jsonpath "$.category" isCollection
#jsonpath "$.category.id" isInteger
#jsonpath "$.category.name" isString
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
jsonpath "$.photoUrls" isCollection
#jsonpath "$.photoUrls[0]" isString
#jsonpath "$.status" isString
#jsonpath "$.tags" isCollection
#jsonpath "$.tags[0]" isCollection
#jsonpath "$.tags[0].id" isInteger
#jsonpath "$.tags[0].name" isString
#jsonpath "$.status" isString

Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ HTTP 200

[Asserts]
jsonpath "$" isCollection
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
#jsonpath "$.category" isCollection
#jsonpath "$.category.id" isInteger
#jsonpath "$.category.name" isString
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
jsonpath "$.photoUrls" isCollection
#jsonpath "$.photoUrls[0]" isString
#jsonpath "$.status" isString
#jsonpath "$.tags" isCollection
#jsonpath "$.tags[0]" isCollection
#jsonpath "$.tags[0].id" isInteger
#jsonpath "$.tags[0].name" isString
#jsonpath "$.status" isString

Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ HTTP 200

[Asserts]
jsonpath "$" isCollection
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
#jsonpath "$.category" isCollection
#jsonpath "$.category.id" isInteger
#jsonpath "$.category.name" isString
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
jsonpath "$.photoUrls" isCollection
#jsonpath "$.photoUrls[0]" isString
#jsonpath "$.status" isString
#jsonpath "$.tags" isCollection
#jsonpath "$.tags[0]" isCollection
#jsonpath "$.tags[0].id" isInteger
#jsonpath "$.tags[0].name" isString
#jsonpath "$.status" isString

Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ GenerateResult {
query_parameters: [],
asserts: [
"jsonpath \"$\" isCollection",
"#jsonpath \"$.name\" isString",
"#jsonpath \"$.B\" isCollection",
"#jsonpath \"$.B.name\" isString",
"#jsonpath \"$.B.A\" isCollection",
"#jsonpath \"$.B.A.name\" isString",
"#jsonpath \"$.B.name\" isString",
"#jsonpath \"$.name\" isString",
],
request_body_parameter: "{\n \"name\": \"\"\n}",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GenerateResult {
operation: "addPet",
path: "/pets",
},
kind: "Not",
kind: "Any",
jsonpath: "",
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ GenerateResult {
operation: "addPet",
path: "/pets",
},
kind: "Not",
kind: "Any",
jsonpath: "$",
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
source: src/main.rs
input_file: src/snapshots/oas31_diagnostics/MultipleTypes_RequestBody.yaml
---
GenerateResult {
outputs: [
Output {
expected_status_code: 201,
name: "createItem_201.hurl",
hurl_path: "/items",
oas_path: "/items",
oas_operation_id: Some(
"createItem",
),
method: "POST",
header_parameters: [],
query_parameters: [],
asserts: [
"jsonpath \"$\" isCollection",
],
request_body_parameter: "{\n \"label\": \"\",\n \"value\": 0\n}",
},
],
diagnostics: [],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
source: src/main.rs
input_file: src/snapshots/oas31_diagnostics/MultipleTypes_ResponseBody.yaml
---
GenerateResult {
outputs: [
Output {
expected_status_code: 200,
name: "getItem_200.hurl",
hurl_path: "/items",
oas_path: "/items",
oas_operation_id: Some(
"getItem",
),
method: "GET",
header_parameters: [],
query_parameters: [],
asserts: [
"jsonpath \"$\" isCollection",
"jsonpath \"$.id\" isInteger",
"#jsonpath \"$.label\" isString",
"#jsonpath \"$.value\" isInteger",
"#jsonpath \"$.value\" isString",
],
request_body_parameter: "",
},
],
diagnostics: [],
}
28 changes: 28 additions & 0 deletions src/snapshots/heave__tests__oas31_petstore@createPet_201.hurl.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
source: src/main.rs
input_file: src/snapshots/oas31/createPet_201.hurl
---
POST {{ baseurl }}/pets
Authorization: Bearer {{ authorization }}
Prefer: code=201
{
"age": 0,
"code": 0,
"name": "",
"tag": ""
}
HTTP 201

[Asserts]
jsonpath "$" isCollection
#jsonpath "$.age" isInteger
#jsonpath "$.aliases" isCollection
#jsonpath "$.aliases[0]" isString
#jsonpath "$.code" isInteger
#jsonpath "$.code" isString
jsonpath "$.id" isInteger
#jsonpath "$.metadata" isCollection
#jsonpath "$.metadata.source" isString
jsonpath "$.name" isString
#jsonpath "$.tag" isString
#jsonpath "$.weight" isNumber
23 changes: 23 additions & 0 deletions src/snapshots/heave__tests__oas31_petstore@getPet_200.hurl.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
source: src/main.rs
input_file: src/snapshots/oas31/getPet_200.hurl
---
GET {{ baseurl }}/pets/{{petId}}
Authorization: Bearer {{ authorization }}
Prefer: code=200

HTTP 200

[Asserts]
jsonpath "$" isCollection
#jsonpath "$.age" isInteger
#jsonpath "$.aliases" isCollection
#jsonpath "$.aliases[0]" isString
#jsonpath "$.code" isInteger
#jsonpath "$.code" isString
jsonpath "$.id" isInteger
#jsonpath "$.metadata" isCollection
#jsonpath "$.metadata.source" isString
jsonpath "$.name" isString
#jsonpath "$.tag" isString
#jsonpath "$.weight" isNumber
24 changes: 24 additions & 0 deletions src/snapshots/heave__tests__oas31_petstore@listPets_200.hurl.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
source: src/main.rs
input_file: src/snapshots/oas31/listPets_200.hurl
---
GET {{ baseurl }}/pets
Authorization: Bearer {{ authorization }}
Prefer: code=200

HTTP 200

[Asserts]
jsonpath "$" isCollection
#jsonpath "$[0]" isCollection
#jsonpath "$[0].age" isInteger
#jsonpath "$[0].aliases" isCollection
#jsonpath "$[0].aliases[0]" isString
#jsonpath "$[0].code" isInteger
#jsonpath "$[0].code" isString
#jsonpath "$[0].id" isInteger
#jsonpath "$[0].metadata" isCollection
#jsonpath "$[0].metadata.source" isString
#jsonpath "$[0].name" isString
#jsonpath "$[0].tag" isString
#jsonpath "$[0].weight" isNumber
8 changes: 3 additions & 5 deletions src/snapshots/heave__tests__petstore@addPet_200.hurl.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ HTTP 200

[Asserts]
jsonpath "$" isCollection
#jsonpath "$.id" isInteger
jsonpath "$.name" isString
#jsonpath "$.category" isCollection
#jsonpath "$.category.id" isInteger
#jsonpath "$.category.name" isString
#jsonpath "$.id" isInteger

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetized output on asserts is an acceptable change for the snapshots 👍

jsonpath "$.name" isString
jsonpath "$.photoUrls" isCollection
#jsonpath "$.photoUrls[0]" isString
#jsonpath "$.status" isString
#jsonpath "$.tags" isCollection
#jsonpath "$.tags[0]" isCollection
#jsonpath "$.tags[0].id" isInteger
#jsonpath "$.tags[0].name" isString
#jsonpath "$.status" isString


Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ HTTP 200

[Asserts]
jsonpath "$" isCollection
#jsonpath "$.id" isInteger
#jsonpath "$.username" isString
#jsonpath "$.email" isString
#jsonpath "$.firstName" isString
#jsonpath "$.id" isInteger
#jsonpath "$.lastName" isString
#jsonpath "$.email" isString
#jsonpath "$.password" isString
#jsonpath "$.phone" isString
#jsonpath "$.userStatus" isInteger

#jsonpath "$.username" isString
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ HTTP 200
[Asserts]
jsonpath "$" isCollection
#jsonpath "$[0]" isCollection
#jsonpath "$[0].id" isInteger
#jsonpath "$[0].name" isString
#jsonpath "$[0].category" isCollection
#jsonpath "$[0].category.id" isInteger
#jsonpath "$[0].category.name" isString
#jsonpath "$[0].id" isInteger
#jsonpath "$[0].name" isString
#jsonpath "$[0].photoUrls" isCollection
#jsonpath "$[0].photoUrls[0]" isString
#jsonpath "$[0].status" isString
#jsonpath "$[0].tags" isCollection
#jsonpath "$[0].tags[0]" isCollection
#jsonpath "$[0].tags[0].id" isInteger
#jsonpath "$[0].tags[0].name" isString
#jsonpath "$[0].status" isString

Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ HTTP 200
[Asserts]
jsonpath "$" isCollection
#jsonpath "$[0]" isCollection
#jsonpath "$[0].id" isInteger
#jsonpath "$[0].name" isString
#jsonpath "$[0].category" isCollection
#jsonpath "$[0].category.id" isInteger
#jsonpath "$[0].category.name" isString
#jsonpath "$[0].id" isInteger
#jsonpath "$[0].name" isString
#jsonpath "$[0].photoUrls" isCollection
#jsonpath "$[0].photoUrls[0]" isString
#jsonpath "$[0].status" isString
#jsonpath "$[0].tags" isCollection
#jsonpath "$[0].tags[0]" isCollection
#jsonpath "$[0].tags[0].id" isInteger
#jsonpath "$[0].tags[0].name" isString
#jsonpath "$[0].status" isString

Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ HTTP 200

[Asserts]
jsonpath "$" isCollection
#jsonpath "$.complete" isBoolean
#jsonpath "$.id" isInteger
#jsonpath "$.petId" isInteger
#jsonpath "$.quantity" isInteger
#jsonpath "$.shipDate" isString
#jsonpath "$.status" isString
#jsonpath "$.complete" isBoolean

Loading