Skip to content

Commit

Permalink
Updating Postman schema to have domain and path optional on cookies. …
Browse files Browse the repository at this point in the history
…Allowing for null response bodies in Postman examples.
  • Loading branch information
kevinswiber committed Nov 21, 2023
1 parent 5e0389f commit 0e2a0c5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ impl<'a> Transpiler<'a> {
existing_response.headers = Some(cloned_headers);
}

let mut existing_content = existing_response.content.clone().unwrap();
let mut existing_content =
existing_response.content.clone().unwrap_or_default();
for (media_type, new_content) in new_response.content.unwrap() {
if let Some(existing_response_content) =
existing_content.get_mut(&media_type)
Expand Down
4 changes: 2 additions & 2 deletions src/postman/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ pub struct ResponseClass {
pub struct Cookie {
/// The domain for which this cookie is valid.
#[serde(rename = "domain")]
pub domain: String,
pub domain: Option<String>,

/// When the cookie expires.
#[serde(rename = "expires")]
Expand Down Expand Up @@ -701,7 +701,7 @@ pub struct Cookie {

/// The path associated with the Cookie.
#[serde(rename = "path")]
pub path: String,
pub path: Option<String>,

/// Indicates if the 'secure' flag is set on the Cookie, meaning that it is transmitted over
/// secure connections only. (typically HTTPS)
Expand Down
4 changes: 1 addition & 3 deletions tests/fixtures/echo.postman.json
Original file line number Diff line number Diff line change
Expand Up @@ -3944,14 +3944,12 @@
{
"expires": "Invalid Date",
"httpOnly": true,
"domain": "postman-echo.com",
"path": "/",
"secure": false,
"value": "s%3A55y5Ll7HpTzt_hKuw6N54k4N04ilmMdn.uCPCHttP5DmI%2BdBw2I9NZL55lFFOzz4XxS4qAHv47gI",
"key": "sails.sid"
}
],
"body": "{\"id\":\"0c42230c-c8e4-4ca0-a4aa-d393971de8b8\",\"name\":\"Sample Postman Collection\",\"description\":\"A sample collection to demonstrate collections as a set of related requests\",\"order\":[\"3d04ed83-dc1e-40ec-923c-16aa92509e50\",\"e02f8160-fb41-4633-be80-cc7d701e85b4\",\"77bd6d4d-1060-4927-aa5c-dcdba7f750cf\"],\"folders\":[],\"requests\":[{\"id\":\"3d04ed83-dc1e-40ec-923c-16aa92509e50\",\"name\":\"A simple GET request\",\"collectionId\":\"1dd68aff-a3fa-4f52-904f-5b75053bc9d9\",\"method\":\"GET\",\"headers\":\"\",\"data\":[],\"rawModeData\":\"\",\"tests\":\"tests['response code is 200'] = (responseCode.code === 200);\",\"preRequestScript\":\"\",\"url\":\"https://postman-echo.com/get?source=newman-sample-github-collection\"},{\"id\":\"e02f8160-fb41-4633-be80-cc7d701e85b4\",\"name\":\"A simple POST request\",\"collectionId\":\"1dd68aff-a3fa-4f52-904f-5b75053bc9d9\",\"method\":\"POST\",\"headers\":\"Content-Type: text/plain\",\"dataMode\":\"raw\",\"data\":[],\"rawModeData\":\"Duis posuere augue vel cursus pharetra. In luctus a ex nec pretium...\",\"url\":\"https://postman-echo.com/post\"},{\"id\":\"77bd6d4d-1060-4927-aa5c-dcdba7f750cf\",\"name\":\"A simple POST request with JSON body\",\"collectionId\":\"1dd68aff-a3fa-4f52-904f-5b75053bc9d9\",\"method\":\"POST\",\"headers\":\"Content-Type: application/json\",\"dataMode\":\"raw\",\"data\":[],\"rawModeData\":\"{\\\"text\\\":\\\"Duis posuere augue vel cursus pharetra. In luctus a ex nec pretium...\\\"}\",\"url\":\"https://postman-echo.com/post\"}]}"
"body": null
}
]
}
Expand Down

0 comments on commit 0e2a0c5

Please sign in to comment.