grape-swagger icon indicating copy to clipboard operation
grape-swagger copied to clipboard

Wrong route ordering

Open pavelbabin opened this issue 2 years ago • 3 comments

There is wrong ordering of routes.

For example - there is ordering in the resource I've set:

  1. GET users/
  2. GET users/:id
  3. POST users/
  4. POST users/:id/restore
  5. PUT users/:id
  6. DELETE users/:id

But grape-swagger is generating it like this:

  1. GET users/
  2. POST users/
  3. DELETE users/:id
  4. GET users/:id
  5. PUT users/:id
  6. POST users/:id/restore

The fix from https://github.com/ruby-grape/grape-swagger/pull/859 doesn't fix it completely. The order is still not the same as it was "declared"

pavelbabin avatar Feb 07 '24 08:02 pavelbabin

mmh "wrong" isn't the right word here, cause it is only a different ordering … / and this is always a running discussion, see for example here → https://github.com/ruby-grape/grape-swagger/pull/859

so if you mean to change it, please provide a PR for that and an explanation, why and what changed, thanks

LeFnord avatar Mar 03 '24 15:03 LeFnord

@pavelbabin I'm not sure that Grape itself makes any guarantees with respect to route order - at least not in the documentation or test suite that I can see. FWIW, I agree that it would be useful to be able to rely on the declared order of routes.

dchandekstark avatar Mar 04 '24 17:03 dchandekstark

Grape does mount, evaluate and match routes in the order they are declared in code. It would be nice if someone contributed some statements towards that to the docs ;)

dblock avatar Mar 05 '24 21:03 dblock