swaggo / gin-swagger

gin middleware to automatically generate RESTful API documentation with Swagger 2.0.
MIT License
3.66k stars 266 forks source link

Feat: add option to sort list of endpoints (#288) #289

Open PhlipTIP opened 8 months ago

PhlipTIP commented 8 months ago

Describe the PR The content featured in the PR adds the OperationsSorter field to the configuration. This field let's the user customize how the API endpoints are displayed in the UI based on the input.

The default in the current version of gin-swagger is "alpha" and this is is still the default, but with this feature other options are available through adding custom config to the wrapHandler method.

Link to Swagger-ui doc referencing operationsSorter

Relation issue Issue #288

Additional context As the operationsSorter field in the window.onload function of the swaggerUI can be either a string ("method", "alpha") or a function itself we need to conditionally wrap the value in backticks with fmt.sprintf to denote whether the window.onload function should interpret the {{.operationsSorter}} value as either a string or js function.

All new features have been tested locally to ensure all three options are working correctly