Egs
A Go framework based on Gin, designed to quickly generate Swagger documentation.
Install / Use
npx skills add Yuukirn/egsInstalls into whichever agent you are using.
README
egs
Egs is a Go framework based on Gin, designed to quickly generate Swagger documentation, which means "Easy Gin Swagger"
Featurs
- Fast and efficient routing with Gin
- Automatic generation of Swagger documentation
Why I build this project?
I once wanted to find a convenient way to generate Swagger documentation for Gin web services, and then I found this project SwaGin. But I found that the project has not been updated sometime and there are some problems with the code. Such as the following:
- panic when the response struct has pointers
- group doesn't work when use middlewares
- don't register components for structs which results in the Swagger JSON containing many duplicated information
- don't support enum type
- don't support OAuth and OIDC authentication
- can't register request struct
- wrong field value of apiKey authentication and don't support cookie and query api key
- authentications have the same name which causes
So I decided to rewrite many codes and fix the above problems.
Installation
go get -u github.com/Yuukirn/egs
Usage
- Import the package in your Go file:
import "github.com/Yuukirn/egs"
- Define a struct for the request parameters:
type TestStruct struct {
ID string `uri:"id" validate:"required" json:"id"`
Name string `form:"name" json:"name"`
Age int `form:"age" json:"age"`
Token string `header:"authorization" validate:"required" json:"token"`
}
Egs uses validator to validate the request parameters, so you need to add validate tags to the struct fields. And egs will bind the struct for you. 3. Define the api
func TestApi(c *gin.Context, req TestStruct) {
bytes, err := json.Marshal(req)
if err != nil {
panic(err)
}
println(string(bytes))
c.JSON(http.StatusOK, TestResp{
Code: 200,
Msg: "OK",
})
}
Note that the first parameter is *gin.Context, and the second parameter is the request struct.
4. Define the router
var test = router.NewRouter(TestApi,
router.Tags("test"),
router.Summary("test summary"),
router.Desc("test desc"),
router.Req(router.Request{
Model: &TestStruct{},
}),
router.Resp(router.Response{
"200": router.ResponseItem{
Model: &TestResp{},
},
}),
)
You can also add other metadata here. 5. Register the router
testGroup := app.Group("test", egs.Handlers(testMiddleware), egs.Security(jwtAuth))
testGroup.POST("/:id", test)
You can find an example in the examples folder. Run the example and enter http://127.0.0.1:8080/docs then you can see the swagger docs like this.

TODO
- [ ] Add OAuth and OIDC authentication
ThanksTo
- SwaGin Swagger + Gin = SwaGin, a web framework based on Gin and Swagger
- kin-openapi, OpenAPI 3.0 implementation for Go (parsing, converting, validation, and more).
- Gin, an HTTP web framework written in Go (Golang).
Related Skills
obsidian
385.5kWork with Obsidian vaults using the official obsidian CLI: read/search/create/edit notes, tasks, links, properties, plugins.
html-anything
8.1k✨ The agentic HTML editor — your local AI agent writes the HTML, you ship it. 🚀 75 Skills × 9 Surfaces (magazine · deck · poster · XHS / tweet · prototype · data report · Hyperframes) 🛡️ Sandboxed preview · 📤 1-click to WeChat / X / Zhihu / HTML / PNG 🔑 Zero API key — Claude Code / Cursor / Code…
openpencil
4.7kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.
openpencil
4.7kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.
