Skip to content

Commit 60508e2

Browse files
committed
Merge branch 'bug/swagger-ui-3511' of github.com:owenconti/swagger-js into bug/swagger-ui-3511
2 parents b2ea186 + e250dd3 commit 60508e2

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

src/execute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function buildRequest({
121121
value = parameters
122122
}
123123

124-
value = parameter && parameter.name && parameters[parameter.name]
124+
value = parameter && parameter.name && parameters[`${parameter.name}-${parameter.in}`]
125125

126126
if (typeof value === 'undefined') {
127127
// check for `name-in` formatted key

test/execute.js

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ describe('execute', () => {
146146
}
147147

148148
// When
149-
const req = buildRequest({spec, operationId: 'getMe', parameters: {petId: 123}})
149+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'petId-query': 123}})
150150

151151
// Then
152152
expect(req).toEqual({
@@ -177,7 +177,7 @@ describe('execute', () => {
177177
}
178178

179179
// When
180-
const req = buildRequest({spec, operationId: 'getMe', parameters: {fields: '[articles]=title'}})
180+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'fields-query': '[articles]=title'}})
181181

182182
// Then
183183
expect(req).toEqual({
@@ -231,8 +231,8 @@ describe('execute', () => {
231231
spec,
232232
operationId: 'getMe',
233233
parameters: {
234-
false: false,
235-
zero: 0
234+
'false-query': false,
235+
'zero-query': 0
236236
}
237237
})
238238

@@ -265,7 +265,7 @@ describe('execute', () => {
265265
}
266266

267267
// When
268-
const req = buildRequest({spec, operationId: 'getMe', parameters: {petId: true}})
268+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'petId-query': true}})
269269

270270
// Then
271271
expect(req).toEqual({
@@ -395,7 +395,7 @@ describe('execute', () => {
395395
}
396396

397397
// When
398-
const req = buildRequest({spec, operationId: 'getMe', parameters: {petId: [1, 2, 3]}})
398+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'petId-formData': [1, 2, 3]}})
399399

400400
// Then
401401
expect(req.body).toEqual('petId=1,2,3')
@@ -458,7 +458,7 @@ describe('execute', () => {
458458
}
459459

460460
// When
461-
const req = buildRequest({spec, operationId: 'getMe', parameters: {status: false}})
461+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'status-query': false}})
462462

