Skip to content

eiixy/swagger-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swagger-api

Install

protoc-gen-openapi

go install github.com/google/gnostic/cmd/protoc-gen-openapi

QuickStart

examples/apis/Makefile

protoc --proto_path=./api/ \
    --proto_path=./third_party \
    --openapi_out=output_mode=source_relative:./api/ \
    $(API_PROTO_FILES)

examples/main.go

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{
		{Name: "Account Interface", URL: "/account-interface/v1/account.openapi.yaml"},
		{Name: "Auth Interface", URL: "/auth-interface/v1/auth.openapi.yaml"},
	}))
	err := http.ListenAndServe(":8088", mux)
	if err != nil {
		panic(err)
	}
}

SwaggerUI: http://127.0.0.1:8088/swagger/ui