Skip to content
This repository was archived by the owner on May 15, 2023. It is now read-only.

Commit 38d1a79

Browse files
committed
fix bug not set header param
1 parent 3347bf8 commit 38d1a79

File tree

12 files changed

+17
-38
lines changed

12 files changed

+17
-38
lines changed

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,6 @@ handlebars.registerHelper('isXmlMediaType', helpers.isXmlMediaType);
580580
handlebars.registerHelper('isPdfMediaType', helpers.isPdfMediaType);
581581
handlebars.registerHelper('isNecessaryBody', helpers.isNecessaryBody);
582582

583-
584583
module.exports = {
585584
testGen: testGen
586585
};

templates/request/get/get.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
method: 'GET',
125125
headers: {
126126
'Content-Type': '{{contentType}}'{{#if headerParameters}},
127-
{{#each headerParameters}}'{{this.name}}': 'DATA GOES HERE'{{#unless @last}},{{/unless}}{{/each}}{{/if}}{{#if headerApiKey}},
127+
{{#each headerParameters}}'{{this.name}}': {{requestDataParamFormatter this.name 'string' ../requestParameters}}{{#unless @last}},{{/unless}}{{/each}}{{/if}}{{#if headerApiKey}},
128128
{{headerApiKey.type}}: process.env.{{headerApiKey.name}}{{/if}}{{#if headerSecurity}},
129129
Authorization: '{{headerSecurity.type}} ' + process.env.{{headerSecurity.name}}{{/if}}
130130
}

templates/request/patch/patch.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
method: 'PATCH',
154154
headers: {
155155
'Content-Type': '{{contentType}}'{{#if headerParameters}},
156-
{{#each headerParameters}}'{{this.name}}': 'DATA GOES HERE'{{#unless @last}},{{/unless}}{{/each}}{{/if}}{{#if headerApiKey}},
156+
{{#each headerParameters}}'{{this.name}}': {{requestDataParamFormatter this.name 'string' ../requestParameters}}{{#unless @last}},{{/unless}}{{/each}}{{/if}}{{#if headerApiKey}},
157157
{{headerApiKey.type}}: process.env.{{headerApiKey.name}}{{/if}}{{#if headerSecurity}},
158158
Authorization: '{{headerSecurity.type}} ' + process.env.{{headerSecurity.name}}{{/if}}
159159
},

templates/request/post/post.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
method: 'POST',
152152
headers: {
153153
'Content-Type': '{{contentType}}'{{#if headerParameters}},
154-
{{#each headerParameters}}'{{this.name}}': 'DATA GOES HERE'{{#unless @last}},{{/unless}}{{/each}}{{/if}}{{#if headerApiKey}},
154+
{{#each headerParameters}}'{{this.name}}': {{requestDataParamFormatter this.name 'string' ../requestParameters}}{{#unless @last}},{{/unless}}{{/each}}{{/if}}{{#if headerApiKey}},
155155
{{headerApiKey.type}}: process.env.{{headerApiKey.name}}{{/if}}{{#if headerSecurity}},
156156
Authorization: '{{headerSecurity.type}} ' + process.env.{{headerSecurity.name}}{{/if}}
157157
},

templates/request/put/put.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
method: 'PUT',
152152
headers: {
153153
'Content-Type': '{{contentType}}'{{#if headerParameters}},
154-
{{#each headerParameters}}'{{this.name}}': 'DATA GOES HERE'{{#unless @last}},{{/unless}}{{/each}}{{/if}}{{#if headerApiKey}},
154+
{{#each headerParameters}}'{{this.name}}': {{requestDataParamFormatter this.name 'string' ../requestParameters}}{{#unless @last}},{{/unless}}{{/each}}{{/if}}{{#if headerApiKey}},
155155
{{headerApiKey.type}}: process.env.{{headerApiKey.name}}{{/if}}{{#if headerSecurity}},
156156
Authorization: '{{headerSecurity.type}} ' + process.env.{{headerSecurity.name}}{{/if}}
157157
},

templates/supertest/delete/delete.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{{#if headerParameters}}
2121
.set({
2222
{{#each headerParameters}}
23-
'{{this.name}}': 'DATA GOES HERE'{{#unless @last}},{{/unless}}
23+
'{{this.name}}': {{requestDataParamFormatter this.name 'string' ../requestParameters}}{{#unless @last}},{{/unless}}
2424
{{/each}}
2525
})
2626
{{/if}}

templates/supertest/get/get.handlebars

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{{#if headerParameters}}
2121
.set({
2222
{{#each headerParameters}}
23-
'{{this.name}}': 'DATA GOES HERE'{{#unless @last}},{{/unless}}
23+
'{{this.name}}': {{requestDataParamFormatter this.name 'string' ../requestParameters}}{{#unless @last}},{{/unless}}
2424
{{/each}}
2525
})
2626
{{/if}}
@@ -113,7 +113,7 @@
113113
{{#if headerParameters}}
114114
.set({
115115
{{#each headerParameters}}
116-
'{{this.name}}': 'DATA GOES HERE'{{#unless @last}},{{/unless}}
116+
'{{this.name}}': {{requestDataParamFormatter this.name 'string' ../requestParameters}}{{#unless @last}},{{/unless}}
117117
{{/each}}
118118
})
119119
{{/if}}

templates/supertest/head/head.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{{#if headerParameters}}
2121
.set({
2222
{{#each headerParameters}}
23-
'{{this.name}}': 'DATA GOES HERE'{{#unless @last}},{{/unless}}
23+
'{{this.name}}': {{requestDataParamFormatter this.name 'string' ../requestParameters}}{{#unless @last}},{{/unless}}
2424
{{/each}}
2525
})
2626
{{/if}}

templates/supertest/options/options.handlebars

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{{#if headerParameters}}
2121
.set({
2222
{{#each headerParameters}}
23-
'{{this.name}}': 'DATA GOES HERE'{{#unless @last}},{{/unless}}
23+
'{{this.name}}': {{requestDataParamFormatter this.name 'string' ../requestParameters}}{{#unless @last}},{{/unless}}
2424
{{/each}}
2525
})
2626
{{/if}}
@@ -81,7 +81,7 @@
8181
{{#if headerParameters}}
8282
.set({
8383
{{#each headerParameters}}
84-
'{{this.name}}': 'DATA GOES HERE'{{#unless @last}},{{/unless}}
84+
'{{this.name}}': {{requestDataParamFormatter this.name 'string' ../requestParameters}}{{#unless @last}},{{/unless}}
8585
{{/each}}
8686
})
8787
{{/if}}

templates/supertest/patch/patch.handlebars

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{{#if headerParameters}}
2121
.set({
2222
{{#each headerParameters}}
23-
'{{this.name}}': 'DATA GOES HERE'{{#unless @last}},{{/unless}}
23+
'{{this.name}}': {{requestDataParamFormatter this.name 'string' ../requestParameters}}{{#unless @last}},{{/unless}}
2424
{{/each}}
2525
})
2626
{{/if}}
@@ -61,7 +61,6 @@
6161
if (err) return done(err);
6262

6363
{{#validateResponse returnType noSchema}}
64-
{{#isJsonMediaType returnType}}
6564
{{#is assertion 'expect'}}
6665
expect(validator.validate(res.body, schema)).to.be.true;
6766
{{/is}}
@@ -71,25 +70,6 @@
7170
{{#is assertion 'assert'}}
7271
assert.true(validator.validate(res.body, schema));
7372
{{/is}}
74-
done();
75-
{{/isJsonMediaType}}
76-
{{#isXmlMediaType returnType}}
77-
var xml2jsConfig = {{xml2jsConfig}};
78-
79-
parseString(res.text, xml2jsConfig, function(parseErr, result) {
80-
if (parseErr) return done(parseErr);
81-
{{#is assertion 'expect'}}
82-
expect(validator.validate(result, schema)).to.be.true;
83-
{{/is}}
84-
{{#is assertion 'should'}}
85-
validator.validate(result, schema).should.be.true;
86-
{{/is}}
87-
{{#is assertion 'assert'}}
88-
assert.true(validator.validate(result, schema));
89-
{{/is}}
90-
done();
91-
});
92-
{{/isXmlMediaType}}
9373
{{else}}
9474
{{#isPdfMediaType returnType}}
9575
{{#is assertion 'expect'}}
@@ -112,8 +92,8 @@
11292
assert.isNull(res.body); // non-json response or no schema
11393
{{/is}}
11494
{{/isPdfMediaType}}
115-
done();
11695
{{/validateResponse}}
96+
done();
11797
});
11898
});
11999
{{#if isLoadTest}}
@@ -147,7 +127,7 @@
147127
{{#is contentType 'application/json'}}
148128
.send({
149129
{{#each bodyParameters}}
150-
'{{this.name}}': 'DATA GOES HERE'{{#unless @last}},{{/unless}}
130+
'{{this.name}}': {{requestDataParamFormatter this.name 'string' ../requestParameters}}{{#unless @last}},{{/unless}}
151131
{{/each}}
152132
})
153133
{{/is}}

0 commit comments

Comments
 (0)