463463
// Then
464464
expect(req).toEqual({
@@ -538,7 +538,7 @@ describe('execute', () => {
538538
}
539539
}
540540

541-
const req = buildRequest({spec, operationId: 'loginUser', parameters: {username: 'fred', password: 'meyer'}})
541+
const req = buildRequest({spec, operationId: 'loginUser', parameters: {'username-query': 'fred', 'password-query': 'meyer'}})
542542

543543
expect(req).toEqual({
544544
url: 'http://swagger.io/v1/one?username=fred&password=meyer',
@@ -618,7 +618,7 @@ describe('execute', () => {
618618
const req = buildRequest({
619619
spec,
620620
operationId: 'postMe',
621-
parameters: {file: 'test'}})
621+
parameters: {'file-formData': 'test'}})
622622

623623
// Then
624624
expect(req).toEqual({
@@ -651,7 +651,7 @@ describe('execute', () => {
651651
const req = buildRequest({
652652
spec,
653653
operationId: 'postMe',
654-
parameters: {file: 'test'}})
654+
parameters: {'file-formData': 'test'}})
655655

656656
// Then
657657
expect(req).toEqual({
@@ -685,7 +685,7 @@ describe('execute', () => {
685685
const req = buildRequest({
686686
spec,
687687
operationId: 'postMe',
688-
parameters: {file: 'test'}})
688+
parameters: {'file-formData': 'test'}})
689689

690690
// Then
691691
expect(req).toEqual({
@@ -752,10 +752,10 @@ describe('execute', () => {
752752
const req = buildRequest({spec,
753753
operationId: 'getMe',
754754
parameters: {
755-
head: 'justTheHead',
756-
two: '2',
757-
body: {json: 'rulez'},
758-
question: 'answer'
755+
'head-header': 'justTheHead',
756+
'two-path': '2',
757+
'body-body': {json: 'rulez'},
758+
'question-query': 'answer'
759759
}})
760760

761761
// Then
@@ -783,7 +783,7 @@ describe('execute', () => {
783783
spec,
784784
operationId: 'makeMe',
785785
parameters: {
786-
body: {
786+
'body-body': {
787787
one: 1,
788788
}
789789
}})
@@ -832,7 +832,7 @@ describe('execute', () => {
832832
spec,
833833
operationId: 'makeMe',
834834
parameters: {
835-
body: {
835+
'body-body': {
836836
one: 1,
837837
two: {
838838
three: 3
@@ -859,7 +859,7 @@ describe('execute', () => {
859859
spec,
860860
operationId: 'makeMe',
861861
parameters: {
862-
body: 'hello'
862+
'body-body': 'hello'
863863
}
864864
})
865865

@@ -1083,7 +1083,7 @@ describe('execute', () => {
10831083
}
10841084

10851085
// When
1086-
const req = buildRequest({spec, operationId: 'getMe', parameters: {petId: ['a,b']}})
1086+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'petId-query': ['a,b']}})
10871087

10881088
// Then
10891089
expect(req).toEqual({
@@ -1129,7 +1129,7 @@ describe('execute', () => {
11291129
}
11301130

11311131
// When
1132-
const req = buildRequest({spec, operationId: 'getMe', parameters: {ids: [1, 2, 3], 'the names': ['a,b', 'mary']}})
1132+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'ids-query': [1, 2, 3], 'the names-query': ['a,b', 'mary']}})
11331133

11341134
// Then
11351135
expect(req).toEqual({
@@ -1164,7 +1164,7 @@ describe('execute', () => {
11641164
}
11651165

11661166
// When
1167-
const req = buildRequest({spec, operationId: 'getMe', parameters: {petId: [1, 2, 3]}})
1167+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'petId-query': [1, 2, 3]}})
11681168

11691169
// Then
11701170
expect(req).toEqual({
@@ -1199,7 +1199,7 @@ describe('execute', () => {
11991199
}
12001200

12011201
// When
1202-
const req = buildRequest({spec, operationId: 'getMe', parameters: {petId: [1, 2, 3]}})
1202+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'petId-query': [1, 2, 3]}})
12031203

12041204
// Then
12051205
expect(req).toEqual({
@@ -1234,7 +1234,7 @@ describe('execute', () => {
12341234
}
12351235

12361236
// When
1237-
const req = buildRequest({spec, operationId: 'getMe', parameters: {petId: [1, 2, 3]}})
1237+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'petId-query': [1, 2, 3]}})
12381238

12391239
// Then
12401240
expect(req).toEqual({
@@ -1269,7 +1269,7 @@ describe('execute', () => {
12691269
}
12701270

12711271
// When
1272-
const req = buildRequest({spec, operationId: 'getMe', parameters: {petId: [1, 2, 3]}})
1272+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'petId-query': [1, 2, 3]}})
12731273

12741274
// Then
12751275
expect(req).toEqual({
@@ -1304,7 +1304,7 @@ describe('execute', () => {
13041304
}
13051305

13061306
// When
1307-
const req = buildRequest({spec, operationId: 'getMe', parameters: {name: ['john', 'smith']}})
1307+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'name-query': ['john', 'smith']}})
13081308

13091309
// Then
13101310
expect(req).toEqual({
@@ -1403,11 +1403,11 @@ describe('execute', () => {
14031403
spec: spec2,
14041404
operationId: 'getBlob',
14051405
parameters: {
1406-
bodyParam: {
1406+
'bodyParam-body': {
14071407
name: 'johny',
14081408
id: '123'
14091409
},
1410-
someQuery: 'foo',
1410+
'someQuery-query': 'foo',
14111411
}})
14121412

14131413

@@ -1424,7 +1424,7 @@ describe('execute', () => {
14241424
})
14251425

14261426
it('should not add values of body parameters to the URL', function () {
1427-
const req = buildRequest({spec, operationId: 'postMe', parameters: {petId: 123}})
1427+
const req = buildRequest({spec, operationId: 'postMe', parameters: {'petId-body': 123}})
14281428

14291429

14301430
expect(req).toEqual({
@@ -1480,7 +1480,7 @@ describe('execute', () => {
14801480
})
14811481

14821482
it('should generate a request with body parameter', function () {
1483-
const req = buildRequest({spec, operationId: 'deleteMe', parameters: {petId: 123}})
1483+
const req = buildRequest({spec, operationId: 'deleteMe', parameters: {'petId-body': 123}})
14841484

14851485
expect(req).toEqual({
14861486
url: 'http://swagger.io/v1/one',
@@ -1512,7 +1512,7 @@ describe('execute', () => {
15121512
}
15131513
}
15141514

1515-
const req = buildRequest({spec, operationId: 'deleteMe', parameters: {api_key: 123}})
1515+
const req = buildRequest({spec, operationId: 'deleteMe', parameters: {'api_key-header': 123}})
15161516

15171517
expect(req).toEqual({
15181518
url: 'http://swagger.io/v1/one',
@@ -1633,7 +1633,7 @@ describe('execute', () => {
16331633
}
16341634
}
16351635

1636-
const req = buildRequest({spec, operationId: 'getMe', parameters: {id: '123'}})
1636+
const req = buildRequest({spec, operationId: 'getMe', parameters: {'id-path': '123'}})
16371637

16381638
expect(req).toEqual({
16391639
url: 'http://swagger.io/v1/123',
@@ -1672,7 +1672,7 @@ describe('execute', () => {
16721672
}
16731673
}
16741674

1675-
const req = buildRequest({spec, operationId: 'getPetsById', parameters: {id: 123, test: 567}})
1675+
const req = buildRequest({spec, operationId: 'getPetsById', parameters: {'id-path': 123, 'test-query': 567}})
16761676

16771677
expect(req).toEqual({
16781678
url: 'http://swagger.io/v1/pet/123?test=567',
@@ -1710,7 +1710,7 @@ describe('execute', () => {
17101710
}
17111711
}
17121712

1713-
const req = buildRequest({spec, operationId: 'getPetsById', parameters: {id: 123, test: 567}})
1713+
const req = buildRequest({spec, operationId: 'getPetsById', parameters: {'id-path': 123, 'test-query': 567}})
17141714

17151715
expect(req).toEqual({
17161716
url: 'http://swagger.io/v1/pet/123?test=567',
@@ -1739,7 +1739,7 @@ describe('execute', () => {
17391739
}
17401740
}
17411741

1742-
const req = buildRequest({spec, operationId: 'deleteMe', parameters: {id: 'foo/bar'}})
1742+
const req = buildRequest({spec, operationId: 'deleteMe', parameters: {'id-path': 'foo/bar'}})
17431743

17441744
expect(req).toEqual({
17451745
url: 'http://swagger.io/v1/foo%2Fbar',
@@ -1773,7 +1773,7 @@ describe('execute', () => {
17731773
const req = buildRequest({spec,
17741774
requestContentType: 'application/x-www-form-urlencoded',
17751775
operationId: 'postMe',
1776-
parameters: {petId: 'id'}})
1776+
parameters: {'petId-formData': 'id'}})
17771777

17781778
expect(req).toEqual({
17791779
url: 'http://swagger.io/v1/one',

test/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ describe('constructor', () => {
467467
req.url = 'http://petstore.swagger.io/v2/pet/4'
468468
}
469469
}).then((client) => {
470-
client.apis.pet.getPetById({petId: 3}).then((data) => {
470+
client.apis.pet.getPetById({'petId-path': 3}).then((data) => {
471471
expect(data.body.id).toEqual(4)
472472
cb()
473473
})
@@ -481,7 +481,7 @@ describe('constructor', () => {
481481
res.body.id = 4
482482
}
483483
}).then((client) => {
484-
client.apis.pet.getPetById({petId: 3}).then((data) => {
484+
client.apis.pet.getPetById({'petId-path': 3}).then((data) => {
485485
expect(data.body.id).toEqual(4)
486486
cb()
487487
})

0 commit comments

Comments
 (0)