@@ -1062,6 +1062,45 @@ describe('buildRequest w/ `style` & `explode` - OpenAPI Specification 3.0', func
10621062 } )
10631063 } )
10641064
1065+ it ( 'should build a query parameter in form/no-explode format with allowReserved' , function ( ) {
1066+ // Given
1067+ const spec = {
1068+ openapi : '3.0.0' ,
1069+ paths : {
1070+ '/users' : {
1071+ get : {
1072+ operationId : 'myOperation' ,
1073+ parameters : [
1074+ {
1075+ name : 'id' ,
1076+ in : 'query' ,
1077+ style : 'form' ,
1078+ explode : false ,
1079+ allowReserved : true
1080+ }
1081+ ]
1082+ }
1083+ }
1084+ }
1085+ }
1086+
1087+ // when
1088+ const req = buildRequest ( {
1089+ spec,
1090+ operationId : 'myOperation' ,
1091+ parameters : {
1092+ id : VALUE
1093+ }
1094+ } )
1095+
1096+ expect ( req ) . toEqual ( {
1097+ method : 'GET' ,
1098+ url : '/users?id=3,4,5' ,
1099+ credentials : 'same-origin' ,
1100+ headers : { } ,
1101+ } )
1102+ } )
1103+
10651104 it ( 'should build a query parameter in space-delimited/explode format' , function ( ) {
10661105 // Given
10671106 const spec = {
@@ -1100,6 +1139,45 @@ describe('buildRequest w/ `style` & `explode` - OpenAPI Specification 3.0', func
11001139 } )
11011140 } )
11021141
1142+ it ( 'should build a query parameter in space-delimited/explode format with allowReserved' , function ( ) {
1143+ // Given
1144+ const spec = {
1145+ openapi : '3.0.0' ,
1146+ paths : {
1147+ '/users' : {
1148+ get : {
1149+ operationId : 'myOperation' ,
1150+ parameters : [
1151+ {
1152+ name : 'id' ,
1153+ in : 'query' ,
1154+ style : 'spaceDelimited' ,
1155+ explode : true
1156+ }
1157+ ]
1158+ }
1159+ }
1160+ }
1161+ }
1162+
1163+ // when
1164+ const req = buildRequest ( {
1165+ spec,
1166+ operationId : 'myOperation' ,
1167+ parameters : {
1168+ id : VALUE
1169+ }
1170+ } )
1171+ // whitespace is _not_ an RFC3986 reserved character,
1172+ // so it should still be escaped!
1173+ expect ( req ) . toEqual ( {
1174+ method : 'GET' ,
1175+ url : '/users?id=3%20id=4%20id=5' ,
1176+ credentials : 'same-origin' ,
1177+ headers : { } ,
1178+ } )
1179+ } )
1180+
11031181 it ( 'should build a query parameter in space-delimited/no-explode format' , function ( ) {
11041182 // Given
11051183 const spec = {
@@ -1176,6 +1254,45 @@ describe('buildRequest w/ `style` & `explode` - OpenAPI Specification 3.0', func
11761254 } )
11771255 } )
11781256
1257+ it ( 'should build a query parameter in pipe-delimited/explode format with allowReserved' , function ( ) {
1258+ // Given
1259+ const spec = {
1260+ openapi : '3.0.0' ,
1261+ paths : {
1262+ '/users' : {
1263+ get : {
1264+ operationId : 'myOperation' ,
1265+ parameters : [
1266+ {
1267+ name : 'id' ,
1268+ in : 'query' ,
1269+ style : 'pipeDelimited' ,
1270+ explode : true ,
1271+ allowReserved : true
1272+ }
1273+ ]
1274+ }
1275+ }
1276+ }
1277+ }
1278+
1279+ // when
1280+ const req = buildRequest ( {
1281+ spec,
1282+ operationId : 'myOperation' ,
1283+ parameters : {
1284+ id : VALUE
1285+ }
1286+ } )
1287+
1288+ expect ( req ) . toEqual ( {
1289+ method : 'GET' ,
1290+ url : '/users?id=3|id=4|id=5' ,
1291+ credentials : 'same-origin' ,
1292+ headers : { } ,
1293+ } )
1294+ } )
1295+
11791296 it ( 'should build a query parameter in pipe-delimited/no-explode format' , function ( ) {
11801297 // Given
11811298 const spec = {
@@ -1213,6 +1330,45 @@ describe('buildRequest w/ `style` & `explode` - OpenAPI Specification 3.0', func
12131330 headers : { } ,
12141331 } )
12151332 } )
1333+
1334+ it ( 'should build a query parameter in pipe-delimited/no-explode format with allowReserved' , function ( ) {
1335+ // Given
1336+ const spec = {
1337+ openapi : '3.0.0' ,
1338+ paths : {
1339+ '/users' : {
1340+ get : {
1341+ operationId : 'myOperation' ,
1342+ parameters : [
1343+ {
1344+ name : 'id' ,
1345+ in : 'query' ,
1346+ style : 'pipeDelimited' ,
1347+ explode : false ,
1348+ allowReserved : true
1349+ }
1350+ ]
1351+ }
1352+ }
1353+ }
1354+ }
1355+
1356+ // when
1357+ const req = buildRequest ( {
1358+ spec,
1359+ operationId : 'myOperation' ,
1360+ parameters : {
1361+ id : VALUE
1362+ }
1363+ } )
1364+
1365+ expect ( req ) . toEqual ( {
1366+ method : 'GET' ,
1367+ url : '/users?id=3|4|5' ,
1368+ credentials : 'same-origin' ,
1369+ headers : { } ,
1370+ } )
1371+ } )
12161372 } )
12171373 describe ( 'object values' , function ( ) {
12181374 const VALUE = {
0 commit comments