Skip to content

Commit 6416762

Browse files
committed
Remove functionality that converts URL paramters to query parameters
1 parent 4e555a9 commit 6416762

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

src/Writing/PostmanCollectionWriter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ protected function resolveHeadersForRoute($route)
117117
protected function makeUrlData($route)
118118
{
119119
// URL Parameters are collected by the `UrlParameters` strategies, but only make sense if they're in the route
120-
// definition. Filter out any URL parameters that don't appear in the URL, and assume they're query params.
121-
[$urlParams, $queryParams] = collect($route['urlParameters'])->partition(function ($_, $key) use ($route) {
120+
// definition. Filter out any URL parameters that don't appear in the URL.
121+
$urlParams = collect($route['urlParameters'])->filter(function ($_, $key) use ($route) {
122122
return Str::contains($route['uri'], '{'.$key.'}');
123123
});
124124

@@ -130,7 +130,7 @@ protected function makeUrlData($route)
130130
'path' => preg_replace_callback('/\/{(\w+)\??}(?=\/|$)/', function ($matches) {
131131
return '/:'.$matches[1];
132132
}, $route['uri']),
133-
'query' => $queryParams->union($route['queryParameters'])->map(function ($parameter, $key) {
133+
'query' => collect($route['queryParameters'])->map(function ($parameter, $key) {
134134
return [
135135
'key' => $key,
136136
'value' => urlencode($parameter['value']),

tests/Fixtures/collection.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,6 @@
344344
"host": "localhost",
345345
"path": "api\/echoesUrlParameters\/{param}-{param2}\/:param3",
346346
"query": [
347-
{
348-
"key": "param4",
349-
"value": "",
350-
"description": "",
351-
"disabled": true
352-
},
353347
{
354348
"key": "something",
355349
"value": "consequatur",

tests/Unit/PostmanCollectionWriterTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function testQueryParametersAreDocumented()
179179
], $variableData[0]);
180180
}
181181

182-
public function testUrlParametersAreResolvedAsQueryParametersIfMissingFromPath()
182+
public function testUrlParametersAreNotIncludedIfMissingFromPath()
183183
{
184184
$fakeRoute = $this->createMockRouteData('fake/path');
185185

@@ -195,19 +195,13 @@ public function testUrlParametersAreResolvedAsQueryParametersIfMissingFromPath()
195195

196196
$variableData = data_get($collection, 'item.0.item.0.request.url.query');
197197

198-
$this->assertCount(1, $variableData);
199-
$this->assertSame([
200-
'key' => 'limit',
201-
'value' => '5',
202-
'description' => 'A fake limit for my fake endpoint',
203-
'disabled' => false,
204-
], $variableData[0]);
198+
$this->assertCount(0, $variableData);
205199
}
206200

207201
public function testQueryParametersAreDisabledWithNoValueWhenNotRequired()
208202
{
209203
$fakeRoute = $this->createMockRouteData('fake/path');
210-
$fakeRoute['urlParameters'] = [
204+
$fakeRoute['queryParameters'] = [
211205
'required' => [
212206
'description' => 'A required param with a null value',
213207
'required' => true,

0 commit comments

Comments
 (0)