@@ -157,33 +157,27 @@ public PostmanCollection Create(string assemblyFilePath, string environmentKey,
157157 }
158158
159159 // scrub curly braces from url parameter values
160- var cleanUrlParameterUrl = _urlParameterVariableRegEx . Replace ( apiDescription . RelativePath , "=$1-value" ) ;
161-
162- // get path variables from url
163- var pathVariables = _pathVariableRegEx . Matches ( cleanUrlParameterUrl )
164- . Cast < Match > ( )
165- . Select ( m => m . Value )
166- . Select ( s => s . Substring ( 1 , s . Length - 2 ) )
167- . ToDictionary ( s => s , s => string . Format ( "{0}-value" , s ) ) ;
160+ var pathTokens = apiDescription . RelativePath . Split ( new char [ ] { '?' } , 2 ) ;
161+ var path = _pathVariableRegEx . Replace ( pathTokens [ 0 ] , ":$1" ) ;
162+ var queryString = pathTokens . Length > 1 ? _urlParameterVariableRegEx . Replace ( pathTokens [ 1 ] , "=" ) : string . Empty ;
168163
169164 // prefix url with postman environment key variable
170- var url = baseUrl + apiDescription . RelativePath ;
165+ var url = path + ( pathTokens . Length > 1 ? "?" + queryString : string . Empty ) ;
171166
172167 var postmanRequest = new PostmanRequest
173168 {
174169 CollectionId = postManCollection . Id ,
175170 Id = Guid . NewGuid ( ) ,
176- Name = apiDescription . RelativePath ,
171+ Name = url ,
177172 Description = ToMarkdown ( apiDescription ) ,
178- Url = url ,
173+ Url = baseUrl + url ,
179174 Method = apiDescription . HttpMethod . Method ,
180175 Headers = "Content-Type: application/json" ,
181176 RawModeData = sampleData == null ? null : sampleData . Text ,
182177 DataMode = "raw" ,
183178 Time = postManCollection . Timestamp ,
184179 DescriptionFormat = "markdown" ,
185180 Responses = new Collection < string > ( ) ,
186- PathVariables = pathVariables ,
187181 Folder = postManFolder . Id
188182 } ;
189183
0 commit comments