@@ -38,6 +38,16 @@ export interface RequestData {
3838 bodyMediaType ?: string ;
3939}
4040
41+ const FormDelimiter = {
42+ spaceDelimited : ' ' ,
43+ pipeDelimited : '|' ,
44+ } ;
45+
46+ const PathPrefix = {
47+ label : '.' ,
48+ matrix : ';' ,
49+ } ;
50+
4151export function ident ( code : string , tab : number = 1 ) {
4252 return code
4353 . split ( '\n' )
@@ -106,20 +116,31 @@ export function encodeRequestData(
106116 return output ;
107117 }
108118
109- const sep =
110- {
111- spaceDelimited : ' ' ,
112- pipeDelimited : '|' ,
113- } [ field . style ?? 'form' ] ?? ',' ;
119+ let prefix = '' ;
120+ let sep = ',' ;
121+ if ( field . in === 'query' ) {
122+ const style = field . style ?? 'form' ;
123+
124+ if ( style in FormDelimiter )
125+ sep = FormDelimiter [ style as keyof typeof FormDelimiter ] ;
126+ } else if ( field . in === 'path' ) {
127+ const style = field . style ?? 'simple' ;
128+
129+ if ( style in PathPrefix )
130+ prefix = PathPrefix [ style as keyof typeof PathPrefix ] ;
131+
132+ if ( explode && prefix . length > 0 ) sep = prefix ;
133+ }
134+
114135 output [ key ] = {
115- value : value . map ( String ) . join ( sep ) ,
136+ value : prefix + value . map ( String ) . join ( sep ) ,
116137 } ;
117138 return output ;
118139 }
119140
120141 if ( typeof value === 'object' && value ) {
121- // header uses the original key
122- if ( explode && field . in === 'header' ) {
142+ // header & path creates key-value pairs
143+ if ( explode && ( field . in === 'header' || field . in === 'path' ) ) {
123144 output [ key ] = {
124145 value : Object . entries ( value )
125146 . map ( ( [ k , v ] ) => `${ k } =${ v } ` )
0 commit comments