Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var GenCommand = &cobra.Command{ Use: "gen", Short: "gen swagger api", Run: func(cmd *cobra.Command, args []string) { fds, err := openapi.LoadProtosetFile("/Users/roverliang/go/src/tds-service-agent/api.bin") if err != nil { klog.Error(err) return } reg := descriptor.NewRegistry() ch := []descriptor.CommonHeader{ descriptor.CommonHeader{ Name: "token", Value: "value", In: "header", Type: "string", Description: "header token", }, } reg.SetSchema("http") reg.SetCommonHeader(ch) reg.SetNamespace(namespace) reg.SetPrefix(importPrefix) reg.SetAllowDeleteBody(allowDeleteBody) reg.SetAllowMerge(allowMerge) reg.SetMergeFileName(mergeFileName) reg.SetUseJSONNamesForFields(useJSONNamesForFields) reg.SetAllowRepeatedFieldsInBody(allowRepeatedFieldsInBody) reg.SetIncludePackageInTags(includePackageInTags) reg.SetUseFQNForOpenAPIName(useFQNForOpenAPIName) reg.SetUseGoTemplate(useGoTemplate) reg.SetEnumsAsInts(enumsAsInts) reg.SetDisableDefaultErrors(disableDefaultErrors) reg.SetSimpleOperationIDs(simpleOperationIDs) reg.SetGenerateUnboundMethods(generateUnboundMethods) gen := genopenapi.New(reg) if err := reg.Load(fds); err != nil { klog.Info(err) return } var targets []*descriptor.File for _, f := range fds { if strings.Contains(f.GetFile().GetName(), descriptor.ReflectionProto) { continue } filePath := f.GetFile().GetName() f, err := reg.LookupFile(filePath) if err != nil { klog.Fatal(err) } targets = append(targets, f) } out, err := gen.Generate(targets) if err != nil { klog.Error(err) return } emitResp(out) }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.