usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
22.21k stars 1.04k forks source link

[Issue] CLI ignores path params in request-urls #2506

Open chrisnagel opened 3 weeks ago

chrisnagel commented 3 weeks ago

I have checked the following:

Describe the bug

Thanks to the very useful feature #484 from @game5413, it is now possible to define and use path parmeters. The feature works as expected in the GUI version of Bruno.

The path parameters are apparently not taken into account in the CLI: A request sent via bru run currently still contains the colon placeholders instead of the defined parameter values.

The issue can be reproduced with V1.19.0 (GUI) and V1.12.0 (CLI).

.bru file to reproduce the bug

meta {
  name: demo
  type: http
  seq: 2
}

get {
  url: https://jsonplaceholder.typicode.com/todos/:num?limit=3
  body: none
  auth: none
}

params:query {
  limit: 3
}

params:path {
  num: 1
}

script:post-response {
  console.log("Request-Url: " + req.url);
}

Screenshots/Live demo link

image Request-Url sent by Bruno GUI

image Request-Url sent by Bruno CLI

epestela commented 3 weeks ago

I also have a small issue: my path params are defined like this in my OpenApi Yaml file http://api/rubrics/{id} when an the request is loaded id is detected as a param and added to path params list image

however when the query executed the replacement does not work correctly: image

fgrande commented 1 week ago

I made a Fix for this, I can still reproduce the bug on bru v1.20.1 (see attached zipped bru file) When run on BrunoApp everything is ok, on bruno CLI it raise an error (since params on URL are not interpolated). Going to attach a PR TestParams.bru.zip