You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The api routes are registered with the router by iterating over the map and since native maps are unordered in golang, this leads to unexpected route ordering and breaks the above two routes (as they depend on route precedence for path matching).
Based on the Golang language spec here, The iteration order over maps is not specified and is not guaranteed to be the same from one iteration to the next.
So reruns of the server may lead to different paths being matched if one was registered with the router first.
The problem is in the generator code when sorting the OpenAPI operations. Re-ordering the operations (routes) doesn't work for the Go Server generator, see #19550
Description
For routes defined as the following
and stored in a type defined as:
Refer code here.
The api routes are registered with the router by iterating over the map and since native maps are unordered in golang, this leads to unexpected route ordering and breaks the above two routes (as they depend on route precedence for path matching).
openapi-generator version
Latest 7.9.0
OpenAPI declaration file content or url
Test api.yaml can be downloaded here
Generation Details
You can use any method of generation but I used the following:
Steps to reproduce
Based on the Golang language spec here,
The iteration order over maps is not specified and is not guaranteed to be the same from one iteration to the next.
So reruns of the server may lead to different paths being matched if one was registered with the router first.
Related issues/PRs
Sounds similar but is not:
#14660
Suggest a fix
Use an ordered data type to store the routes such as a list.
The text was updated successfully, but these errors were encountered: