scribe icon indicating copy to clipboard operation
scribe copied to clipboard

Postman Collection Where Example contains a colon

Open freexe opened this issue 3 years ago • 1 comments

What happened?

  1. I set the query params in the doc block /** *@queryParam identifier required foobar. Example: 1234:1234 */
  2. Then I ran php artisan scribe:generate ...
  3. I expected the collection.json once imported into Postman to have the query value "1234:1234"
  4. But instead inside postman the value is escaped and shown as "1234%3A1234":
  5. In the collection.json you can see: "query": [ { "key": "identifier", "value": "1234%3A1234", "description": "foobar", "disabled": false } ],

instead of... "query": [ { "key": "identifier", "value": "1234:1234", "description": "foobar", "disabled": false } ],

My environment:

  • PHP version 8.1
  • Framework (Laravel/Lumen): Laravel
  • Laravel/Lumen version (from composer show laravel/framework or composer show laravel/lumen-framework): 9.1
  • Scribe version (from composer show knuckleswtf/scribe): 3.24

Additional info: I've tracked this done to the class PostmanCollectionWriter.php::generateUrlObject[line:252 + 261]

'value' => urlencode($parameterData->example),

I think this should be as follows because the value doesn't need escaping here as postman escapes the values when it processes the url parameters:

'value' => $parameterData->example,

freexe avatar Feb 28 '22 14:02 freexe

I'll consider it, but I think I once removed it, but returned it when that caused problems.

shalvah avatar Mar 01 '22 16:03 shalvah

We have the same problem, for example, this filter is corrupted in the postman collection but not open API. filter[created_at_between] Filter by created date based on the date range in format Y-m-d.Example:2020-01-01,2020-01-05 Also, any filters that contain [ ] or , or : or space... For example, we use spatie query builder for laravel and all includes and filters containing those characters are corrupted in the postman collection. I believe should be a setting in the configuration if you want to URL encode PHP doc or not.

mariosvasiliou avatar Feb 22 '23 13:02 mariosvasiliou

@shalvah same issue here! Are there any updates?

lumos94 avatar Mar 16 '23 13:03 lumos94

Ugh, I can see that I reverted it, but I can't find the reason why. I'll change it for now, and let's see. My hypothesis is that there are more non-URL-friendly characters beyond the : and [] that could be more game-breaking, but it's your problem. 🤷

shalvah avatar Mar 19 '23 14:03 shalvah