Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 917 Bytes

README.md

File metadata and controls

44 lines (35 loc) · 917 Bytes

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