Skip to content
This repository has been archived by the owner on Nov 14, 2022. It is now read-only.

gogf/swagger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣

This repository is not maintained anymore.

Please use the latest v2 version of goframe for automatic API generating and swagger UI feature.

👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣👣

swagger

Provides swagger API document feature for GoFrame project.

Usage

1. Install gf cli tool

Download and install gf cli tool: https://github.com/gogf/gf/tree/master/cmd/gf

2. Install gf-swagger

go get -u github.com/gogf/swagger/v2

3. Produce and pack swagger.json

Use v1 version command gf swagger --pack parses and produces the /swagger/swagger.json file and packs it to /packed/swagger.go.

You can also use gf run main.go --swagger -y running your codes with hot-compiled-like feature and automatically packs the swagger files into your project.

4. Use the swagger plugin

Install the swagger using as plugin:

package main

import (
    "github.com/gogf/gf/v2/frame/g"
    "github.com/gogf/swagger/v2"
)

func main() {
    s := g.Server()
    s.Plugin(&swagger.Swagger{})
    s.SetPort(8199)
    s.Run()
}

Start your server and visit: http://127.0.0.1:8199/swagger

Enjoy!

Comment and configuration

As the swagger files parsed and produced by third party tool, you can get details about comment at: https://github.com/swaggo/swag .

GF swagger feature also supports configuration from file with swagger node. Supported configuration item names of the node please refer to the attribute names of Swagger struct: https://godoc.org/github.com/gogf/swagger/v2