Badgerati / Pode

Pode is a Cross-Platform PowerShell web framework for creating REST APIs, Web Sites, and TCP/SMTP servers
https://badgerati.github.io/Pode
MIT License
851 stars 92 forks source link

Order of API routes on swagger page #814

Closed s-dobson closed 3 years ago

s-dobson commented 3 years ago

Question

Not sure if this is a question, bug or I'm just missing something.

I have the following routes (as an example): '/api/users/' '/api/users/user/:userId'

In a basic setup using 'Enable-Pode-OpenApi' these stay in the above order. However when using a "-RouteFilter '/api/*'" the order switches to: '/api/users/user/:userId' '/api/users/'

Obviously I would prefer the first example as the second route is a child of the first so this flows better and makes more sense to an end user.

I just wanted to see if I'm missing anything obvious, if this is intended or is a bug.

Thanks

s-dobson commented 3 years ago

Just as a follow up here is what I mean with screenshots.

Using Enable-PodeOpenApi -Path '/docs/openapi' -Title 'Lorem ipsum API' -Version 0.0.0.1

Screenshot-NoRouteFilter

Using Enable-PodeOpenApi -Path '/docs/openapi' -Title 'Lorem ipsum API' -RouteFilter '/api/*' -Version 0.0.0.1 Screenshot-WithRouteFilter

Badgerati commented 3 years ago

This could be a bug by the looks of it, I'll investigate and get back. Thanks!

s-dobson commented 3 years ago

Ah perfect, thanks for investigating!

Badgerati commented 3 years ago

Hey @s-dobson,

I managed to reproduce the issue, and the changes in the above commit fixes the ordering so it's more consistent. Are you able to make the same couple of changes in the above commit to your Pode module locally and test?

Thanks :)

Badgerati commented 3 years ago

I've merged the fix for this as testing shows the correct order now, but if it's still occurring please feel free to re-open :)

s-dobson commented 3 years ago

Hey @Badgerati ,

Sorry about the delay getting back to you.

I've just tested this and its working on v2.4.2,.

Thanks 👍