Skip to content

Commit

Permalink
[POSTMAN] Mark request header as disabled (#16028)
Browse files Browse the repository at this point in the history
* Disable headers without a value

* Update samples
  • Loading branch information
gcatanese committed Jul 7, 2023
1 parent 30d6a2f commit 2aa7580
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
{{#headerParams}}
{
"key": "{{baseName}}",
"value": "{{schema.defaultValue}}"
"value": "{{schema.defaultValue}}",
"disabled": {{#schema.defaultValue}}false{{/schema.defaultValue}}{{^schema.defaultValue}}true{{/schema.defaultValue}}
}{{^-last}},{{/-last}}
{{/headerParams}}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,11 @@ public void testHeaderParameters() throws IOException {
TestUtils.assertFileExists(path);
TestUtils.assertFileContains(path, "{ \"key\": \"Content-Type\", \"value\": \"application/json\"");
TestUtils.assertFileContains(path, "{ \"key\": \"Accept\", \"value\": \"application/json\"");
// header without default value
TestUtils.assertFileContains(path, "{ \"key\": \"Custom-Header\", \"value\": \"\"");
// header with default value
TestUtils.assertFileContains(path, "{ \"key\": \"Another-Custom-Header\", \"value\": \"abc\"");
// header without default value (disabled: true)
TestUtils.assertFileContains(path, "{ \"key\": \"Custom-Header\", \"value\": \"\", \"disabled\": true");
// header with default value (disabled: false)
TestUtils.assertFileContains(path, "{ \"key\": \"Another-Custom-Header\", \"value\": \"abc\", \"disabled\": false");

}


Expand Down
36 changes: 24 additions & 12 deletions samples/schema/postman-collection/postman.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@
"header": [
{
"key": "Content-Type",
"value": "application/json"
"value": "application/json",
"disabled": false
},
{
"key": "Accept",
"value": "application/json"
"value": "application/json",
"disabled": false
},
{
"key": "strCode",
"value": "code_one"
"value": "code_one",
"disabled": false
},
{
"key": "strCode2",
"value": ""
"value": "",
"disabled": true
}
],
"body": {
Expand Down Expand Up @@ -134,15 +138,18 @@
"header": [
{
"key": "Accept",
"value": "application/json"
"value": "application/json",
"disabled": false
},
{
"key": "strCode",
"value": "code_one"
"value": "code_one",
"disabled": false
},
{
"key": "strCode2",
"value": ""
"value": "",
"disabled": true
}
],
"body": {
Expand Down Expand Up @@ -194,15 +201,18 @@
"header": [
{
"key": "Accept",
"value": "application/json"
"value": "application/json",
"disabled": false
},
{
"key": "Custom-Header",
"value": ""
"value": "",
"disabled": true
},
{
"key": "Another-Custom-Header",
"value": "abc"
"value": "abc",
"disabled": false
}
],
"body": {
Expand Down Expand Up @@ -247,11 +257,13 @@
"header": [
{
"key": "Content-Type",
"value": "application/json"
"value": "application/json",
"disabled": false
},
{
"key": "Accept",
"value": "application/json"
"value": "application/json",
"disabled": false
}
],
"body": {
Expand Down

0 comments on commit 2aa7580

Please sign in to comment.