swaggest / openapi-go

OpenAPI structures for Go
https://pkg.go.dev/github.com/swaggest/openapi-go/openapi3
MIT License
259 stars 23 forks source link

Improving the regular expression used to remove gorilla.mux-style regexp in paths #45

Closed Fifi31 closed 2 years ago

Fifi31 commented 2 years ago

Hello, Imagine I have the 2 routes in my API : /users/{userID:[^/]+} and /users/{userID:[^/]+}/books/{bookID:.+}. The regexp are [^/]+ because without it, calling users/toto/books/openapi, matches with /users/{userID:[^/]+} with userID being toto/books/openapi.

The problem is that during Spec.SetupOperation(), {userID:[^/]+} is not matched by regexFindPathParameter ({([^}:]+)(:[^/]+)?(?:})).

I think changing the regex to {([^}:]+)(:[^}]+)?(?:}) would solve the problem.

vearutop commented 2 years ago

Thank you, please try v0.2.22.

Fifi31 commented 2 years ago

Thanks, I briefly tested it but it is still not working. I will dig deeper in it when I have time.

Fifi31 commented 2 years ago

Hey @vearutop I had the chance to look at it, and it works well. Thanks for everything !