update to never micro-proto, generate openapi
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
29
main.go
29
main.go
@@ -10,10 +10,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
flagDebug = flag.Bool("debug", false, "")
|
||||
flagStandalone = flag.Bool("standalone", false, "")
|
||||
flagComponents = flag.String("components", "micro|rpc|http|client|server", "")
|
||||
flagTagPath = flag.String("tag_path", "", "")
|
||||
flagDebug = flag.Bool("debug", false, "debug output")
|
||||
flagStandalone = flag.Bool("standalone", false, "generate file to standalone dir")
|
||||
flagComponents = flag.String("components", "micro|rpc|http|client|server|openapiv3", "specify components to generate")
|
||||
flagTagPath = flag.String("tag_path", "", "tag rewriting dir")
|
||||
flagOpenapiFile = flag.String("openapi_file", "apidocs.swagger.json", "openapi file name")
|
||||
flagHelp = flag.Bool("help", false, "display help message")
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -21,16 +23,24 @@ func main() {
|
||||
ParamFunc: flag.CommandLine.Set,
|
||||
}
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if *flagHelp {
|
||||
flag.PrintDefaults()
|
||||
return
|
||||
}
|
||||
|
||||
g := &Generator{}
|
||||
|
||||
opts.Run(g.Generate)
|
||||
}
|
||||
|
||||
type Generator struct {
|
||||
components string
|
||||
standalone bool
|
||||
debug bool
|
||||
tagPath string
|
||||
components string
|
||||
standalone bool
|
||||
debug bool
|
||||
tagPath string
|
||||
openapiFile string
|
||||
}
|
||||
|
||||
func (g *Generator) Generate(plugin *protogen.Plugin) error {
|
||||
@@ -40,6 +50,7 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error {
|
||||
g.debug = *flagDebug
|
||||
g.components = *flagComponents
|
||||
g.tagPath = *flagTagPath
|
||||
g.openapiFile = *flagOpenapiFile
|
||||
plugin.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
|
||||
|
||||
var genClient bool
|
||||
@@ -73,6 +84,8 @@ func (g *Generator) Generate(plugin *protogen.Plugin) error {
|
||||
err = g.gorillaGenerate(component, plugin)
|
||||
case "chi":
|
||||
err = g.chiGenerate(component, plugin)
|
||||
case "openapiv3":
|
||||
err = g.openapiv3Generate(component, plugin)
|
||||
default:
|
||||
err = fmt.Errorf("unknown component: %s", component)
|
||||
}
|
||||
|
Reference in New Issue
Block a user