go install github.com/google/gnostic/cmd/protoc-gen-openapi
go get github.com/rakyll/statik
go install github.com/rakyll/statik
protoc --proto_path=./api/ \
--proto_path=./third_party \
--openapi_out=output_mode=source_relative:./api/ \
$(API_PROTO_FILES)
package main
import (
"github.com/eiixy/swagger-api"
"github.com/eiixy/swagger-api/examples/apis/api"
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.Handle("/swagger/", swagger.Handler(http.FS(api.FS), []swagger.OpenapiURL{
{"Account Interface", "/account-interface/v1/account.openapi.yaml"},
{"Auth Interface", "/auth-interface/v1/auth.openapi.yaml"},
},
swagger.SetPrefix("/swagger"),
swagger.SetSwaggerUIPath("ui"),
swagger.SetOpenapiPath("apis"),
))
err := http.ListenAndServe(":8088", mux)
if err != nil {
panic(err)
}
}
SwaggerUI: http://127.0.0.1:8088/swagger/ui