Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Gin Vue Admin | 18,818 | 3 days ago | 35 | October 10, 2023 | 35 | apache-2.0 | Go | |||
基于vite+vue3+gin搭建的开发基础平台(支持TS,JS混用),集成jwt鉴权,权限管理,动态路由,显隐可控组件,分页封装,多点登录拦截,资源权限,上传下载,代码生成器,表单生成器,chatGPT自动查表等开发必备功能。 | ||||||||||
Go Admin | 10,147 | 4 days ago | 46 | mit | Go | |||||
基于Gin + Vue + Element UI & Arco Design & Ant Design 的前后端分离权限管理系统脚手架(包含了:多租户的支持,基础用户管理功能,jwt鉴权,代码生成器,RBAC资源控制,表单构建,定时任务等)3分钟构建自己的中后台项目;项目文档》:https://www.go-admin.pro V2 Demo: https://vue2.go-admin.dev V3 Demo: https://vue3.go-admin.dev Antd 订阅版:https://antd.go-admin.pro | ||||||||||
Swag | 9,076 | 74 | 1,424 | 10 days ago | 141 | August 30, 2023 | 272 | mit | Go | |
Automatically generate RESTful API documentation with Swagger 2.0 for Go. | ||||||||||
Go Gin Example | 6,309 | 5 | 5 months ago | 1 | February 02, 2019 | 44 | mit | Go | ||
An example of gin | ||||||||||
Go Gin Api | 4,801 | 1 | 5 months ago | 23 | November 28, 2021 | 31 | mit | Go | ||
基于 Gin 进行模块化设计的 API 框架,封装了常用功能,使用简单,致力于进行快速的业务研发。比如,支持 cors 跨域、jwt 签名验证、zap 日志收集、panic 异常捕获、trace 链路追踪、prometheus 监控指标、swagger 文档生成、viper 配置文件解析、gorm 数据库组件、gormgen 代码生成工具、graphql 查询语言、errno 统一定义错误码、gRPC 的使用、cron 定时任务 等等。 | ||||||||||
Gin Swagger | 3,276 | 59 | 791 | 2 months ago | 32 | March 28, 2023 | 90 | mit | Go | |
gin middleware to automatically generate RESTful API documentation with Swagger 2.0. | ||||||||||
Gin Admin | 2,327 | 1 | 3 days ago | 21 | November 14, 2021 | 54 | apache-2.0 | Go | ||
A lightweight, flexible, elegant and full-featured RBAC scaffolding based on GIN + GORM 2.0 + Casbin 2.0 + Wire DI. | ||||||||||
Gin_scaffold | 451 | 2 years ago | 1 | Go | ||||||
Gin best practices, gin development scaffolding, too late to explain, get on the bus. | ||||||||||
Weave | 398 | a month ago | 15 | apache-2.0 | Go | |||||
Golang+Vue3 application starter, Simple but functional. | ||||||||||
Microservices Go | 333 | 2 months ago | 3 | November 27, 2021 | 2 | mit | Go | |||
Golang Microservice Boilerplate using MySQL, Docker and Swagger, API REST. Gin Go and GORM with pagination and implementation of a Clean Architecture. |
gin middleware to automatically generate RESTful API documentation with Swagger 2.0.
go get -u github.com/swaggo/swag/cmd/swag
Starting in Go 1.17, installing executables with go get
is deprecated. go install
may be used instead:
go install github.com/swaggo/swag/cmd/swag@latest
~/root/go-project-name
),
Swag will parse comments and generate required files(docs
folder and docs/doc.go
)
at ~/root/go-project-name/docs
.swag init
go get -u github.com/swaggo/gin-swagger
go get -u github.com/swaggo/files
Import following in your code:
import "github.com/swaggo/gin-swagger" // gin-swagger middleware
import "github.com/swaggo/files" // swagger embed files
Now assume you have implemented a simple api as following:
// A get function which returns a hello world string by json
func Helloworld(g *gin.Context) {
g.JSON(http.StatusOK,"helloworld")
}
So how to use gin-swagger on api above? Just follow the following guide.
// @BasePath /api/v1
// PingExample godoc
// @Summary ping example
// @Schemes
// @Description do ping
// @Tags example
// @Accept json
// @Produce json
// @Success 200 {string} Helloworld
// @Router /example/helloworld [get]
func Helloworld(g *gin.Context) {
g.JSON(http.StatusOK,"helloworld")
}
swag init
command to generate a docs, docs generated will be stored at docs/
.github.com/go-project-name/docs
.import (
docs "github.com/go-project-name/docs"
)
build your application and after that, go to http://localhost:8080/swagger/index.html ,you to see your Swagger UI.
The full code and folder relatives here:
package main
import (
"github.com/gin-gonic/gin"
docs "github.com/go-project-name/docs"
swaggerfiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"net/http"
)
// @BasePath /api/v1
// PingExample godoc
// @Summary ping example
// @Schemes
// @Description do ping
// @Tags example
// @Accept json
// @Produce json
// @Success 200 {string} Helloworld
// @Router /example/helloworld [get]
func Helloworld(g *gin.Context) {
g.JSON(http.StatusOK,"helloworld")
}
func main() {
r := gin.Default()
docs.SwaggerInfo.BasePath = "/api/v1"
v1 := r.Group("/api/v1")
{
eg := v1.Group("/example")
{
eg.GET("/helloworld",Helloworld)
}
}
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
r.Run(":8080")
}
Demo project tree, swag init
is run at relative .
.
├── docs
│ ├── docs.go
│ ├── swagger.json
│ └── swagger.yaml
├── go.mod
├── go.sum
└── main.go
This feature was introduced in swag v1.7.9
You can configure Swagger using different configuration options
func main() {
r := gin.New()
ginSwagger.WrapHandler(swaggerfiles.Handler,
ginSwagger.URL("http://localhost:8080/swagger/doc.json"),
ginSwagger.DefaultModelsExpandDepth(-1))
r.Run()
}
Option | Type | Default | Description |
---|---|---|---|
URL | string | "doc.json" | URL pointing to API definition |
DocExpansion | string | "list" | Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing). |
DeepLinking | bool | true | If set to true, enables deep linking for tags and operations. See the Deep Linking documentation for more information. |
DefaultModelsExpandDepth | int | 1 | Default expansion depth for models (set to -1 completely hide the models). |
InstanceName | string | "swagger" | The instance name of the swagger document. If multiple different swagger instances should be deployed on one gin router, ensure that each instance has a unique name (use the --instanceName parameter to generate swagger documents with swag init). |
PersistAuthorization | bool | false | If set to true, it persists authorization data and it would not be lost on browser close/refresh. |
Oauth2DefaultClientID | string | "" | If set, it's used to prepopulate the client_id field of the OAuth2 Authorization dialog. |