Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tylfin/gin-swagger-files
Alternative to github.com/swaggo/files that provides support for //go:embed, and multiple swagger UI versions.
https://github.com/tylfin/gin-swagger-files
gin golang swagger-ui
Last synced: about 1 month ago
JSON representation
Alternative to github.com/swaggo/files that provides support for //go:embed, and multiple swagger UI versions.
- Host: GitHub
- URL: https://github.com/tylfin/gin-swagger-files
- Owner: tylfin
- License: mit
- Created: 2021-07-13T16:52:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-05T02:30:44.000Z (over 1 year ago)
- Last Synced: 2023-07-27T22:43:55.863Z (over 1 year ago)
- Topics: gin, golang, swagger-ui
- Language: Go
- Homepage:
- Size: 3.22 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gin-swagger-files
[![Go](https://github.com/tylfin/gin-swagger-files/actions/workflows/go.yml/badge.svg)](https://github.com/tylfin/gin-swagger-files/actions/workflows/go.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/tylfin/gin-swagger-files)](https://goreportcard.com/report/github.com/tylfin/gin-swagger-files)
Alternative to [github.com/swaggo/files](https://github.com/swaggo/files) that provides support for `//go:embed`, and multiple swagger UI versions.
## Example usage
This package is a drop-in replacement for [github.com/swaggo/files](https://github.com/swaggo/files) and will work with
Go1.16+ projects. To use it, replace the `github.com/swaggo/files` with `github.com/tylfin/gin-swagger-files` like this:```go
package mainimport (
"github.com/gin-gonic/gin"
swaggerFiles "github.com/tylfin/gin-swagger-files"
ginSwagger "github.com/swaggo/gin-swagger"_ "github.com/swaggo/gin-swagger/example/basic/docs" // docs is generated by Swag CLI, you have to import it.
)// @title Swagger Example API
// @version 1.0
// @description This is a sample server Petstore server.
// @termsOfService http://swagger.io/terms/// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email [email protected]// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html// @host petstore.swagger.io
// @BasePath /v2
func main() {
r := gin.New()url := ginSwagger.URL("http://localhost:8080/swagger/doc.json") // The url pointing to API definition
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url))r.Run()
}
```## Updating the version
To update the Swagger UI version, copy the contents of the
[swagger-api/swagger-ui](https://github.com/swagger-api/swagger-ui)
[dist folder](https://github.com/swagger-api/swagger-ui/tree/master/dist) into the dist folder here. This will
automatically be bundled into the library at build time.The version should be tagged appropriately like `3.51.1`.