From 0919663464f1e302e2afb3fe9ed7f70ca520bf69 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Tue, 15 Oct 2024 07:44:49 +0200 Subject: [PATCH] feat: add protoc-gen-openapi (gnostic) --- tools/sgprotocgenopenapi/tools.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tools/sgprotocgenopenapi/tools.go diff --git a/tools/sgprotocgenopenapi/tools.go b/tools/sgprotocgenopenapi/tools.go new file mode 100644 index 00000000..d4c76ee6 --- /dev/null +++ b/tools/sgprotocgenopenapi/tools.go @@ -0,0 +1,28 @@ +package sgprotocgenopenapi + +import ( + "context" + "os/exec" + + "go.einride.tech/sage/sg" + "go.einride.tech/sage/sgtool" +) + +// docs: +// https://github.com/google/gnostic/tree/main/cmd/protoc-gen-openapi +// https://buf.build/gnostic/gnostic/docs/main:gnostic.openapi.v3 + +const ( + version = "0.7.0" + name = "protoc-gen-openapi" +) + +func Command(ctx context.Context, args ...string) *exec.Cmd { + sg.Deps(ctx, PrepareCommand) + return sg.Command(ctx, sg.FromBinDir(name), args...) +} + +func PrepareCommand(ctx context.Context) error { + _, err := sgtool.GoInstall(ctx, "github.com/google/gnostic/cmd/"+name, "v"+version) + return err +}