Committing vendored dependencies and generated protos
Change-Id: I349c149b513d9de7d9f60bde2c954a939da2fc54
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/BUILD.bazel b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/BUILD.bazel
new file mode 100644
index 0000000..d5a1d05
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/BUILD.bazel
@@ -0,0 +1,30 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
+
+package(default_visibility = ["//visibility:private"])
+
+go_library(
+ name = "go_default_library",
+ srcs = ["main.go"],
+ importpath = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger",
+ deps = [
+ "//codegenerator:go_default_library",
+ "//protoc-gen-grpc-gateway/descriptor:go_default_library",
+ "//protoc-gen-swagger/genswagger:go_default_library",
+ "@com_github_golang_glog//:go_default_library",
+ "@com_github_golang_protobuf//proto:go_default_library",
+ "@io_bazel_rules_go//proto/wkt:compiler_plugin_go_proto",
+ ],
+)
+
+go_binary(
+ name = "protoc-gen-swagger",
+ embed = [":go_default_library"],
+ visibility = ["//visibility:public"],
+)
+
+go_test(
+ name = "go_default_test",
+ size = "small",
+ srcs = ["main_test.go"],
+ embed = [":go_default_library"],
+)
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/defs.bzl b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/defs.bzl
new file mode 100644
index 0000000..4f90807
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/defs.bzl
@@ -0,0 +1,154 @@
+"""Generated an open-api spec for a grpc api spec.
+
+Reads the the api spec in protobuf format and generate an open-api spec.
+Optionally applies settings from the grpc-service configuration.
+"""
+
+def _collect_includes(gen_dir, srcs):
+ """Build an include path mapping.
+
+ It is important to not just collect unique dirnames, to also support
+ proto files of the same name from different packages.
+
+ The implementation below is similar to what bazel does in its
+ ProtoCompileActionBuilder.java
+ """
+ includes = []
+ for src in srcs:
+ ref_path = src.path
+
+ if ref_path.startswith(gen_dir):
+ ref_path = ref_path[len(gen_dir):].lstrip("/")
+
+ if src.owner.workspace_root:
+ workspace_root = src.owner.workspace_root
+ ref_path = ref_path[len(workspace_root):].lstrip("/")
+
+ include = ref_path + "=" + src.path
+ if include not in includes:
+ includes.append(include)
+
+ return includes
+
+def _run_proto_gen_swagger(ctx, direct_proto_srcs, transitive_proto_srcs, actions, protoc, protoc_gen_swagger, grpc_api_configuration, single_output):
+ swagger_files = []
+
+ inputs = direct_proto_srcs + transitive_proto_srcs
+ tools = [protoc_gen_swagger]
+
+ options = ["logtostderr=true", "allow_repeated_fields_in_body=true"]
+ if grpc_api_configuration:
+ options.append("grpc_api_configuration=%s" % grpc_api_configuration.path)
+ inputs.append(grpc_api_configuration)
+
+ includes = _collect_includes(ctx.genfiles_dir.path, direct_proto_srcs + transitive_proto_srcs)
+
+ if single_output:
+ swagger_file = actions.declare_file(
+ "%s.swagger.json" % ctx.attr.name,
+ sibling = direct_proto_srcs[0],
+ )
+ output_dir = ctx.bin_dir.path
+ if direct_proto_srcs[0].owner.workspace_root:
+ output_dir = "/".join([output_dir, direct_proto_srcs[0].owner.workspace_root])
+
+ output_dir = "/".join([output_dir, direct_proto_srcs[0].dirname])
+
+ options.append("allow_merge=true")
+ options.append("merge_file_name=%s" % ctx.attr.name)
+
+ args = actions.args()
+ args.add("--plugin=%s" % protoc_gen_swagger.path)
+ args.add("--swagger_out=%s:%s" % (",".join(options), output_dir))
+ args.add_all(["-I%s" % include for include in includes])
+ args.add_all([src.path for src in direct_proto_srcs])
+
+ actions.run(
+ executable = protoc,
+ inputs = inputs,
+ tools = tools,
+ outputs = [swagger_file],
+ arguments = [args],
+ )
+
+ swagger_files.append(swagger_file)
+ else:
+ for proto in direct_proto_srcs:
+ swagger_file = actions.declare_file(
+ "%s.swagger.json" % proto.basename[:-len(".proto")],
+ sibling = proto,
+ )
+
+ output_dir = ctx.bin_dir.path
+ if proto.owner.workspace_root:
+ output_dir = "/".join([output_dir, proto.owner.workspace_root])
+
+ args = actions.args()
+ args.add("--plugin=%s" % protoc_gen_swagger.path)
+ args.add("--swagger_out=%s:%s" % (",".join(options), output_dir))
+ args.add_all(["-I%s" % include for include in includes])
+ args.add(proto.path)
+
+ actions.run(
+ executable = protoc,
+ inputs = inputs,
+ tools = tools,
+ outputs = [swagger_file],
+ arguments = [args],
+ )
+
+ swagger_files.append(swagger_file)
+
+ return swagger_files
+
+def _proto_gen_swagger_impl(ctx):
+ proto = ctx.attr.proto[ProtoInfo]
+ grpc_api_configuration = ctx.file.grpc_api_configuration
+
+ return [DefaultInfo(
+ files = depset(
+ _run_proto_gen_swagger(
+ ctx,
+ direct_proto_srcs = proto.direct_sources,
+ transitive_proto_srcs = ctx.files._well_known_protos + proto.transitive_sources.to_list(),
+ actions = ctx.actions,
+ protoc = ctx.executable._protoc,
+ protoc_gen_swagger = ctx.executable._protoc_gen_swagger,
+ grpc_api_configuration = grpc_api_configuration,
+ single_output = ctx.attr.single_output,
+ ),
+ ),
+ )]
+
+protoc_gen_swagger = rule(
+ attrs = {
+ "proto": attr.label(
+ allow_rules = ["proto_library"],
+ mandatory = True,
+ providers = ["proto"],
+ ),
+ "grpc_api_configuration": attr.label(
+ allow_single_file = True,
+ mandatory = False,
+ ),
+ "single_output": attr.bool(
+ default = False,
+ mandatory = False,
+ ),
+ "_protoc": attr.label(
+ default = "@com_google_protobuf//:protoc",
+ executable = True,
+ cfg = "host",
+ ),
+ "_well_known_protos": attr.label(
+ default = "@com_google_protobuf//:well_known_protos",
+ allow_files = True,
+ ),
+ "_protoc_gen_swagger": attr.label(
+ default = Label("//protoc-gen-swagger:protoc-gen-swagger"),
+ executable = True,
+ cfg = "host",
+ ),
+ },
+ implementation = _proto_gen_swagger_impl,
+)
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/BUILD.bazel b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/BUILD.bazel
new file mode 100644
index 0000000..929d0cf
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/BUILD.bazel
@@ -0,0 +1,46 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
+
+package(default_visibility = ["//protoc-gen-swagger:__subpackages__"])
+
+go_library(
+ name = "go_default_library",
+ srcs = [
+ "doc.go",
+ "generator.go",
+ "template.go",
+ "types.go",
+ ],
+ importpath = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger",
+ deps = [
+ "//internal:go_default_library",
+ "//protoc-gen-grpc-gateway/descriptor:go_default_library",
+ "//protoc-gen-grpc-gateway/generator:go_default_library",
+ "//protoc-gen-swagger/options:go_default_library",
+ "@com_github_golang_glog//:go_default_library",
+ "@com_github_golang_protobuf//descriptor:go_default_library_gen",
+ "@com_github_golang_protobuf//jsonpb:go_default_library_gen",
+ "@com_github_golang_protobuf//proto:go_default_library",
+ "@com_github_golang_protobuf//protoc-gen-go/generator:go_default_library_gen",
+ "@io_bazel_rules_go//proto/wkt:any_go_proto",
+ "@io_bazel_rules_go//proto/wkt:compiler_plugin_go_proto",
+ "@io_bazel_rules_go//proto/wkt:descriptor_go_proto",
+ "@io_bazel_rules_go//proto/wkt:struct_go_proto",
+ ],
+)
+
+go_test(
+ name = "go_default_test",
+ size = "small",
+ srcs = ["template_test.go"],
+ embed = [":go_default_library"],
+ deps = [
+ "//protoc-gen-grpc-gateway/descriptor:go_default_library",
+ "//protoc-gen-grpc-gateway/httprule:go_default_library",
+ "//protoc-gen-swagger/options:go_default_library",
+ "@com_github_golang_protobuf//proto:go_default_library",
+ "@io_bazel_rules_go//proto/wkt:any_go_proto",
+ "@io_bazel_rules_go//proto/wkt:compiler_plugin_go_proto",
+ "@io_bazel_rules_go//proto/wkt:descriptor_go_proto",
+ "@io_bazel_rules_go//proto/wkt:struct_go_proto",
+ ],
+)
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/doc.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/doc.go
new file mode 100644
index 0000000..4d28716
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/doc.go
@@ -0,0 +1,2 @@
+// Package genswagger provides a code generator for swagger.
+package genswagger
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/generator.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/generator.go
new file mode 100644
index 0000000..31409ac
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/generator.go
@@ -0,0 +1,247 @@
+package genswagger
+
+import (
+ "bytes"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "path/filepath"
+ "reflect"
+ "strings"
+
+ "github.com/golang/glog"
+ pbdescriptor "github.com/golang/protobuf/descriptor"
+ "github.com/golang/protobuf/proto"
+ protocdescriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
+ plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
+ "github.com/golang/protobuf/ptypes/any"
+ "github.com/grpc-ecosystem/grpc-gateway/internal"
+ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor"
+ gen "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/generator"
+ swagger_options "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"
+)
+
+var (
+ errNoTargetService = errors.New("no target service defined in the file")
+)
+
+type generator struct {
+ reg *descriptor.Registry
+}
+
+type wrapper struct {
+ fileName string
+ swagger *swaggerObject
+}
+
+// New returns a new generator which generates grpc gateway files.
+func New(reg *descriptor.Registry) gen.Generator {
+ return &generator{reg: reg}
+}
+
+// Merge a lot of swagger file (wrapper) to single one swagger file
+func mergeTargetFile(targets []*wrapper, mergeFileName string) *wrapper {
+ var mergedTarget *wrapper
+ for _, f := range targets {
+ if mergedTarget == nil {
+ mergedTarget = &wrapper{
+ fileName: mergeFileName,
+ swagger: f.swagger,
+ }
+ } else {
+ for k, v := range f.swagger.Definitions {
+ mergedTarget.swagger.Definitions[k] = v
+ }
+ for k, v := range f.swagger.StreamDefinitions {
+ mergedTarget.swagger.StreamDefinitions[k] = v
+ }
+ for k, v := range f.swagger.Paths {
+ mergedTarget.swagger.Paths[k] = v
+ }
+ for k, v := range f.swagger.SecurityDefinitions {
+ mergedTarget.swagger.SecurityDefinitions[k] = v
+ }
+ mergedTarget.swagger.Security = append(mergedTarget.swagger.Security, f.swagger.Security...)
+ }
+ }
+ return mergedTarget
+}
+
+func fieldName(k string) string {
+ return strings.ReplaceAll(strings.Title(k), "-", "_")
+}
+
+// Q: What's up with the alias types here?
+// A: We don't want to completely override how these structs are marshaled into
+// JSON, we only want to add fields (see below, extensionMarshalJSON).
+// An infinite recursion would happen if we'd call json.Marshal on the struct
+// that has swaggerObject as an embedded field. To avoid that, we'll create
+// type aliases, and those don't have the custom MarshalJSON methods defined
+// on them. See http://choly.ca/post/go-json-marshalling/ (or, if it ever
+// goes away, use
+// https://web.archive.org/web/20190806073003/http://choly.ca/post/go-json-marshalling/.
+func (so swaggerObject) MarshalJSON() ([]byte, error) {
+ type alias swaggerObject
+ return extensionMarshalJSON(alias(so), so.extensions)
+}
+
+func (so swaggerInfoObject) MarshalJSON() ([]byte, error) {
+ type alias swaggerInfoObject
+ return extensionMarshalJSON(alias(so), so.extensions)
+}
+
+func (so swaggerSecuritySchemeObject) MarshalJSON() ([]byte, error) {
+ type alias swaggerSecuritySchemeObject
+ return extensionMarshalJSON(alias(so), so.extensions)
+}
+
+func (so swaggerOperationObject) MarshalJSON() ([]byte, error) {
+ type alias swaggerOperationObject
+ return extensionMarshalJSON(alias(so), so.extensions)
+}
+
+func (so swaggerResponseObject) MarshalJSON() ([]byte, error) {
+ type alias swaggerResponseObject
+ return extensionMarshalJSON(alias(so), so.extensions)
+}
+
+func extensionMarshalJSON(so interface{}, extensions []extension) ([]byte, error) {
+ // To append arbitrary keys to the struct we'll render into json,
+ // we're creating another struct that embeds the original one, and
+ // its extra fields:
+ //
+ // The struct will look like
+ // struct {
+ // *swaggerCore
+ // XGrpcGatewayFoo json.RawMessage `json:"x-grpc-gateway-foo"`
+ // XGrpcGatewayBar json.RawMessage `json:"x-grpc-gateway-bar"`
+ // }
+ // and thus render into what we want -- the JSON of swaggerCore with the
+ // extensions appended.
+ fields := []reflect.StructField{
+ reflect.StructField{ // embedded
+ Name: "Embedded",
+ Type: reflect.TypeOf(so),
+ Anonymous: true,
+ },
+ }
+ for _, ext := range extensions {
+ fields = append(fields, reflect.StructField{
+ Name: fieldName(ext.key),
+ Type: reflect.TypeOf(ext.value),
+ Tag: reflect.StructTag(fmt.Sprintf("json:\"%s\"", ext.key)),
+ })
+ }
+
+ t := reflect.StructOf(fields)
+ s := reflect.New(t).Elem()
+ s.Field(0).Set(reflect.ValueOf(so))
+ for _, ext := range extensions {
+ s.FieldByName(fieldName(ext.key)).Set(reflect.ValueOf(ext.value))
+ }
+ return json.Marshal(s.Interface())
+}
+
+// encodeSwagger converts swagger file obj to plugin.CodeGeneratorResponse_File
+func encodeSwagger(file *wrapper) (*plugin.CodeGeneratorResponse_File, error) {
+ var formatted bytes.Buffer
+ enc := json.NewEncoder(&formatted)
+ enc.SetIndent("", " ")
+ if err := enc.Encode(*file.swagger); err != nil {
+ return nil, err
+ }
+ name := file.fileName
+ ext := filepath.Ext(name)
+ base := strings.TrimSuffix(name, ext)
+ output := fmt.Sprintf("%s.swagger.json", base)
+ return &plugin.CodeGeneratorResponse_File{
+ Name: proto.String(output),
+ Content: proto.String(formatted.String()),
+ }, nil
+}
+
+func (g *generator) Generate(targets []*descriptor.File) ([]*plugin.CodeGeneratorResponse_File, error) {
+ var files []*plugin.CodeGeneratorResponse_File
+ if g.reg.IsAllowMerge() {
+ var mergedTarget *descriptor.File
+ // try to find proto leader
+ for _, f := range targets {
+ if proto.HasExtension(f.Options, swagger_options.E_Openapiv2Swagger) {
+ mergedTarget = f
+ break
+ }
+ }
+ // merge protos to leader
+ for _, f := range targets {
+ if mergedTarget == nil {
+ mergedTarget = f
+ } else {
+ mergedTarget.Enums = append(mergedTarget.Enums, f.Enums...)
+ mergedTarget.Messages = append(mergedTarget.Messages, f.Messages...)
+ mergedTarget.Services = append(mergedTarget.Services, f.Services...)
+ }
+ }
+
+ targets = nil
+ targets = append(targets, mergedTarget)
+ }
+
+ var swaggers []*wrapper
+ for _, file := range targets {
+ glog.V(1).Infof("Processing %s", file.GetName())
+ swagger, err := applyTemplate(param{File: file, reg: g.reg})
+ if err == errNoTargetService {
+ glog.V(1).Infof("%s: %v", file.GetName(), err)
+ continue
+ }
+ if err != nil {
+ return nil, err
+ }
+ swaggers = append(swaggers, &wrapper{
+ fileName: file.GetName(),
+ swagger: swagger,
+ })
+ }
+
+ if g.reg.IsAllowMerge() {
+ targetSwagger := mergeTargetFile(swaggers, g.reg.GetMergeFileName())
+ f, err := encodeSwagger(targetSwagger)
+ if err != nil {
+ return nil, fmt.Errorf("failed to encode swagger for %s: %s", g.reg.GetMergeFileName(), err)
+ }
+ files = append(files, f)
+ glog.V(1).Infof("New swagger file will emit")
+ } else {
+ for _, file := range swaggers {
+ f, err := encodeSwagger(file)
+ if err != nil {
+ return nil, fmt.Errorf("failed to encode swagger for %s: %s", file.fileName, err)
+ }
+ files = append(files, f)
+ glog.V(1).Infof("New swagger file will emit")
+ }
+ }
+ return files, nil
+}
+
+//AddStreamError Adds grpc.gateway.runtime.StreamError and google.protobuf.Any to registry for stream responses
+func AddStreamError(reg *descriptor.Registry) error {
+ //load internal protos
+ any := fileDescriptorProtoForMessage(&any.Any{})
+ streamError := fileDescriptorProtoForMessage(&internal.StreamError{})
+ if err := reg.Load(&plugin.CodeGeneratorRequest{
+ ProtoFile: []*protocdescriptor.FileDescriptorProto{
+ any,
+ streamError,
+ },
+ }); err != nil {
+ return err
+ }
+ return nil
+}
+
+func fileDescriptorProtoForMessage(msg pbdescriptor.Message) *protocdescriptor.FileDescriptorProto {
+ fdp, _ := pbdescriptor.ForMessage(msg)
+ fdp.SourceCodeInfo = &protocdescriptor.SourceCodeInfo{}
+ return fdp
+}
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/template.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/template.go
new file mode 100644
index 0000000..3d97207
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/template.go
@@ -0,0 +1,1764 @@
+package genswagger
+
+import (
+ "encoding/json"
+ "fmt"
+ "os"
+ "reflect"
+ "regexp"
+ "sort"
+ "strconv"
+ "strings"
+ "sync"
+
+ "github.com/golang/glog"
+ "github.com/golang/protobuf/jsonpb"
+ "github.com/golang/protobuf/proto"
+ structpb "github.com/golang/protobuf/ptypes/struct"
+ pbdescriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
+ gogen "github.com/golang/protobuf/protoc-gen-go/generator"
+ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor"
+ swagger_options "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"
+)
+
+var wktSchemas = map[string]schemaCore{
+ ".google.protobuf.Timestamp": schemaCore{
+ Type: "string",
+ Format: "date-time",
+ },
+ ".google.protobuf.Duration": schemaCore{
+ Type: "string",
+ },
+ ".google.protobuf.StringValue": schemaCore{
+ Type: "string",
+ },
+ ".google.protobuf.BytesValue": schemaCore{
+ Type: "string",
+ Format: "byte",
+ },
+ ".google.protobuf.Int32Value": schemaCore{
+ Type: "integer",
+ Format: "int32",
+ },
+ ".google.protobuf.UInt32Value": schemaCore{
+ Type: "integer",
+ Format: "int64",
+ },
+ ".google.protobuf.Int64Value": schemaCore{
+ Type: "string",
+ Format: "int64",
+ },
+ ".google.protobuf.UInt64Value": schemaCore{
+ Type: "string",
+ Format: "uint64",
+ },
+ ".google.protobuf.FloatValue": schemaCore{
+ Type: "number",
+ Format: "float",
+ },
+ ".google.protobuf.DoubleValue": schemaCore{
+ Type: "number",
+ Format: "double",
+ },
+ ".google.protobuf.BoolValue": schemaCore{
+ Type: "boolean",
+ Format: "boolean",
+ },
+ ".google.protobuf.Empty": schemaCore{},
+ ".google.protobuf.Struct": schemaCore{
+ Type: "object",
+ },
+ ".google.protobuf.Value": schemaCore{
+ Type: "object",
+ },
+ ".google.protobuf.ListValue": schemaCore{
+ Type: "array",
+ Items: (*swaggerItemsObject)(&schemaCore{
+ Type: "object",
+ }),
+ },
+ ".google.protobuf.NullValue": schemaCore{
+ Type: "string",
+ },
+}
+
+func listEnumNames(enum *descriptor.Enum) (names []string) {
+ for _, value := range enum.GetValue() {
+ names = append(names, value.GetName())
+ }
+ return names
+}
+
+func getEnumDefault(enum *descriptor.Enum) string {
+ for _, value := range enum.GetValue() {
+ if value.GetNumber() == 0 {
+ return value.GetName()
+ }
+ }
+ return ""
+}
+
+// messageToQueryParameters converts a message to a list of swagger query parameters.
+func messageToQueryParameters(message *descriptor.Message, reg *descriptor.Registry, pathParams []descriptor.Parameter) (params []swaggerParameterObject, err error) {
+ for _, field := range message.Fields {
+ p, err := queryParams(message, field, "", reg, pathParams)
+ if err != nil {
+ return nil, err
+ }
+ params = append(params, p...)
+ }
+ return params, nil
+}
+
+// queryParams converts a field to a list of swagger query parameters recursively.
+func queryParams(message *descriptor.Message, field *descriptor.Field, prefix string, reg *descriptor.Registry, pathParams []descriptor.Parameter) (params []swaggerParameterObject, err error) {
+ // make sure the parameter is not already listed as a path parameter
+ for _, pathParam := range pathParams {
+ if pathParam.Target == field {
+ return nil, nil
+ }
+ }
+ schema := schemaOfField(field, reg, nil)
+ fieldType := field.GetTypeName()
+ if message.File != nil {
+ comments := fieldProtoComments(reg, message, field)
+ if err := updateSwaggerDataFromComments(&schema, comments, false); err != nil {
+ return nil, err
+ }
+ }
+
+ isEnum := field.GetType() == pbdescriptor.FieldDescriptorProto_TYPE_ENUM
+ items := schema.Items
+ if schema.Type != "" || isEnum {
+ if schema.Type == "object" {
+ return nil, nil // TODO: currently, mapping object in query parameter is not supported
+ }
+ if items != nil && (items.Type == "" || items.Type == "object") && !isEnum {
+ return nil, nil // TODO: currently, mapping object in query parameter is not supported
+ }
+ desc := schema.Description
+ if schema.Title != "" { // merge title because title of parameter object will be ignored
+ desc = strings.TrimSpace(schema.Title + ". " + schema.Description)
+ }
+
+ // verify if the field is required
+ required := false
+ for _, fieldName := range schema.Required {
+ if fieldName == field.GetName() {
+ required = true
+ break
+ }
+ }
+
+ param := swaggerParameterObject{
+ Description: desc,
+ In: "query",
+ Default: schema.Default,
+ Type: schema.Type,
+ Items: schema.Items,
+ Format: schema.Format,
+ Required: required,
+ }
+ if param.Type == "array" {
+ param.CollectionFormat = "multi"
+ }
+
+ if reg.GetUseJSONNamesForFields() {
+ param.Name = prefix + field.GetJsonName()
+ } else {
+ param.Name = prefix + field.GetName()
+ }
+
+ if isEnum {
+ enum, err := reg.LookupEnum("", fieldType)
+ if err != nil {
+ return nil, fmt.Errorf("unknown enum type %s", fieldType)
+ }
+ if items != nil { // array
+ param.Items = &swaggerItemsObject{
+ Type: "string",
+ Enum: listEnumNames(enum),
+ }
+ } else {
+ param.Type = "string"
+ param.Enum = listEnumNames(enum)
+ param.Default = getEnumDefault(enum)
+ }
+ valueComments := enumValueProtoComments(reg, enum)
+ if valueComments != "" {
+ param.Description = strings.TrimLeft(param.Description+"\n\n "+valueComments, "\n")
+ }
+ }
+ return []swaggerParameterObject{param}, nil
+ }
+
+ // nested type, recurse
+ msg, err := reg.LookupMsg("", fieldType)
+ if err != nil {
+ return nil, fmt.Errorf("unknown message type %s", fieldType)
+ }
+ for _, nestedField := range msg.Fields {
+ p, err := queryParams(msg, nestedField, prefix+field.GetName()+".", reg, pathParams)
+ if err != nil {
+ return nil, err
+ }
+ params = append(params, p...)
+ }
+ return params, nil
+}
+
+// findServicesMessagesAndEnumerations discovers all messages and enums defined in the RPC methods of the service.
+func findServicesMessagesAndEnumerations(s []*descriptor.Service, reg *descriptor.Registry, m messageMap, ms messageMap, e enumMap, refs refMap) {
+ for _, svc := range s {
+ for _, meth := range svc.Methods {
+ // Request may be fully included in query
+ if _, ok := refs[fmt.Sprintf("#/definitions/%s", fullyQualifiedNameToSwaggerName(meth.RequestType.FQMN(), reg))]; ok {
+ if !skipRenderingRef(meth.RequestType.FQMN()) {
+ m[fullyQualifiedNameToSwaggerName(meth.RequestType.FQMN(), reg)] = meth.RequestType
+ }
+ }
+ findNestedMessagesAndEnumerations(meth.RequestType, reg, m, e)
+
+ if !skipRenderingRef(meth.ResponseType.FQMN()) {
+ m[fullyQualifiedNameToSwaggerName(meth.ResponseType.FQMN(), reg)] = meth.ResponseType
+ if meth.GetServerStreaming() {
+ runtimeStreamError := fullyQualifiedNameToSwaggerName(".grpc.gateway.runtime.StreamError", reg)
+ glog.V(1).Infof("StreamError FQMN: %s", runtimeStreamError)
+ streamError, err := reg.LookupMsg(".grpc.gateway.runtime", "StreamError")
+ if err == nil {
+ glog.V(1).Infof("StreamError: %v", streamError)
+ m[runtimeStreamError] = streamError
+ findNestedMessagesAndEnumerations(streamError, reg, m, e)
+ } else {
+ //just in case there is an error looking up StreamError
+ glog.Error(err)
+ }
+ ms[fullyQualifiedNameToSwaggerName(meth.ResponseType.FQMN(), reg)] = meth.ResponseType
+ }
+ }
+ findNestedMessagesAndEnumerations(meth.ResponseType, reg, m, e)
+ }
+ }
+}
+
+// findNestedMessagesAndEnumerations those can be generated by the services.
+func findNestedMessagesAndEnumerations(message *descriptor.Message, reg *descriptor.Registry, m messageMap, e enumMap) {
+ // Iterate over all the fields that
+ for _, t := range message.Fields {
+ fieldType := t.GetTypeName()
+ // If the type is an empty string then it is a proto primitive
+ if fieldType != "" {
+ if _, ok := m[fieldType]; !ok {
+ msg, err := reg.LookupMsg("", fieldType)
+ if err != nil {
+ enum, err := reg.LookupEnum("", fieldType)
+ if err != nil {
+ panic(err)
+ }
+ e[fieldType] = enum
+ continue
+ }
+ m[fieldType] = msg
+ findNestedMessagesAndEnumerations(msg, reg, m, e)
+ }
+ }
+ }
+}
+
+func skipRenderingRef(refName string) bool {
+ _, ok := wktSchemas[refName]
+ return ok
+}
+
+func renderMessagesAsDefinition(messages messageMap, d swaggerDefinitionsObject, reg *descriptor.Registry, customRefs refMap) {
+ for name, msg := range messages {
+ if skipRenderingRef(name) {
+ continue
+ }
+
+ if opt := msg.GetOptions(); opt != nil && opt.MapEntry != nil && *opt.MapEntry {
+ continue
+ }
+ schema := swaggerSchemaObject{
+ schemaCore: schemaCore{
+ Type: "object",
+ },
+ }
+ msgComments := protoComments(reg, msg.File, msg.Outers, "MessageType", int32(msg.Index))
+ if err := updateSwaggerDataFromComments(&schema, msgComments, false); err != nil {
+ panic(err)
+ }
+ opts, err := extractSchemaOptionFromMessageDescriptor(msg.DescriptorProto)
+ if err != nil {
+ panic(err)
+ }
+ if opts != nil {
+ protoSchema := swaggerSchemaFromProtoSchema(opts, reg, customRefs)
+
+ // Warning: Make sure not to overwrite any fields already set on the schema type.
+ schema.ExternalDocs = protoSchema.ExternalDocs
+ schema.ReadOnly = protoSchema.ReadOnly
+ schema.MultipleOf = protoSchema.MultipleOf
+ schema.Maximum = protoSchema.Maximum
+ schema.ExclusiveMaximum = protoSchema.ExclusiveMaximum
+ schema.Minimum = protoSchema.Minimum
+ schema.ExclusiveMinimum = protoSchema.ExclusiveMinimum
+ schema.MaxLength = protoSchema.MaxLength
+ schema.MinLength = protoSchema.MinLength
+ schema.Pattern = protoSchema.Pattern
+ schema.Default = protoSchema.Default
+ schema.MaxItems = protoSchema.MaxItems
+ schema.MinItems = protoSchema.MinItems
+ schema.UniqueItems = protoSchema.UniqueItems
+ schema.MaxProperties = protoSchema.MaxProperties
+ schema.MinProperties = protoSchema.MinProperties
+ schema.Required = protoSchema.Required
+ if protoSchema.schemaCore.Type != "" || protoSchema.schemaCore.Ref != "" {
+ schema.schemaCore = protoSchema.schemaCore
+ }
+ if protoSchema.Title != "" {
+ schema.Title = protoSchema.Title
+ }
+ if protoSchema.Description != "" {
+ schema.Description = protoSchema.Description
+ }
+ if protoSchema.Example != nil {
+ schema.Example = protoSchema.Example
+ }
+ }
+
+ for _, f := range msg.Fields {
+ fieldValue := schemaOfField(f, reg, customRefs)
+ comments := fieldProtoComments(reg, msg, f)
+ if err := updateSwaggerDataFromComments(&fieldValue, comments, false); err != nil {
+ panic(err)
+ }
+
+ kv := keyVal{Value: fieldValue}
+ if reg.GetUseJSONNamesForFields() {
+ kv.Key = f.GetJsonName()
+ } else {
+ kv.Key = f.GetName()
+ }
+ if schema.Properties == nil {
+ schema.Properties = &swaggerSchemaObjectProperties{}
+ }
+ *schema.Properties = append(*schema.Properties, kv)
+ }
+ d[fullyQualifiedNameToSwaggerName(msg.FQMN(), reg)] = schema
+ }
+}
+
+func renderMessagesAsStreamDefinition(messages messageMap, d swaggerDefinitionsObject, reg *descriptor.Registry) {
+ for name, msg := range messages {
+ if skipRenderingRef(name) {
+ continue
+ }
+
+ if opt := msg.GetOptions(); opt != nil && opt.MapEntry != nil && *opt.MapEntry {
+ continue
+ }
+ d[fullyQualifiedNameToSwaggerName(msg.FQMN(), reg)] = swaggerSchemaObject{
+ schemaCore: schemaCore{
+ Type: "object",
+ },
+ Title: fmt.Sprintf("Stream result of %s", fullyQualifiedNameToSwaggerName(msg.FQMN(), reg)),
+ Properties: &swaggerSchemaObjectProperties{
+ keyVal{
+ Key: "result",
+ Value: swaggerSchemaObject{
+ schemaCore: schemaCore{
+ Ref: fmt.Sprintf("#/definitions/%s", fullyQualifiedNameToSwaggerName(msg.FQMN(), reg)),
+ },
+ },
+ },
+ keyVal{
+ Key: "error",
+ Value: swaggerSchemaObject{
+ schemaCore: schemaCore{
+ Ref: fmt.Sprintf("#/definitions/%s", fullyQualifiedNameToSwaggerName(".grpc.gateway.runtime.StreamError", reg)),
+ },
+ },
+ },
+ },
+ }
+ }
+}
+
+// schemaOfField returns a swagger Schema Object for a protobuf field.
+func schemaOfField(f *descriptor.Field, reg *descriptor.Registry, refs refMap) swaggerSchemaObject {
+ const (
+ singular = 0
+ array = 1
+ object = 2
+ )
+ var (
+ core schemaCore
+ aggregate int
+ )
+
+ fd := f.FieldDescriptorProto
+ if m, err := reg.LookupMsg("", f.GetTypeName()); err == nil {
+ if opt := m.GetOptions(); opt != nil && opt.MapEntry != nil && *opt.MapEntry {
+ fd = m.GetField()[1]
+ aggregate = object
+ }
+ }
+ if fd.GetLabel() == pbdescriptor.FieldDescriptorProto_LABEL_REPEATED {
+ aggregate = array
+ }
+
+ var props *swaggerSchemaObjectProperties
+
+ switch ft := fd.GetType(); ft {
+ case pbdescriptor.FieldDescriptorProto_TYPE_ENUM, pbdescriptor.FieldDescriptorProto_TYPE_MESSAGE, pbdescriptor.FieldDescriptorProto_TYPE_GROUP:
+ if wktSchema, ok := wktSchemas[fd.GetTypeName()]; ok {
+ core = wktSchema
+
+ if fd.GetTypeName() == ".google.protobuf.Empty" {
+ props = &swaggerSchemaObjectProperties{}
+ }
+ } else {
+ core = schemaCore{
+ Ref: "#/definitions/" + fullyQualifiedNameToSwaggerName(fd.GetTypeName(), reg),
+ }
+ if refs != nil {
+ refs[fd.GetTypeName()] = struct{}{}
+
+ }
+ }
+ default:
+ ftype, format, ok := primitiveSchema(ft)
+ if ok {
+ core = schemaCore{Type: ftype, Format: format}
+ } else {
+ core = schemaCore{Type: ft.String(), Format: "UNKNOWN"}
+ }
+ }
+
+ ret := swaggerSchemaObject{}
+
+ switch aggregate {
+ case array:
+ ret = swaggerSchemaObject{
+ schemaCore: schemaCore{
+ Type: "array",
+ Items: (*swaggerItemsObject)(&core),
+ },
+ }
+ case object:
+ ret = swaggerSchemaObject{
+ schemaCore: schemaCore{
+ Type: "object",
+ },
+ AdditionalProperties: &swaggerSchemaObject{Properties: props, schemaCore: core},
+ }
+ default:
+ ret = swaggerSchemaObject{
+ schemaCore: core,
+ Properties: props,
+ }
+ }
+
+ if j, err := extractJSONSchemaFromFieldDescriptor(fd); err == nil {
+ updateSwaggerObjectFromJSONSchema(&ret, j)
+ }
+
+ return ret
+}
+
+// primitiveSchema returns a pair of "Type" and "Format" in JSON Schema for
+// the given primitive field type.
+// The last return parameter is true iff the field type is actually primitive.
+func primitiveSchema(t pbdescriptor.FieldDescriptorProto_Type) (ftype, format string, ok bool) {
+ switch t {
+ case pbdescriptor.FieldDescriptorProto_TYPE_DOUBLE:
+ return "number", "double", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_FLOAT:
+ return "number", "float", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_INT64:
+ return "string", "int64", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_UINT64:
+ // 64bit integer types are marshaled as string in the default JSONPb marshaler.
+ // TODO(yugui) Add an option to declare 64bit integers as int64.
+ //
+ // NOTE: uint64 is not a predefined format of integer type in Swagger spec.
+ // So we cannot expect that uint64 is commonly supported by swagger processor.
+ return "string", "uint64", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_INT32:
+ return "integer", "int32", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_FIXED64:
+ // Ditto.
+ return "string", "uint64", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_FIXED32:
+ // Ditto.
+ return "integer", "int64", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_BOOL:
+ return "boolean", "boolean", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_STRING:
+ // NOTE: in swagger specifition, format should be empty on string type
+ return "string", "", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_BYTES:
+ return "string", "byte", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_UINT32:
+ // Ditto.
+ return "integer", "int64", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_SFIXED32:
+ return "integer", "int32", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_SFIXED64:
+ return "string", "int64", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_SINT32:
+ return "integer", "int32", true
+ case pbdescriptor.FieldDescriptorProto_TYPE_SINT64:
+ return "string", "int64", true
+ default:
+ return "", "", false
+ }
+}
+
+// renderEnumerationsAsDefinition inserts enums into the definitions object.
+func renderEnumerationsAsDefinition(enums enumMap, d swaggerDefinitionsObject, reg *descriptor.Registry) {
+ for _, enum := range enums {
+ enumComments := protoComments(reg, enum.File, enum.Outers, "EnumType", int32(enum.Index))
+
+ // it may be necessary to sort the result of the GetValue function.
+ enumNames := listEnumNames(enum)
+ defaultValue := getEnumDefault(enum)
+ valueComments := enumValueProtoComments(reg, enum)
+ if valueComments != "" {
+ enumComments = strings.TrimLeft(enumComments+"\n\n "+valueComments, "\n")
+ }
+ enumSchemaObject := swaggerSchemaObject{
+ schemaCore: schemaCore{
+ Type: "string",
+ Enum: enumNames,
+ Default: defaultValue,
+ },
+ }
+ if err := updateSwaggerDataFromComments(&enumSchemaObject, enumComments, false); err != nil {
+ panic(err)
+ }
+
+ d[fullyQualifiedNameToSwaggerName(enum.FQEN(), reg)] = enumSchemaObject
+ }
+}
+
+// Take in a FQMN or FQEN and return a swagger safe version of the FQMN
+func fullyQualifiedNameToSwaggerName(fqn string, reg *descriptor.Registry) string {
+ registriesSeenMutex.Lock()
+ defer registriesSeenMutex.Unlock()
+ if mapping, present := registriesSeen[reg]; present {
+ return mapping[fqn]
+ }
+ mapping := resolveFullyQualifiedNameToSwaggerNames(append(reg.GetAllFQMNs(), reg.GetAllFQENs()...), reg.GetUseFQNForSwaggerName())
+ registriesSeen[reg] = mapping
+ return mapping[fqn]
+}
+
+// registriesSeen is used to memoise calls to resolveFullyQualifiedNameToSwaggerNames so
+// we don't repeat it unnecessarily, since it can take some time.
+var registriesSeen = map[*descriptor.Registry]map[string]string{}
+var registriesSeenMutex sync.Mutex
+
+// Take the names of every proto and "uniq-ify" them. The idea is to produce a
+// set of names that meet a couple of conditions. They must be stable, they
+// must be unique, and they must be shorter than the FQN.
+//
+// This likely could be made better. This will always generate the same names
+// but may not always produce optimal names. This is a reasonably close
+// approximation of what they should look like in most cases.
+func resolveFullyQualifiedNameToSwaggerNames(messages []string, useFQNForSwaggerName bool) map[string]string {
+ packagesByDepth := make(map[int][][]string)
+ uniqueNames := make(map[string]string)
+
+ hierarchy := func(pkg string) []string {
+ return strings.Split(pkg, ".")
+ }
+
+ for _, p := range messages {
+ h := hierarchy(p)
+ for depth := range h {
+ if _, ok := packagesByDepth[depth]; !ok {
+ packagesByDepth[depth] = make([][]string, 0)
+ }
+ packagesByDepth[depth] = append(packagesByDepth[depth], h[len(h)-depth:])
+ }
+ }
+
+ count := func(list [][]string, item []string) int {
+ i := 0
+ for _, element := range list {
+ if reflect.DeepEqual(element, item) {
+ i++
+ }
+ }
+ return i
+ }
+
+ for _, p := range messages {
+ if useFQNForSwaggerName {
+ // strip leading dot from proto fqn
+ uniqueNames[p] = p[1:]
+ } else {
+ h := hierarchy(p)
+ for depth := 0; depth < len(h); depth++ {
+ if count(packagesByDepth[depth], h[len(h)-depth:]) == 1 {
+ uniqueNames[p] = strings.Join(h[len(h)-depth-1:], "")
+ break
+ }
+ if depth == len(h)-1 {
+ uniqueNames[p] = strings.Join(h, "")
+ }
+ }
+ }
+ }
+ return uniqueNames
+}
+
+var canRegexp = regexp.MustCompile("{([a-zA-Z][a-zA-Z0-9_.]*).*}")
+
+// Swagger expects paths of the form /path/{string_value} but grpc-gateway paths are expected to be of the form /path/{string_value=strprefix/*}. This should reformat it correctly.
+func templateToSwaggerPath(path string, reg *descriptor.Registry) string {
+ // It seems like the right thing to do here is to just use
+ // strings.Split(path, "/") but that breaks badly when you hit a url like
+ // /{my_field=prefix/*}/ and end up with 2 sections representing my_field.
+ // Instead do the right thing and write a small pushdown (counter) automata
+ // for it.
+ var parts []string
+ depth := 0
+ buffer := ""
+ jsonBuffer := ""
+ for _, char := range path {
+ switch char {
+ case '{':
+ // Push on the stack
+ depth++
+ buffer += string(char)
+ jsonBuffer = ""
+ jsonBuffer += string(char)
+ break
+ case '}':
+ if depth == 0 {
+ panic("Encountered } without matching { before it.")
+ }
+ // Pop from the stack
+ depth--
+ buffer += string(char)
+ if reg.GetUseJSONNamesForFields() &&
+ len(jsonBuffer) > 1 {
+ jsonSnakeCaseName := string(jsonBuffer[1:])
+ jsonCamelCaseName := string(lowerCamelCase(jsonSnakeCaseName))
+ prev := string(buffer[:len(buffer)-len(jsonSnakeCaseName)-2])
+ buffer = strings.Join([]string{prev, "{", jsonCamelCaseName, "}"}, "")
+ jsonBuffer = ""
+ }
+ case '/':
+ if depth == 0 {
+ parts = append(parts, buffer)
+ buffer = ""
+ // Since the stack was empty when we hit the '/' we are done with this
+ // section.
+ continue
+ }
+ buffer += string(char)
+ jsonBuffer += string(char)
+ default:
+ buffer += string(char)
+ jsonBuffer += string(char)
+ break
+ }
+ }
+
+ // Now append the last element to parts
+ parts = append(parts, buffer)
+
+ // Parts is now an array of segments of the path. Interestingly, since the
+ // syntax for this subsection CAN be handled by a regexp since it has no
+ // memory.
+ for index, part := range parts {
+ // If part is a resource name such as "parent", "name", "user.name", the format info must be retained.
+ prefix := canRegexp.ReplaceAllString(part, "$1")
+ if isResourceName(prefix) {
+ continue
+ }
+ parts[index] = canRegexp.ReplaceAllString(part, "{$1}")
+ }
+
+ return strings.Join(parts, "/")
+}
+
+func isResourceName(prefix string) bool {
+ words := strings.Split(prefix, ".")
+ l := len(words)
+ field := words[l-1]
+ words = strings.Split(field, ":")
+ field = words[0]
+ return field == "parent" || field == "name"
+}
+
+func renderServices(services []*descriptor.Service, paths swaggerPathsObject, reg *descriptor.Registry, requestResponseRefs, customRefs refMap) error {
+ // Correctness of svcIdx and methIdx depends on 'services' containing the services in the same order as the 'file.Service' array.
+ for svcIdx, svc := range services {
+ for methIdx, meth := range svc.Methods {
+ for bIdx, b := range meth.Bindings {
+ // Iterate over all the swagger parameters
+ parameters := swaggerParametersObject{}
+ for _, parameter := range b.PathParams {
+
+ var paramType, paramFormat, desc, collectionFormat, defaultValue string
+ var enumNames []string
+ var items *swaggerItemsObject
+ var minItems *int
+ switch pt := parameter.Target.GetType(); pt {
+ case pbdescriptor.FieldDescriptorProto_TYPE_GROUP, pbdescriptor.FieldDescriptorProto_TYPE_MESSAGE:
+ if descriptor.IsWellKnownType(parameter.Target.GetTypeName()) {
+ if parameter.IsRepeated() {
+ return fmt.Errorf("only primitive and enum types are allowed in repeated path parameters")
+ }
+ schema := schemaOfField(parameter.Target, reg, customRefs)
+ paramType = schema.Type
+ paramFormat = schema.Format
+ desc = schema.Description
+ defaultValue = schema.Default
+ } else {
+ return fmt.Errorf("only primitive and well-known types are allowed in path parameters")
+ }
+ case pbdescriptor.FieldDescriptorProto_TYPE_ENUM:
+ paramType = "string"
+ paramFormat = ""
+ enum, err := reg.LookupEnum("", parameter.Target.GetTypeName())
+ if err != nil {
+ return err
+ }
+ enumNames = listEnumNames(enum)
+ schema := schemaOfField(parameter.Target, reg, customRefs)
+ desc = schema.Description
+ defaultValue = schema.Default
+ default:
+ var ok bool
+ paramType, paramFormat, ok = primitiveSchema(pt)
+ if !ok {
+ return fmt.Errorf("unknown field type %v", pt)
+ }
+
+ schema := schemaOfField(parameter.Target, reg, customRefs)
+ desc = schema.Description
+ defaultValue = schema.Default
+ }
+
+ if parameter.IsRepeated() {
+ core := schemaCore{Type: paramType, Format: paramFormat}
+ if parameter.IsEnum() {
+ var s []string
+ core.Enum = enumNames
+ enumNames = s
+ }
+ items = (*swaggerItemsObject)(&core)
+ paramType = "array"
+ paramFormat = ""
+ collectionFormat = reg.GetRepeatedPathParamSeparatorName()
+ minItems = new(int)
+ *minItems = 1
+ }
+
+ if desc == "" {
+ desc = fieldProtoComments(reg, parameter.Target.Message, parameter.Target)
+ }
+ parameterString := parameter.String()
+ if reg.GetUseJSONNamesForFields() {
+ parameterString = lowerCamelCase(parameterString)
+ }
+ parameters = append(parameters, swaggerParameterObject{
+ Name: parameterString,
+ Description: desc,
+ In: "path",
+ Required: true,
+ Default: defaultValue,
+ // Parameters in gRPC-Gateway can only be strings?
+ Type: paramType,
+ Format: paramFormat,
+ Enum: enumNames,
+ Items: items,
+ CollectionFormat: collectionFormat,
+ MinItems: minItems,
+ })
+ }
+ // Now check if there is a body parameter
+ if b.Body != nil {
+ var schema swaggerSchemaObject
+ desc := ""
+
+ if len(b.Body.FieldPath) == 0 {
+ schema = swaggerSchemaObject{
+ schemaCore: schemaCore{},
+ }
+
+ wknSchemaCore, isWkn := wktSchemas[meth.RequestType.FQMN()]
+ if !isWkn {
+ schema.Ref = fmt.Sprintf("#/definitions/%s", fullyQualifiedNameToSwaggerName(meth.RequestType.FQMN(), reg))
+ } else {
+ schema.schemaCore = wknSchemaCore
+
+ // Special workaround for Empty: it's well-known type but wknSchemas only returns schema.schemaCore; but we need to set schema.Properties which is a level higher.
+ if meth.RequestType.FQMN() == ".google.protobuf.Empty" {
+ schema.Properties = &swaggerSchemaObjectProperties{}
+ }
+ }
+ } else {
+ lastField := b.Body.FieldPath[len(b.Body.FieldPath)-1]
+ schema = schemaOfField(lastField.Target, reg, customRefs)
+ if schema.Description != "" {
+ desc = schema.Description
+ } else {
+ desc = fieldProtoComments(reg, lastField.Target.Message, lastField.Target)
+ }
+ }
+
+ if meth.GetClientStreaming() {
+ desc += " (streaming inputs)"
+ }
+ parameters = append(parameters, swaggerParameterObject{
+ Name: "body",
+ Description: desc,
+ In: "body",
+ Required: true,
+ Schema: &schema,
+ })
+ } else if b.HTTPMethod == "GET" || b.HTTPMethod == "DELETE" {
+ // add the parameters to the query string
+ queryParams, err := messageToQueryParameters(meth.RequestType, reg, b.PathParams)
+ if err != nil {
+ return err
+ }
+ parameters = append(parameters, queryParams...)
+ }
+
+ pathItemObject, ok := paths[templateToSwaggerPath(b.PathTmpl.Template, reg)]
+ if !ok {
+ pathItemObject = swaggerPathItemObject{}
+ }
+
+ methProtoPath := protoPathIndex(reflect.TypeOf((*pbdescriptor.ServiceDescriptorProto)(nil)), "Method")
+ desc := "A successful response."
+ var responseSchema swaggerSchemaObject
+
+ if b.ResponseBody == nil || len(b.ResponseBody.FieldPath) == 0 {
+ responseSchema = swaggerSchemaObject{
+ schemaCore: schemaCore{},
+ }
+
+ // Don't link to a full definition for
+ // empty; it's overly verbose.
+ // schema.Properties{} renders it as
+ // well, without a definition
+ wknSchemaCore, isWkn := wktSchemas[meth.ResponseType.FQMN()]
+ if !isWkn {
+ responseSchema.Ref = fmt.Sprintf("#/definitions/%s", fullyQualifiedNameToSwaggerName(meth.ResponseType.FQMN(), reg))
+ } else {
+ responseSchema.schemaCore = wknSchemaCore
+
+ // Special workaround for Empty: it's well-known type but wknSchemas only returns schema.schemaCore; but we need to set schema.Properties which is a level higher.
+ if meth.ResponseType.FQMN() == ".google.protobuf.Empty" {
+ responseSchema.Properties = &swaggerSchemaObjectProperties{}
+ }
+ }
+ } else {
+ // This is resolving the value of response_body in the google.api.HttpRule
+ lastField := b.ResponseBody.FieldPath[len(b.ResponseBody.FieldPath)-1]
+ responseSchema = schemaOfField(lastField.Target, reg, customRefs)
+ if responseSchema.Description != "" {
+ desc = responseSchema.Description
+ } else {
+ desc = fieldProtoComments(reg, lastField.Target.Message, lastField.Target)
+ }
+ }
+ if meth.GetServerStreaming() {
+ desc += "(streaming responses)"
+ // Use the streamdefinition which wraps the message in a "result"
+ responseSchema.Ref = strings.Replace(responseSchema.Ref, `#/definitions/`, `#/x-stream-definitions/`, 1)
+ }
+
+ tag := svc.GetName()
+ if pkg := svc.File.GetPackage(); pkg != "" && reg.IsIncludePackageInTags() {
+ tag = pkg + "." + tag
+ }
+
+ operationObject := &swaggerOperationObject{
+ Tags: []string{tag},
+ Parameters: parameters,
+ Responses: swaggerResponsesObject{
+ "200": swaggerResponseObject{
+ Description: desc,
+ Schema: responseSchema,
+ },
+ },
+ }
+ if bIdx == 0 {
+ operationObject.OperationID = fmt.Sprintf("%s", meth.GetName())
+ } else {
+ // OperationID must be unique in an OpenAPI v2 definition.
+ operationObject.OperationID = fmt.Sprintf("%s%d", meth.GetName(), bIdx+1)
+ }
+
+ // Fill reference map with referenced request messages
+ for _, param := range operationObject.Parameters {
+ if param.Schema != nil && param.Schema.Ref != "" {
+ requestResponseRefs[param.Schema.Ref] = struct{}{}
+ }
+ }
+
+ methComments := protoComments(reg, svc.File, nil, "Method", int32(svcIdx), methProtoPath, int32(methIdx))
+ if err := updateSwaggerDataFromComments(operationObject, methComments, false); err != nil {
+ panic(err)
+ }
+
+ opts, err := extractOperationOptionFromMethodDescriptor(meth.MethodDescriptorProto)
+ if opts != nil {
+ if err != nil {
+ panic(err)
+ }
+ operationObject.ExternalDocs = protoExternalDocumentationToSwaggerExternalDocumentation(opts.ExternalDocs)
+ // TODO(ivucica): this would be better supported by looking whether the method is deprecated in the proto file
+ operationObject.Deprecated = opts.Deprecated
+
+ if opts.Summary != "" {
+ operationObject.Summary = opts.Summary
+ }
+ if opts.Description != "" {
+ operationObject.Description = opts.Description
+ }
+ if len(opts.Tags) > 0 {
+ operationObject.Tags = make([]string, len(opts.Tags))
+ copy(operationObject.Tags, opts.Tags)
+ }
+ if opts.Security != nil {
+ newSecurity := []swaggerSecurityRequirementObject{}
+ if operationObject.Security != nil {
+ newSecurity = *operationObject.Security
+ }
+ for _, secReq := range opts.Security {
+ newSecReq := swaggerSecurityRequirementObject{}
+ for secReqKey, secReqValue := range secReq.SecurityRequirement {
+ if secReqValue == nil {
+ continue
+ }
+
+ newSecReqValue := make([]string, len(secReqValue.Scope))
+ copy(newSecReqValue, secReqValue.Scope)
+ newSecReq[secReqKey] = newSecReqValue
+ }
+
+ if len(newSecReq) > 0 {
+ newSecurity = append(newSecurity, newSecReq)
+ }
+ }
+ operationObject.Security = &newSecurity
+ }
+ if opts.Responses != nil {
+ for name, resp := range opts.Responses {
+ respObj := swaggerResponseObject{
+ Description: resp.Description,
+ Schema: swaggerSchemaFromProtoSchema(resp.Schema, reg, customRefs),
+ }
+ if resp.Extensions != nil {
+ exts, err := processExtensions(resp.Extensions)
+ if err != nil {
+ return err
+ }
+ respObj.extensions = exts
+ }
+ operationObject.Responses[name] = respObj
+ }
+ }
+
+ if opts.Extensions != nil {
+ exts, err := processExtensions(opts.Extensions)
+ if err != nil {
+ return err
+ }
+ operationObject.extensions = exts
+ }
+
+ // TODO(ivucica): add remaining fields of operation object
+ }
+
+ switch b.HTTPMethod {
+ case "DELETE":
+ pathItemObject.Delete = operationObject
+ break
+ case "GET":
+ pathItemObject.Get = operationObject
+ break
+ case "POST":
+ pathItemObject.Post = operationObject
+ break
+ case "PUT":
+ pathItemObject.Put = operationObject
+ break
+ case "PATCH":
+ pathItemObject.Patch = operationObject
+ break
+ }
+ paths[templateToSwaggerPath(b.PathTmpl.Template, reg)] = pathItemObject
+ }
+ }
+ }
+
+ // Success! return nil on the error object
+ return nil
+}
+
+// This function is called with a param which contains the entire definition of a method.
+func applyTemplate(p param) (*swaggerObject, error) {
+ // Create the basic template object. This is the object that everything is
+ // defined off of.
+ s := swaggerObject{
+ // Swagger 2.0 is the version of this document
+ Swagger: "2.0",
+ Schemes: []string{"http", "https"},
+ Consumes: []string{"application/json"},
+ Produces: []string{"application/json"},
+ Paths: make(swaggerPathsObject),
+ Definitions: make(swaggerDefinitionsObject),
+ StreamDefinitions: make(swaggerDefinitionsObject),
+ Info: swaggerInfoObject{
+ Title: *p.File.Name,
+ Version: "version not set",
+ },
+ }
+
+ // Loops through all the services and their exposed GET/POST/PUT/DELETE definitions
+ // and create entries for all of them.
+ // Also adds custom user specified references to second map.
+ requestResponseRefs, customRefs := refMap{}, refMap{}
+ if err := renderServices(p.Services, s.Paths, p.reg, requestResponseRefs, customRefs); err != nil {
+ panic(err)
+ }
+
+ // Find all the service's messages and enumerations that are defined (recursively)
+ // and write request, response and other custom (but referenced) types out as definition objects.
+ m := messageMap{}
+ ms := messageMap{}
+ e := enumMap{}
+ findServicesMessagesAndEnumerations(p.Services, p.reg, m, ms, e, requestResponseRefs)
+ renderMessagesAsDefinition(m, s.Definitions, p.reg, customRefs)
+ renderMessagesAsStreamDefinition(ms, s.StreamDefinitions, p.reg)
+ renderEnumerationsAsDefinition(e, s.Definitions, p.reg)
+
+ // File itself might have some comments and metadata.
+ packageProtoPath := protoPathIndex(reflect.TypeOf((*pbdescriptor.FileDescriptorProto)(nil)), "Package")
+ packageComments := protoComments(p.reg, p.File, nil, "Package", packageProtoPath)
+ if err := updateSwaggerDataFromComments(&s, packageComments, true); err != nil {
+ panic(err)
+ }
+
+ // There may be additional options in the swagger option in the proto.
+ spb, err := extractSwaggerOptionFromFileDescriptor(p.FileDescriptorProto)
+ if err != nil {
+ panic(err)
+ }
+ if spb != nil {
+ if spb.Swagger != "" {
+ s.Swagger = spb.Swagger
+ }
+ if spb.Info != nil {
+ if spb.Info.Title != "" {
+ s.Info.Title = spb.Info.Title
+ }
+ if spb.Info.Description != "" {
+ s.Info.Description = spb.Info.Description
+ }
+ if spb.Info.TermsOfService != "" {
+ s.Info.TermsOfService = spb.Info.TermsOfService
+ }
+ if spb.Info.Version != "" {
+ s.Info.Version = spb.Info.Version
+ }
+ if spb.Info.Contact != nil {
+ if s.Info.Contact == nil {
+ s.Info.Contact = &swaggerContactObject{}
+ }
+ if spb.Info.Contact.Name != "" {
+ s.Info.Contact.Name = spb.Info.Contact.Name
+ }
+ if spb.Info.Contact.Url != "" {
+ s.Info.Contact.URL = spb.Info.Contact.Url
+ }
+ if spb.Info.Contact.Email != "" {
+ s.Info.Contact.Email = spb.Info.Contact.Email
+ }
+ }
+ if spb.Info.License != nil {
+ if s.Info.License == nil {
+ s.Info.License = &swaggerLicenseObject{}
+ }
+ if spb.Info.License.Name != "" {
+ s.Info.License.Name = spb.Info.License.Name
+ }
+ if spb.Info.License.Url != "" {
+ s.Info.License.URL = spb.Info.License.Url
+ }
+ }
+ if spb.Info.Extensions != nil {
+ exts, err := processExtensions(spb.Info.Extensions)
+ if err != nil {
+ return nil, err
+ }
+ s.Info.extensions = exts
+ }
+ }
+ if spb.Host != "" {
+ s.Host = spb.Host
+ }
+ if spb.BasePath != "" {
+ s.BasePath = spb.BasePath
+ }
+ if len(spb.Schemes) > 0 {
+ s.Schemes = make([]string, len(spb.Schemes))
+ for i, scheme := range spb.Schemes {
+ s.Schemes[i] = strings.ToLower(scheme.String())
+ }
+ }
+ if len(spb.Consumes) > 0 {
+ s.Consumes = make([]string, len(spb.Consumes))
+ copy(s.Consumes, spb.Consumes)
+ }
+ if len(spb.Produces) > 0 {
+ s.Produces = make([]string, len(spb.Produces))
+ copy(s.Produces, spb.Produces)
+ }
+ if spb.SecurityDefinitions != nil && spb.SecurityDefinitions.Security != nil {
+ if s.SecurityDefinitions == nil {
+ s.SecurityDefinitions = swaggerSecurityDefinitionsObject{}
+ }
+ for secDefKey, secDefValue := range spb.SecurityDefinitions.Security {
+ var newSecDefValue swaggerSecuritySchemeObject
+ if oldSecDefValue, ok := s.SecurityDefinitions[secDefKey]; !ok {
+ newSecDefValue = swaggerSecuritySchemeObject{}
+ } else {
+ newSecDefValue = oldSecDefValue
+ }
+ if secDefValue.Type != swagger_options.SecurityScheme_TYPE_INVALID {
+ switch secDefValue.Type {
+ case swagger_options.SecurityScheme_TYPE_BASIC:
+ newSecDefValue.Type = "basic"
+ case swagger_options.SecurityScheme_TYPE_API_KEY:
+ newSecDefValue.Type = "apiKey"
+ case swagger_options.SecurityScheme_TYPE_OAUTH2:
+ newSecDefValue.Type = "oauth2"
+ }
+ }
+ if secDefValue.Description != "" {
+ newSecDefValue.Description = secDefValue.Description
+ }
+ if secDefValue.Name != "" {
+ newSecDefValue.Name = secDefValue.Name
+ }
+ if secDefValue.In != swagger_options.SecurityScheme_IN_INVALID {
+ switch secDefValue.In {
+ case swagger_options.SecurityScheme_IN_QUERY:
+ newSecDefValue.In = "query"
+ case swagger_options.SecurityScheme_IN_HEADER:
+ newSecDefValue.In = "header"
+ }
+ }
+ if secDefValue.Flow != swagger_options.SecurityScheme_FLOW_INVALID {
+ switch secDefValue.Flow {
+ case swagger_options.SecurityScheme_FLOW_IMPLICIT:
+ newSecDefValue.Flow = "implicit"
+ case swagger_options.SecurityScheme_FLOW_PASSWORD:
+ newSecDefValue.Flow = "password"
+ case swagger_options.SecurityScheme_FLOW_APPLICATION:
+ newSecDefValue.Flow = "application"
+ case swagger_options.SecurityScheme_FLOW_ACCESS_CODE:
+ newSecDefValue.Flow = "accessCode"
+ }
+ }
+ if secDefValue.AuthorizationUrl != "" {
+ newSecDefValue.AuthorizationURL = secDefValue.AuthorizationUrl
+ }
+ if secDefValue.TokenUrl != "" {
+ newSecDefValue.TokenURL = secDefValue.TokenUrl
+ }
+ if secDefValue.Scopes != nil {
+ if newSecDefValue.Scopes == nil {
+ newSecDefValue.Scopes = swaggerScopesObject{}
+ }
+ for scopeKey, scopeDesc := range secDefValue.Scopes.Scope {
+ newSecDefValue.Scopes[scopeKey] = scopeDesc
+ }
+ }
+ if secDefValue.Extensions != nil {
+ exts, err := processExtensions(secDefValue.Extensions)
+ if err != nil {
+ return nil, err
+ }
+ newSecDefValue.extensions = exts
+ }
+ s.SecurityDefinitions[secDefKey] = newSecDefValue
+ }
+ }
+ if spb.Security != nil {
+ newSecurity := []swaggerSecurityRequirementObject{}
+ if s.Security == nil {
+ newSecurity = []swaggerSecurityRequirementObject{}
+ } else {
+ newSecurity = s.Security
+ }
+ for _, secReq := range spb.Security {
+ newSecReq := swaggerSecurityRequirementObject{}
+ for secReqKey, secReqValue := range secReq.SecurityRequirement {
+ newSecReqValue := make([]string, len(secReqValue.Scope))
+ copy(newSecReqValue, secReqValue.Scope)
+ newSecReq[secReqKey] = newSecReqValue
+ }
+ newSecurity = append(newSecurity, newSecReq)
+ }
+ s.Security = newSecurity
+ }
+ s.ExternalDocs = protoExternalDocumentationToSwaggerExternalDocumentation(spb.ExternalDocs)
+ // Populate all Paths with Responses set at top level,
+ // preferring Responses already set over those at the top level.
+ if spb.Responses != nil {
+ for _, verbs := range s.Paths {
+ var maps []swaggerResponsesObject
+ if verbs.Delete != nil {
+ maps = append(maps, verbs.Delete.Responses)
+ }
+ if verbs.Get != nil {
+ maps = append(maps, verbs.Get.Responses)
+ }
+ if verbs.Post != nil {
+ maps = append(maps, verbs.Post.Responses)
+ }
+ if verbs.Put != nil {
+ maps = append(maps, verbs.Put.Responses)
+ }
+ if verbs.Patch != nil {
+ maps = append(maps, verbs.Patch.Responses)
+ }
+
+ for k, v := range spb.Responses {
+ for _, respMap := range maps {
+ if _, ok := respMap[k]; ok {
+ // Don't overwrite already existing Responses
+ continue
+ }
+ respMap[k] = swaggerResponseObject{
+ Description: v.Description,
+ Schema: swaggerSchemaFromProtoSchema(v.Schema, p.reg, customRefs),
+ }
+ }
+ }
+ }
+ }
+
+ if spb.Extensions != nil {
+ exts, err := processExtensions(spb.Extensions)
+ if err != nil {
+ return nil, err
+ }
+ s.extensions = exts
+ }
+
+ // Additional fields on the OpenAPI v2 spec's "Swagger" object
+ // should be added here, once supported in the proto.
+ }
+
+ // Finally add any references added by users that aren't
+ // otherwise rendered.
+ addCustomRefs(s.Definitions, p.reg, customRefs)
+
+ return &s, nil
+}
+
+func processExtensions(inputExts map[string]*structpb.Value) ([]extension, error) {
+ exts := []extension{}
+ for k, v := range inputExts {
+ if !strings.HasPrefix(k, "x-") {
+ return nil, fmt.Errorf("Extension keys need to start with \"x-\": %q", k)
+ }
+ ext, err := (&jsonpb.Marshaler{Indent: " "}).MarshalToString(v)
+ if err != nil {
+ return nil, err
+ }
+ exts = append(exts, extension{key: k, value: json.RawMessage(ext)})
+ }
+ sort.Slice(exts, func(i, j int) bool { return exts[i].key < exts[j].key })
+ return exts, nil
+}
+
+// updateSwaggerDataFromComments updates a Swagger object based on a comment
+// from the proto file.
+//
+// First paragraph of a comment is used for summary. Remaining paragraphs of
+// a comment are used for description. If 'Summary' field is not present on
+// the passed swaggerObject, the summary and description are joined by \n\n.
+//
+// If there is a field named 'Info', its 'Summary' and 'Description' fields
+// will be updated instead.
+//
+// If there is no 'Summary', the same behavior will be attempted on 'Title',
+// but only if the last character is not a period.
+func updateSwaggerDataFromComments(swaggerObject interface{}, comment string, isPackageObject bool) error {
+ if len(comment) == 0 {
+ return nil
+ }
+
+ // Figure out what to apply changes to.
+ swaggerObjectValue := reflect.ValueOf(swaggerObject)
+ infoObjectValue := swaggerObjectValue.Elem().FieldByName("Info")
+ if !infoObjectValue.CanSet() {
+ // No such field? Apply summary and description directly to
+ // passed object.
+ infoObjectValue = swaggerObjectValue.Elem()
+ }
+
+ // Figure out which properties to update.
+ summaryValue := infoObjectValue.FieldByName("Summary")
+ descriptionValue := infoObjectValue.FieldByName("Description")
+ readOnlyValue := infoObjectValue.FieldByName("ReadOnly")
+
+ if readOnlyValue.Kind() == reflect.Bool && readOnlyValue.CanSet() && strings.Contains(comment, "Output only.") {
+ readOnlyValue.Set(reflect.ValueOf(true))
+ }
+
+ usingTitle := false
+ if !summaryValue.CanSet() {
+ summaryValue = infoObjectValue.FieldByName("Title")
+ usingTitle = true
+ }
+
+ paragraphs := strings.Split(comment, "\n\n")
+
+ // If there is a summary (or summary-equivalent) and it's empty, use the first
+ // paragraph as summary, and the rest as description.
+ if summaryValue.CanSet() {
+ summary := strings.TrimSpace(paragraphs[0])
+ description := strings.TrimSpace(strings.Join(paragraphs[1:], "\n\n"))
+ if !usingTitle || (len(summary) > 0 && summary[len(summary)-1] != '.') {
+ // overrides the schema value only if it's empty
+ // keep the comment precedence when updating the package definition
+ if summaryValue.Len() == 0 || isPackageObject {
+ summaryValue.Set(reflect.ValueOf(summary))
+ }
+ if len(description) > 0 {
+ if !descriptionValue.CanSet() {
+ return fmt.Errorf("Encountered object type with a summary, but no description")
+ }
+ // overrides the schema value only if it's empty
+ // keep the comment precedence when updating the package definition
+ if descriptionValue.Len() == 0 || isPackageObject {
+ descriptionValue.Set(reflect.ValueOf(description))
+ }
+ }
+ return nil
+ }
+ }
+
+ // There was no summary field on the swaggerObject. Try to apply the
+ // whole comment into description if the swagger object description is empty.
+ if descriptionValue.CanSet() {
+ if descriptionValue.Len() == 0 || isPackageObject {
+ descriptionValue.Set(reflect.ValueOf(strings.Join(paragraphs, "\n\n")))
+ }
+ return nil
+ }
+
+ return fmt.Errorf("no description nor summary property")
+}
+
+func fieldProtoComments(reg *descriptor.Registry, msg *descriptor.Message, field *descriptor.Field) string {
+ protoPath := protoPathIndex(reflect.TypeOf((*pbdescriptor.DescriptorProto)(nil)), "Field")
+ for i, f := range msg.Fields {
+ if f == field {
+ return protoComments(reg, msg.File, msg.Outers, "MessageType", int32(msg.Index), protoPath, int32(i))
+ }
+ }
+ return ""
+}
+
+func enumValueProtoComments(reg *descriptor.Registry, enum *descriptor.Enum) string {
+ protoPath := protoPathIndex(reflect.TypeOf((*pbdescriptor.EnumDescriptorProto)(nil)), "Value")
+ var comments []string
+ for idx, value := range enum.GetValue() {
+ name := value.GetName()
+ str := protoComments(reg, enum.File, enum.Outers, "EnumType", int32(enum.Index), protoPath, int32(idx))
+ if str != "" {
+ comments = append(comments, name+": "+str)
+ }
+ }
+ if len(comments) > 0 {
+ return "- " + strings.Join(comments, "\n - ")
+ }
+ return ""
+}
+
+func protoComments(reg *descriptor.Registry, file *descriptor.File, outers []string, typeName string, typeIndex int32, fieldPaths ...int32) string {
+ if file.SourceCodeInfo == nil {
+ fmt.Fprintln(os.Stderr, "descriptor.File should not contain nil SourceCodeInfo")
+ return ""
+ }
+
+ outerPaths := make([]int32, len(outers))
+ for i := range outers {
+ location := ""
+ if file.Package != nil {
+ location = file.GetPackage()
+ }
+
+ msg, err := reg.LookupMsg(location, strings.Join(outers[:i+1], "."))
+ if err != nil {
+ panic(err)
+ }
+ outerPaths[i] = int32(msg.Index)
+ }
+
+ for _, loc := range file.SourceCodeInfo.Location {
+ if !isProtoPathMatches(loc.Path, outerPaths, typeName, typeIndex, fieldPaths) {
+ continue
+ }
+ comments := ""
+ if loc.LeadingComments != nil {
+ comments = strings.TrimRight(*loc.LeadingComments, "\n")
+ comments = strings.TrimSpace(comments)
+ // TODO(ivucica): this is a hack to fix "// " being interpreted as "//".
+ // perhaps we should:
+ // - split by \n
+ // - determine if every (but first and last) line begins with " "
+ // - trim every line only if that is the case
+ // - join by \n
+ comments = strings.Replace(comments, "\n ", "\n", -1)
+ }
+ return comments
+ }
+ return ""
+}
+
+var messageProtoPath = protoPathIndex(reflect.TypeOf((*pbdescriptor.FileDescriptorProto)(nil)), "MessageType")
+var nestedProtoPath = protoPathIndex(reflect.TypeOf((*pbdescriptor.DescriptorProto)(nil)), "NestedType")
+var packageProtoPath = protoPathIndex(reflect.TypeOf((*pbdescriptor.FileDescriptorProto)(nil)), "Package")
+var serviceProtoPath = protoPathIndex(reflect.TypeOf((*pbdescriptor.FileDescriptorProto)(nil)), "Service")
+var methodProtoPath = protoPathIndex(reflect.TypeOf((*pbdescriptor.ServiceDescriptorProto)(nil)), "Method")
+
+func isProtoPathMatches(paths []int32, outerPaths []int32, typeName string, typeIndex int32, fieldPaths []int32) bool {
+ if typeName == "Package" && typeIndex == packageProtoPath {
+ // path for package comments is just [2], and all the other processing
+ // is too complex for it.
+ if len(paths) == 0 || typeIndex != paths[0] {
+ return false
+ }
+ return true
+ }
+
+ if len(paths) != len(outerPaths)*2+2+len(fieldPaths) {
+ return false
+ }
+
+ if typeName == "Method" {
+ if paths[0] != serviceProtoPath || paths[2] != methodProtoPath {
+ return false
+ }
+ paths = paths[2:]
+ } else {
+ typeNameDescriptor := reflect.TypeOf((*pbdescriptor.FileDescriptorProto)(nil))
+
+ if len(outerPaths) > 0 {
+ if paths[0] != messageProtoPath || paths[1] != outerPaths[0] {
+ return false
+ }
+ paths = paths[2:]
+ outerPaths = outerPaths[1:]
+
+ for i, v := range outerPaths {
+ if paths[i*2] != nestedProtoPath || paths[i*2+1] != v {
+ return false
+ }
+ }
+ paths = paths[len(outerPaths)*2:]
+
+ if typeName == "MessageType" {
+ typeName = "NestedType"
+ }
+ typeNameDescriptor = reflect.TypeOf((*pbdescriptor.DescriptorProto)(nil))
+ }
+
+ if paths[0] != protoPathIndex(typeNameDescriptor, typeName) || paths[1] != typeIndex {
+ return false
+ }
+ paths = paths[2:]
+ }
+
+ for i, v := range fieldPaths {
+ if paths[i] != v {
+ return false
+ }
+ }
+ return true
+}
+
+// protoPathIndex returns a path component for google.protobuf.descriptor.SourceCode_Location.
+//
+// Specifically, it returns an id as generated from descriptor proto which
+// can be used to determine what type the id following it in the path is.
+// For example, if we are trying to locate comments related to a field named
+// `Address` in a message named `Person`, the path will be:
+//
+// [4, a, 2, b]
+//
+// While `a` gets determined by the order in which the messages appear in
+// the proto file, and `b` is the field index specified in the proto
+// file itself, the path actually needs to specify that `a` refers to a
+// message and not, say, a service; and that `b` refers to a field and not
+// an option.
+//
+// protoPathIndex figures out the values 4 and 2 in the above example. Because
+// messages are top level objects, the value of 4 comes from field id for
+// `MessageType` inside `google.protobuf.descriptor.FileDescriptor` message.
+// This field has a message type `google.protobuf.descriptor.DescriptorProto`.
+// And inside message `DescriptorProto`, there is a field named `Field` with id
+// 2.
+//
+// Some code generators seem to be hardcoding these values; this method instead
+// interprets them from `descriptor.proto`-derived Go source as necessary.
+func protoPathIndex(descriptorType reflect.Type, what string) int32 {
+ field, ok := descriptorType.Elem().FieldByName(what)
+ if !ok {
+ panic(fmt.Errorf("could not find protobuf descriptor type id for %s", what))
+ }
+ pbtag := field.Tag.Get("protobuf")
+ if pbtag == "" {
+ panic(fmt.Errorf("no Go tag 'protobuf' on protobuf descriptor for %s", what))
+ }
+ path, err := strconv.Atoi(strings.Split(pbtag, ",")[1])
+ if err != nil {
+ panic(fmt.Errorf("protobuf descriptor id for %s cannot be converted to a number: %s", what, err.Error()))
+ }
+
+ return int32(path)
+}
+
+// extractOperationOptionFromMethodDescriptor extracts the message of type
+// swagger_options.Operation from a given proto method's descriptor.
+func extractOperationOptionFromMethodDescriptor(meth *pbdescriptor.MethodDescriptorProto) (*swagger_options.Operation, error) {
+ if meth.Options == nil {
+ return nil, nil
+ }
+ if !proto.HasExtension(meth.Options, swagger_options.E_Openapiv2Operation) {
+ return nil, nil
+ }
+ ext, err := proto.GetExtension(meth.Options, swagger_options.E_Openapiv2Operation)
+ if err != nil {
+ return nil, err
+ }
+ opts, ok := ext.(*swagger_options.Operation)
+ if !ok {
+ return nil, fmt.Errorf("extension is %T; want an Operation", ext)
+ }
+ return opts, nil
+}
+
+// extractSchemaOptionFromMessageDescriptor extracts the message of type
+// swagger_options.Schema from a given proto message's descriptor.
+func extractSchemaOptionFromMessageDescriptor(msg *pbdescriptor.DescriptorProto) (*swagger_options.Schema, error) {
+ if msg.Options == nil {
+ return nil, nil
+ }
+ if !proto.HasExtension(msg.Options, swagger_options.E_Openapiv2Schema) {
+ return nil, nil
+ }
+ ext, err := proto.GetExtension(msg.Options, swagger_options.E_Openapiv2Schema)
+ if err != nil {
+ return nil, err
+ }
+ opts, ok := ext.(*swagger_options.Schema)
+ if !ok {
+ return nil, fmt.Errorf("extension is %T; want a Schema", ext)
+ }
+ return opts, nil
+}
+
+// extractSwaggerOptionFromFileDescriptor extracts the message of type
+// swagger_options.Swagger from a given proto method's descriptor.
+func extractSwaggerOptionFromFileDescriptor(file *pbdescriptor.FileDescriptorProto) (*swagger_options.Swagger, error) {
+ if file.Options == nil {
+ return nil, nil
+ }
+ if !proto.HasExtension(file.Options, swagger_options.E_Openapiv2Swagger) {
+ return nil, nil
+ }
+ ext, err := proto.GetExtension(file.Options, swagger_options.E_Openapiv2Swagger)
+ if err != nil {
+ return nil, err
+ }
+ opts, ok := ext.(*swagger_options.Swagger)
+ if !ok {
+ return nil, fmt.Errorf("extension is %T; want a Swagger object", ext)
+ }
+ return opts, nil
+}
+
+func extractJSONSchemaFromFieldDescriptor(fd *pbdescriptor.FieldDescriptorProto) (*swagger_options.JSONSchema, error) {
+ if fd.Options == nil {
+ return nil, nil
+ }
+ if !proto.HasExtension(fd.Options, swagger_options.E_Openapiv2Field) {
+ return nil, nil
+ }
+ ext, err := proto.GetExtension(fd.Options, swagger_options.E_Openapiv2Field)
+ if err != nil {
+ return nil, err
+ }
+ opts, ok := ext.(*swagger_options.JSONSchema)
+ if !ok {
+ return nil, fmt.Errorf("extension is %T; want a JSONSchema object", ext)
+ }
+ return opts, nil
+}
+
+func protoJSONSchemaToSwaggerSchemaCore(j *swagger_options.JSONSchema, reg *descriptor.Registry, refs refMap) schemaCore {
+ ret := schemaCore{}
+
+ if j.GetRef() != "" {
+ swaggerName := fullyQualifiedNameToSwaggerName(j.GetRef(), reg)
+ if swaggerName != "" {
+ ret.Ref = "#/definitions/" + swaggerName
+ if refs != nil {
+ refs[j.GetRef()] = struct{}{}
+ }
+ } else {
+ ret.Ref += j.GetRef()
+ }
+ } else {
+ f, t := protoJSONSchemaTypeToFormat(j.GetType())
+ ret.Format = f
+ ret.Type = t
+ }
+
+ return ret
+}
+
+func updateSwaggerObjectFromJSONSchema(s *swaggerSchemaObject, j *swagger_options.JSONSchema) {
+ s.Title = j.GetTitle()
+ s.Description = j.GetDescription()
+ s.ReadOnly = j.GetReadOnly()
+ s.MultipleOf = j.GetMultipleOf()
+ s.Maximum = j.GetMaximum()
+ s.ExclusiveMaximum = j.GetExclusiveMaximum()
+ s.Minimum = j.GetMinimum()
+ s.ExclusiveMinimum = j.GetExclusiveMinimum()
+ s.MaxLength = j.GetMaxLength()
+ s.MinLength = j.GetMinLength()
+ s.Pattern = j.GetPattern()
+ s.Default = j.GetDefault()
+ s.MaxItems = j.GetMaxItems()
+ s.MinItems = j.GetMinItems()
+ s.UniqueItems = j.GetUniqueItems()
+ s.MaxProperties = j.GetMaxProperties()
+ s.MinProperties = j.GetMinProperties()
+ s.Required = j.GetRequired()
+ if overrideType := j.GetType(); len(overrideType) > 0 {
+ s.Type = strings.ToLower(overrideType[0].String())
+ }
+}
+
+func swaggerSchemaFromProtoSchema(s *swagger_options.Schema, reg *descriptor.Registry, refs refMap) swaggerSchemaObject {
+ ret := swaggerSchemaObject{
+ ExternalDocs: protoExternalDocumentationToSwaggerExternalDocumentation(s.GetExternalDocs()),
+ }
+
+ ret.schemaCore = protoJSONSchemaToSwaggerSchemaCore(s.GetJsonSchema(), reg, refs)
+ updateSwaggerObjectFromJSONSchema(&ret, s.GetJsonSchema())
+
+ if s != nil && s.Example != nil {
+ ret.Example = json.RawMessage(s.Example.Value)
+ }
+
+ return ret
+}
+
+func protoJSONSchemaTypeToFormat(in []swagger_options.JSONSchema_JSONSchemaSimpleTypes) (string, string) {
+ if len(in) == 0 {
+ return "", ""
+ }
+
+ // Can't support more than 1 type, just return the first element.
+ // This is due to an inconsistency in the design of the openapiv2 proto
+ // and that used in schemaCore. schemaCore uses the v3 definition of types,
+ // which only allows a single string, while the openapiv2 proto uses the OpenAPI v2
+ // definition, which defers to the JSON schema definition, which allows a string or an array.
+ // Sources:
+ // https://swagger.io/specification/#itemsObject
+ // https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.2
+ switch in[0] {
+ case swagger_options.JSONSchema_UNKNOWN, swagger_options.JSONSchema_NULL:
+ return "", ""
+ case swagger_options.JSONSchema_OBJECT:
+ return "object", ""
+ case swagger_options.JSONSchema_ARRAY:
+ return "array", ""
+ case swagger_options.JSONSchema_BOOLEAN:
+ return "boolean", "boolean"
+ case swagger_options.JSONSchema_INTEGER:
+ return "integer", "int32"
+ case swagger_options.JSONSchema_NUMBER:
+ return "number", "double"
+ case swagger_options.JSONSchema_STRING:
+ // NOTE: in swagger specifition, format should be empty on string type
+ return "string", ""
+ default:
+ // Maybe panic?
+ return "", ""
+ }
+}
+
+func protoExternalDocumentationToSwaggerExternalDocumentation(in *swagger_options.ExternalDocumentation) *swaggerExternalDocumentationObject {
+ if in == nil {
+ return nil
+ }
+
+ return &swaggerExternalDocumentationObject{
+ Description: in.Description,
+ URL: in.Url,
+ }
+}
+
+func addCustomRefs(d swaggerDefinitionsObject, reg *descriptor.Registry, refs refMap) {
+ if len(refs) == 0 {
+ return
+ }
+ msgMap := make(messageMap)
+ enumMap := make(enumMap)
+ for ref := range refs {
+ if _, ok := d[fullyQualifiedNameToSwaggerName(ref, reg)]; ok {
+ // Skip already existing definitions
+ delete(refs, ref)
+ continue
+ }
+ msg, err := reg.LookupMsg("", ref)
+ if err == nil {
+ msgMap[fullyQualifiedNameToSwaggerName(ref, reg)] = msg
+ continue
+ }
+ enum, err := reg.LookupEnum("", ref)
+ if err == nil {
+ enumMap[fullyQualifiedNameToSwaggerName(ref, reg)] = enum
+ continue
+ }
+
+ // ?? Should be either enum or msg
+ }
+ renderMessagesAsDefinition(msgMap, d, reg, refs)
+ renderEnumerationsAsDefinition(enumMap, d, reg)
+
+ // Run again in case any new refs were added
+ addCustomRefs(d, reg, refs)
+}
+
+func lowerCamelCase(parameter string) string {
+ parameterString := gogen.CamelCase(parameter)
+ builder := &strings.Builder{}
+ builder.WriteString(strings.ToLower(string(parameterString[0])))
+ builder.WriteString(parameterString[1:])
+ return builder.String()
+}
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/types.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/types.go
new file mode 100644
index 0000000..77db96d
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/types.go
@@ -0,0 +1,254 @@
+package genswagger
+
+import (
+ "bytes"
+ "encoding/json"
+
+ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor"
+)
+
+type param struct {
+ *descriptor.File
+ reg *descriptor.Registry
+}
+
+type binding struct {
+ *descriptor.Binding
+}
+
+// http://swagger.io/specification/#infoObject
+type swaggerInfoObject struct {
+ Title string `json:"title"`
+ Description string `json:"description,omitempty"`
+ TermsOfService string `json:"termsOfService,omitempty"`
+ Version string `json:"version"`
+
+ Contact *swaggerContactObject `json:"contact,omitempty"`
+ License *swaggerLicenseObject `json:"license,omitempty"`
+
+ extensions []extension
+}
+
+// http://swagger.io/specification/#contactObject
+type swaggerContactObject struct {
+ Name string `json:"name,omitempty"`
+ URL string `json:"url,omitempty"`
+ Email string `json:"email,omitempty"`
+}
+
+// http://swagger.io/specification/#licenseObject
+type swaggerLicenseObject struct {
+ Name string `json:"name,omitempty"`
+ URL string `json:"url,omitempty"`
+}
+
+// http://swagger.io/specification/#externalDocumentationObject
+type swaggerExternalDocumentationObject struct {
+ Description string `json:"description,omitempty"`
+ URL string `json:"url,omitempty"`
+}
+
+type extension struct {
+ key string
+ value json.RawMessage
+}
+
+// http://swagger.io/specification/#swaggerObject
+type swaggerObject struct {
+ Swagger string `json:"swagger"`
+ Info swaggerInfoObject `json:"info"`
+ Host string `json:"host,omitempty"`
+ BasePath string `json:"basePath,omitempty"`
+ Schemes []string `json:"schemes"`
+ Consumes []string `json:"consumes"`
+ Produces []string `json:"produces"`
+ Paths swaggerPathsObject `json:"paths"`
+ Definitions swaggerDefinitionsObject `json:"definitions"`
+ StreamDefinitions swaggerDefinitionsObject `json:"x-stream-definitions,omitempty"`
+ SecurityDefinitions swaggerSecurityDefinitionsObject `json:"securityDefinitions,omitempty"`
+ Security []swaggerSecurityRequirementObject `json:"security,omitempty"`
+ ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"`
+
+ extensions []extension
+}
+
+// http://swagger.io/specification/#securityDefinitionsObject
+type swaggerSecurityDefinitionsObject map[string]swaggerSecuritySchemeObject
+
+// http://swagger.io/specification/#securitySchemeObject
+type swaggerSecuritySchemeObject struct {
+ Type string `json:"type"`
+ Description string `json:"description,omitempty"`
+ Name string `json:"name,omitempty"`
+ In string `json:"in,omitempty"`
+ Flow string `json:"flow,omitempty"`
+ AuthorizationURL string `json:"authorizationUrl,omitempty"`
+ TokenURL string `json:"tokenUrl,omitempty"`
+ Scopes swaggerScopesObject `json:"scopes,omitempty"`
+
+ extensions []extension
+}
+
+// http://swagger.io/specification/#scopesObject
+type swaggerScopesObject map[string]string
+
+// http://swagger.io/specification/#securityRequirementObject
+type swaggerSecurityRequirementObject map[string][]string
+
+// http://swagger.io/specification/#pathsObject
+type swaggerPathsObject map[string]swaggerPathItemObject
+
+// http://swagger.io/specification/#pathItemObject
+type swaggerPathItemObject struct {
+ Get *swaggerOperationObject `json:"get,omitempty"`
+ Delete *swaggerOperationObject `json:"delete,omitempty"`
+ Post *swaggerOperationObject `json:"post,omitempty"`
+ Put *swaggerOperationObject `json:"put,omitempty"`
+ Patch *swaggerOperationObject `json:"patch,omitempty"`
+}
+
+// http://swagger.io/specification/#operationObject
+type swaggerOperationObject struct {
+ Summary string `json:"summary,omitempty"`
+ Description string `json:"description,omitempty"`
+ OperationID string `json:"operationId"`
+ Responses swaggerResponsesObject `json:"responses"`
+ Parameters swaggerParametersObject `json:"parameters,omitempty"`
+ Tags []string `json:"tags,omitempty"`
+ Deprecated bool `json:"deprecated,omitempty"`
+
+ Security *[]swaggerSecurityRequirementObject `json:"security,omitempty"`
+ ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"`
+
+ extensions []extension
+}
+
+type swaggerParametersObject []swaggerParameterObject
+
+// http://swagger.io/specification/#parameterObject
+type swaggerParameterObject struct {
+ Name string `json:"name"`
+ Description string `json:"description,omitempty"`
+ In string `json:"in,omitempty"`
+ Required bool `json:"required"`
+ Type string `json:"type,omitempty"`
+ Format string `json:"format,omitempty"`
+ Items *swaggerItemsObject `json:"items,omitempty"`
+ Enum []string `json:"enum,omitempty"`
+ CollectionFormat string `json:"collectionFormat,omitempty"`
+ Default string `json:"default,omitempty"`
+ MinItems *int `json:"minItems,omitempty"`
+
+ // Or you can explicitly refer to another type. If this is defined all
+ // other fields should be empty
+ Schema *swaggerSchemaObject `json:"schema,omitempty"`
+}
+
+// core part of schema, which is common to itemsObject and schemaObject.
+// http://swagger.io/specification/#itemsObject
+type schemaCore struct {
+ Type string `json:"type,omitempty"`
+ Format string `json:"format,omitempty"`
+ Ref string `json:"$ref,omitempty"`
+ Example json.RawMessage `json:"example,omitempty"`
+
+ Items *swaggerItemsObject `json:"items,omitempty"`
+
+ // If the item is an enumeration include a list of all the *NAMES* of the
+ // enum values. I'm not sure how well this will work but assuming all enums
+ // start from 0 index it will be great. I don't think that is a good assumption.
+ Enum []string `json:"enum,omitempty"`
+ Default string `json:"default,omitempty"`
+}
+
+type swaggerItemsObject schemaCore
+
+// http://swagger.io/specification/#responsesObject
+type swaggerResponsesObject map[string]swaggerResponseObject
+
+// http://swagger.io/specification/#responseObject
+type swaggerResponseObject struct {
+ Description string `json:"description"`
+ Schema swaggerSchemaObject `json:"schema"`
+
+ extensions []extension
+}
+
+type keyVal struct {
+ Key string
+ Value interface{}
+}
+
+type swaggerSchemaObjectProperties []keyVal
+
+func (op swaggerSchemaObjectProperties) MarshalJSON() ([]byte, error) {
+ var buf bytes.Buffer
+ buf.WriteString("{")
+ for i, kv := range op {
+ if i != 0 {
+ buf.WriteString(",")
+ }
+ key, err := json.Marshal(kv.Key)
+ if err != nil {
+ return nil, err
+ }
+ buf.Write(key)
+ buf.WriteString(":")
+ val, err := json.Marshal(kv.Value)
+ if err != nil {
+ return nil, err
+ }
+ buf.Write(val)
+ }
+
+ buf.WriteString("}")
+ return buf.Bytes(), nil
+}
+
+// http://swagger.io/specification/#schemaObject
+type swaggerSchemaObject struct {
+ schemaCore
+ // Properties can be recursively defined
+ Properties *swaggerSchemaObjectProperties `json:"properties,omitempty"`
+ AdditionalProperties *swaggerSchemaObject `json:"additionalProperties,omitempty"`
+
+ Description string `json:"description,omitempty"`
+ Title string `json:"title,omitempty"`
+
+ ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"`
+
+ ReadOnly bool `json:"readOnly,omitempty"`
+ MultipleOf float64 `json:"multipleOf,omitempty"`
+ Maximum float64 `json:"maximum,omitempty"`
+ ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`
+ Minimum float64 `json:"minimum,omitempty"`
+ ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"`
+ MaxLength uint64 `json:"maxLength,omitempty"`
+ MinLength uint64 `json:"minLength,omitempty"`
+ Pattern string `json:"pattern,omitempty"`
+ MaxItems uint64 `json:"maxItems,omitempty"`
+ MinItems uint64 `json:"minItems,omitempty"`
+ UniqueItems bool `json:"uniqueItems,omitempty"`
+ MaxProperties uint64 `json:"maxProperties,omitempty"`
+ MinProperties uint64 `json:"minProperties,omitempty"`
+ Required []string `json:"required,omitempty"`
+}
+
+// http://swagger.io/specification/#referenceObject
+type swaggerReferenceObject struct {
+ Ref string `json:"$ref"`
+}
+
+// http://swagger.io/specification/#definitionsObject
+type swaggerDefinitionsObject map[string]swaggerSchemaObject
+
+// Internal type mapping from FQMN to descriptor.Message. Used as a set by the
+// findServiceMessages function.
+type messageMap map[string]*descriptor.Message
+
+// Internal type mapping from FQEN to descriptor.Enum. Used as a set by the
+// findServiceMessages function.
+type enumMap map[string]*descriptor.Enum
+
+// Internal type to store used references.
+type refMap map[string]struct{}
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/main.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/main.go
new file mode 100644
index 0000000..237e460
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/main.go
@@ -0,0 +1,198 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+ "strings"
+
+ "github.com/golang/glog"
+ "github.com/golang/protobuf/proto"
+ plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
+ "github.com/grpc-ecosystem/grpc-gateway/codegenerator"
+ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor"
+ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger"
+)
+
+var (
+ importPrefix = flag.String("import_prefix", "", "prefix to be added to go package paths for imported proto files")
+ file = flag.String("file", "-", "where to load data from")
+ allowDeleteBody = flag.Bool("allow_delete_body", false, "unless set, HTTP DELETE methods may not have a body")
+ grpcAPIConfiguration = flag.String("grpc_api_configuration", "", "path to gRPC API Configuration in YAML format")
+ allowMerge = flag.Bool("allow_merge", false, "if set, generation one swagger file out of multiple protos")
+ mergeFileName = flag.String("merge_file_name", "apidocs", "target swagger file name prefix after merge")
+ useJSONNamesForFields = flag.Bool("json_names_for_fields", false, "if it sets Field.GetJsonName() will be used for generating swagger definitions, otherwise Field.GetName() will be used")
+ repeatedPathParamSeparator = flag.String("repeated_path_param_separator", "csv", "configures how repeated fields should be split. Allowed values are `csv`, `pipes`, `ssv` and `tsv`.")
+ versionFlag = flag.Bool("version", false, "print the current verison")
+ allowRepeatedFieldsInBody = flag.Bool("allow_repeated_fields_in_body", false, "allows to use repeated field in `body` and `response_body` field of `google.api.http` annotation option")
+ includePackageInTags = flag.Bool("include_package_in_tags", false, "if unset, the gRPC service name is added to the `Tags` field of each operation. if set and the `package` directive is shown in the proto file, the package name will be prepended to the service name")
+ useFQNForSwaggerName = flag.Bool("fqn_for_swagger_name", false, "if set, the object's swagger names will use the fully qualify name from the proto definition (ie my.package.MyMessage.MyInnerMessage")
+)
+
+// Variables set by goreleaser at build time
+var (
+ version = "dev"
+ commit = "unknown"
+ date = "unknown"
+)
+
+func main() {
+ flag.Parse()
+ defer glog.Flush()
+
+ if *versionFlag {
+ fmt.Printf("Version %v, commit %v, built at %v\n", version, commit, date)
+ os.Exit(0)
+ }
+
+ reg := descriptor.NewRegistry()
+
+ glog.V(1).Info("Processing code generator request")
+ f := os.Stdin
+ if *file != "-" {
+ var err error
+ f, err = os.Open(*file)
+ if err != nil {
+ glog.Fatal(err)
+ }
+ }
+ glog.V(1).Info("Parsing code generator request")
+ req, err := codegenerator.ParseRequest(f)
+ if err != nil {
+ glog.Fatal(err)
+ }
+ glog.V(1).Info("Parsed code generator request")
+ pkgMap := make(map[string]string)
+ if req.Parameter != nil {
+ err := parseReqParam(req.GetParameter(), flag.CommandLine, pkgMap)
+ if err != nil {
+ glog.Fatalf("Error parsing flags: %v", err)
+ }
+ }
+
+ reg.SetPrefix(*importPrefix)
+ reg.SetAllowDeleteBody(*allowDeleteBody)
+ reg.SetAllowMerge(*allowMerge)
+ reg.SetMergeFileName(*mergeFileName)
+ reg.SetUseJSONNamesForFields(*useJSONNamesForFields)
+ reg.SetAllowRepeatedFieldsInBody(*allowRepeatedFieldsInBody)
+ reg.SetIncludePackageInTags(*includePackageInTags)
+ reg.SetUseFQNForSwaggerName(*useFQNForSwaggerName)
+ if err := reg.SetRepeatedPathParamSeparator(*repeatedPathParamSeparator); err != nil {
+ emitError(err)
+ return
+ }
+ for k, v := range pkgMap {
+ reg.AddPkgMap(k, v)
+ }
+
+ if *grpcAPIConfiguration != "" {
+ if err := reg.LoadGrpcAPIServiceFromYAML(*grpcAPIConfiguration); err != nil {
+ emitError(err)
+ return
+ }
+ }
+
+ g := genswagger.New(reg)
+
+ if err := genswagger.AddStreamError(reg); err != nil {
+ emitError(err)
+ return
+ }
+
+ if err := reg.Load(req); err != nil {
+ emitError(err)
+ return
+ }
+
+ var targets []*descriptor.File
+ for _, target := range req.FileToGenerate {
+ f, err := reg.LookupFile(target)
+ if err != nil {
+ glog.Fatal(err)
+ }
+ targets = append(targets, f)
+ }
+
+ out, err := g.Generate(targets)
+ glog.V(1).Info("Processed code generator request")
+ if err != nil {
+ emitError(err)
+ return
+ }
+ emitFiles(out)
+}
+
+func emitFiles(out []*plugin.CodeGeneratorResponse_File) {
+ emitResp(&plugin.CodeGeneratorResponse{File: out})
+}
+
+func emitError(err error) {
+ emitResp(&plugin.CodeGeneratorResponse{Error: proto.String(err.Error())})
+}
+
+func emitResp(resp *plugin.CodeGeneratorResponse) {
+ buf, err := proto.Marshal(resp)
+ if err != nil {
+ glog.Fatal(err)
+ }
+ if _, err := os.Stdout.Write(buf); err != nil {
+ glog.Fatal(err)
+ }
+}
+
+// parseReqParam parses a CodeGeneratorRequest parameter and adds the
+// extracted values to the given FlagSet and pkgMap. Returns a non-nil
+// error if setting a flag failed.
+func parseReqParam(param string, f *flag.FlagSet, pkgMap map[string]string) error {
+ if param == "" {
+ return nil
+ }
+ for _, p := range strings.Split(param, ",") {
+ spec := strings.SplitN(p, "=", 2)
+ if len(spec) == 1 {
+ if spec[0] == "allow_delete_body" {
+ err := f.Set(spec[0], "true")
+ if err != nil {
+ return fmt.Errorf("Cannot set flag %s: %v", p, err)
+ }
+ continue
+ }
+ if spec[0] == "allow_merge" {
+ err := f.Set(spec[0], "true")
+ if err != nil {
+ return fmt.Errorf("Cannot set flag %s: %v", p, err)
+ }
+ continue
+ }
+ if spec[0] == "allow_repeated_fields_in_body" {
+ err := f.Set(spec[0], "true")
+ if err != nil {
+ return fmt.Errorf("Cannot set flag %s: %v", p, err)
+ }
+ continue
+ }
+ if spec[0] == "include_package_in_tags" {
+ err := f.Set(spec[0], "true")
+ if err != nil {
+ return fmt.Errorf("Cannot set flag %s: %v", p, err)
+ }
+ continue
+ }
+ err := f.Set(spec[0], "")
+ if err != nil {
+ return fmt.Errorf("Cannot set flag %s: %v", p, err)
+ }
+ continue
+ }
+ name, value := spec[0], spec[1]
+ if strings.HasPrefix(name, "M") {
+ pkgMap[name[1:]] = value
+ continue
+ }
+ if err := f.Set(name, value); err != nil {
+ return fmt.Errorf("Cannot set flag %s: %v", p, err)
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/BUILD.bazel b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/BUILD.bazel
new file mode 100644
index 0000000..8dea43d
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/BUILD.bazel
@@ -0,0 +1,38 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
+
+package(default_visibility = ["//visibility:public"])
+
+filegroup(
+ name = "options_proto_files",
+ srcs = [
+ "annotations.proto",
+ "openapiv2.proto",
+ ],
+)
+
+go_library(
+ name = "go_default_library",
+ embed = [":options_go_proto"],
+ importpath = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options",
+)
+
+proto_library(
+ name = "options_proto",
+ srcs = [
+ "annotations.proto",
+ "openapiv2.proto",
+ ],
+ deps = [
+ "@com_google_protobuf//:any_proto",
+ "@com_google_protobuf//:descriptor_proto",
+ "@com_google_protobuf//:struct_proto",
+ ],
+)
+
+go_proto_library(
+ name = "options_go_proto",
+ compilers = ["@io_bazel_rules_go//proto:go_grpc"],
+ importpath = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options",
+ proto = ":options_proto",
+)
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/annotations.pb.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/annotations.pb.go
new file mode 100644
index 0000000..9fc282b
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/annotations.pb.go
@@ -0,0 +1,103 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: protoc-gen-swagger/options/annotations.proto
+
+package options // import "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"
+
+import proto "github.com/golang/protobuf/proto"
+import fmt "fmt"
+import math "math"
+import descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+var E_Openapiv2Swagger = &proto.ExtensionDesc{
+ ExtendedType: (*descriptor.FileOptions)(nil),
+ ExtensionType: (*Swagger)(nil),
+ Field: 1042,
+ Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger",
+ Tag: "bytes,1042,opt,name=openapiv2_swagger,json=openapiv2Swagger",
+ Filename: "protoc-gen-swagger/options/annotations.proto",
+}
+
+var E_Openapiv2Operation = &proto.ExtensionDesc{
+ ExtendedType: (*descriptor.MethodOptions)(nil),
+ ExtensionType: (*Operation)(nil),
+ Field: 1042,
+ Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_operation",
+ Tag: "bytes,1042,opt,name=openapiv2_operation,json=openapiv2Operation",
+ Filename: "protoc-gen-swagger/options/annotations.proto",
+}
+
+var E_Openapiv2Schema = &proto.ExtensionDesc{
+ ExtendedType: (*descriptor.MessageOptions)(nil),
+ ExtensionType: (*Schema)(nil),
+ Field: 1042,
+ Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_schema",
+ Tag: "bytes,1042,opt,name=openapiv2_schema,json=openapiv2Schema",
+ Filename: "protoc-gen-swagger/options/annotations.proto",
+}
+
+var E_Openapiv2Tag = &proto.ExtensionDesc{
+ ExtendedType: (*descriptor.ServiceOptions)(nil),
+ ExtensionType: (*Tag)(nil),
+ Field: 1042,
+ Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_tag",
+ Tag: "bytes,1042,opt,name=openapiv2_tag,json=openapiv2Tag",
+ Filename: "protoc-gen-swagger/options/annotations.proto",
+}
+
+var E_Openapiv2Field = &proto.ExtensionDesc{
+ ExtendedType: (*descriptor.FieldOptions)(nil),
+ ExtensionType: (*JSONSchema)(nil),
+ Field: 1042,
+ Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_field",
+ Tag: "bytes,1042,opt,name=openapiv2_field,json=openapiv2Field",
+ Filename: "protoc-gen-swagger/options/annotations.proto",
+}
+
+func init() {
+ proto.RegisterExtension(E_Openapiv2Swagger)
+ proto.RegisterExtension(E_Openapiv2Operation)
+ proto.RegisterExtension(E_Openapiv2Schema)
+ proto.RegisterExtension(E_Openapiv2Tag)
+ proto.RegisterExtension(E_Openapiv2Field)
+}
+
+func init() {
+ proto.RegisterFile("protoc-gen-swagger/options/annotations.proto", fileDescriptor_annotations_8378bd63c2853a5a)
+}
+
+var fileDescriptor_annotations_8378bd63c2853a5a = []byte{
+ // 346 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x4f, 0x4f, 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0xa4, 0xc4, 0x93, 0x06, 0xe3, 0x3b, 0x09, 0x2f, 0xbe, 0x05, 0x78, 0x06, 0x37, 0xa7, 0x69, 0x25,
+ 0x42, 0xaf, 0x76, 0x84, 0xc1, 0xce, 0x3a, 0x0e, 0x0b, 0x5e, 0xb1, 0x8b, 0xb6, 0x41, 0xf3, 0x4b,
+ 0x09, 0x72, 0x0e, 0x0b, 0x11, 0x5e, 0xee, 0x89, 0x60, 0xad, 0xc0, 0x6a, 0x0d, 0xbc, 0x7e, 0x0d,
+ 0xde, 0x38, 0x3e, 0x2a, 0x5b, 0xf0, 0x8b, 0xc8, 0x06, 0x07, 0x25, 0xdd, 0x09, 0xdc, 0x83, 0x1e,
+ 0x82, 0x59, 0x29, 0x59, 0x45, 0x77, 0x6a, 0xa3, 0x47, 0x02, 0xe3, 0xff, 0x05, 0x64, 0x24, 0x30,
+ 0xda, 0x06, 0x65, 0x8e, 0xf1, 0x4c, 0x41, 0x32, 0x0d, 0xcf, 0xf7, 0xfc, 0x75, 0x48, 0xaa, 0x9d,
+ 0xf7, 0x6b, 0x43, 0x9f, 0x86, 0x83, 0x97, 0xfc, 0x9b, 0x0f, 0x0b, 0x96, 0xb7, 0xbc, 0x7f, 0x78,
+ 0xbd, 0x43, 0xe5, 0xe6, 0xcb, 0x09, 0x93, 0xb4, 0xe0, 0x9f, 0x86, 0x5d, 0x90, 0x64, 0x37, 0xd6,
+ 0x41, 0x3e, 0xe6, 0xfe, 0xfc, 0xe7, 0xcb, 0x3e, 0xf9, 0xe3, 0xdf, 0xf5, 0x3f, 0x02, 0x00, 0x00,
+ 0xff, 0xff, 0x4b, 0xc4, 0x41, 0xfb, 0x68, 0x03, 0x00, 0x00,
+}
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/annotations.proto b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/annotations.proto
new file mode 100644
index 0000000..2c0f594
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/annotations.proto
@@ -0,0 +1,44 @@
+syntax = "proto3";
+
+package grpc.gateway.protoc_gen_swagger.options;
+
+option go_package = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options";
+
+import "protoc-gen-swagger/options/openapiv2.proto";
+import "google/protobuf/descriptor.proto";
+
+extend google.protobuf.FileOptions {
+ // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project.
+ //
+ // All IDs are the same, as assigned. It is okay that they are the same, as they extend
+ // different descriptor messages.
+ Swagger openapiv2_swagger = 1042;
+}
+extend google.protobuf.MethodOptions {
+ // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project.
+ //
+ // All IDs are the same, as assigned. It is okay that they are the same, as they extend
+ // different descriptor messages.
+ Operation openapiv2_operation = 1042;
+}
+extend google.protobuf.MessageOptions {
+ // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project.
+ //
+ // All IDs are the same, as assigned. It is okay that they are the same, as they extend
+ // different descriptor messages.
+ Schema openapiv2_schema = 1042;
+}
+extend google.protobuf.ServiceOptions {
+ // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project.
+ //
+ // All IDs are the same, as assigned. It is okay that they are the same, as they extend
+ // different descriptor messages.
+ Tag openapiv2_tag = 1042;
+}
+extend google.protobuf.FieldOptions {
+ // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project.
+ //
+ // All IDs are the same, as assigned. It is okay that they are the same, as they extend
+ // different descriptor messages.
+ JSONSchema openapiv2_field = 1042;
+}
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/openapiv2.pb.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/openapiv2.pb.go
new file mode 100644
index 0000000..6720071
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/openapiv2.pb.go
@@ -0,0 +1,1598 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: protoc-gen-swagger/options/openapiv2.proto
+
+package options // import "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"
+
+import proto "github.com/golang/protobuf/proto"
+import fmt "fmt"
+import math "math"
+import any "github.com/golang/protobuf/ptypes/any"
+import _struct "github.com/golang/protobuf/ptypes/struct"
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type Swagger_SwaggerScheme int32
+
+const (
+ Swagger_UNKNOWN Swagger_SwaggerScheme = 0
+ Swagger_HTTP Swagger_SwaggerScheme = 1
+ Swagger_HTTPS Swagger_SwaggerScheme = 2
+ Swagger_WS Swagger_SwaggerScheme = 3
+ Swagger_WSS Swagger_SwaggerScheme = 4
+)
+
+var Swagger_SwaggerScheme_name = map[int32]string{
+ 0: "UNKNOWN",
+ 1: "HTTP",
+ 2: "HTTPS",
+ 3: "WS",
+ 4: "WSS",
+}
+var Swagger_SwaggerScheme_value = map[string]int32{
+ "UNKNOWN": 0,
+ "HTTP": 1,
+ "HTTPS": 2,
+ "WS": 3,
+ "WSS": 4,
+}
+
+func (x Swagger_SwaggerScheme) String() string {
+ return proto.EnumName(Swagger_SwaggerScheme_name, int32(x))
+}
+func (Swagger_SwaggerScheme) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{0, 0}
+}
+
+type JSONSchema_JSONSchemaSimpleTypes int32
+
+const (
+ JSONSchema_UNKNOWN JSONSchema_JSONSchemaSimpleTypes = 0
+ JSONSchema_ARRAY JSONSchema_JSONSchemaSimpleTypes = 1
+ JSONSchema_BOOLEAN JSONSchema_JSONSchemaSimpleTypes = 2
+ JSONSchema_INTEGER JSONSchema_JSONSchemaSimpleTypes = 3
+ JSONSchema_NULL JSONSchema_JSONSchemaSimpleTypes = 4
+ JSONSchema_NUMBER JSONSchema_JSONSchemaSimpleTypes = 5
+ JSONSchema_OBJECT JSONSchema_JSONSchemaSimpleTypes = 6
+ JSONSchema_STRING JSONSchema_JSONSchemaSimpleTypes = 7
+)
+
+var JSONSchema_JSONSchemaSimpleTypes_name = map[int32]string{
+ 0: "UNKNOWN",
+ 1: "ARRAY",
+ 2: "BOOLEAN",
+ 3: "INTEGER",
+ 4: "NULL",
+ 5: "NUMBER",
+ 6: "OBJECT",
+ 7: "STRING",
+}
+var JSONSchema_JSONSchemaSimpleTypes_value = map[string]int32{
+ "UNKNOWN": 0,
+ "ARRAY": 1,
+ "BOOLEAN": 2,
+ "INTEGER": 3,
+ "NULL": 4,
+ "NUMBER": 5,
+ "OBJECT": 6,
+ "STRING": 7,
+}
+
+func (x JSONSchema_JSONSchemaSimpleTypes) String() string {
+ return proto.EnumName(JSONSchema_JSONSchemaSimpleTypes_name, int32(x))
+}
+func (JSONSchema_JSONSchemaSimpleTypes) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{8, 0}
+}
+
+// Required. The type of the security scheme. Valid values are "basic",
+// "apiKey" or "oauth2".
+type SecurityScheme_Type int32
+
+const (
+ SecurityScheme_TYPE_INVALID SecurityScheme_Type = 0
+ SecurityScheme_TYPE_BASIC SecurityScheme_Type = 1
+ SecurityScheme_TYPE_API_KEY SecurityScheme_Type = 2
+ SecurityScheme_TYPE_OAUTH2 SecurityScheme_Type = 3
+)
+
+var SecurityScheme_Type_name = map[int32]string{
+ 0: "TYPE_INVALID",
+ 1: "TYPE_BASIC",
+ 2: "TYPE_API_KEY",
+ 3: "TYPE_OAUTH2",
+}
+var SecurityScheme_Type_value = map[string]int32{
+ "TYPE_INVALID": 0,
+ "TYPE_BASIC": 1,
+ "TYPE_API_KEY": 2,
+ "TYPE_OAUTH2": 3,
+}
+
+func (x SecurityScheme_Type) String() string {
+ return proto.EnumName(SecurityScheme_Type_name, int32(x))
+}
+func (SecurityScheme_Type) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{11, 0}
+}
+
+// Required. The location of the API key. Valid values are "query" or "header".
+type SecurityScheme_In int32
+
+const (
+ SecurityScheme_IN_INVALID SecurityScheme_In = 0
+ SecurityScheme_IN_QUERY SecurityScheme_In = 1
+ SecurityScheme_IN_HEADER SecurityScheme_In = 2
+)
+
+var SecurityScheme_In_name = map[int32]string{
+ 0: "IN_INVALID",
+ 1: "IN_QUERY",
+ 2: "IN_HEADER",
+}
+var SecurityScheme_In_value = map[string]int32{
+ "IN_INVALID": 0,
+ "IN_QUERY": 1,
+ "IN_HEADER": 2,
+}
+
+func (x SecurityScheme_In) String() string {
+ return proto.EnumName(SecurityScheme_In_name, int32(x))
+}
+func (SecurityScheme_In) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{11, 1}
+}
+
+// Required. The flow used by the OAuth2 security scheme. Valid values are
+// "implicit", "password", "application" or "accessCode".
+type SecurityScheme_Flow int32
+
+const (
+ SecurityScheme_FLOW_INVALID SecurityScheme_Flow = 0
+ SecurityScheme_FLOW_IMPLICIT SecurityScheme_Flow = 1
+ SecurityScheme_FLOW_PASSWORD SecurityScheme_Flow = 2
+ SecurityScheme_FLOW_APPLICATION SecurityScheme_Flow = 3
+ SecurityScheme_FLOW_ACCESS_CODE SecurityScheme_Flow = 4
+)
+
+var SecurityScheme_Flow_name = map[int32]string{
+ 0: "FLOW_INVALID",
+ 1: "FLOW_IMPLICIT",
+ 2: "FLOW_PASSWORD",
+ 3: "FLOW_APPLICATION",
+ 4: "FLOW_ACCESS_CODE",
+}
+var SecurityScheme_Flow_value = map[string]int32{
+ "FLOW_INVALID": 0,
+ "FLOW_IMPLICIT": 1,
+ "FLOW_PASSWORD": 2,
+ "FLOW_APPLICATION": 3,
+ "FLOW_ACCESS_CODE": 4,
+}
+
+func (x SecurityScheme_Flow) String() string {
+ return proto.EnumName(SecurityScheme_Flow_name, int32(x))
+}
+func (SecurityScheme_Flow) EnumDescriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{11, 2}
+}
+
+// `Swagger` is a representation of OpenAPI v2 specification's Swagger object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject
+//
+// TODO(ivucica): document fields
+type Swagger struct {
+ Swagger string `protobuf:"bytes,1,opt,name=swagger,proto3" json:"swagger,omitempty"`
+ Info *Info `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"`
+ Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"`
+ // `base_path` is the common prefix path used on all API endpoints (ie. /api, /v1, etc.). By adding this,
+ // it allows you to remove this portion from the path endpoints in your Swagger file making them easier
+ // to read. Note that using `base_path` does not change the endpoint paths that are generated in the resulting
+ // Swagger file. If you wish to use `base_path` with relatively generated Swagger paths, the
+ // `base_path` prefix must be manually removed from your `google.api.http` paths and your code changed to
+ // serve the API from the `base_path`.
+ BasePath string `protobuf:"bytes,4,opt,name=base_path,json=basePath,proto3" json:"base_path,omitempty"`
+ Schemes []Swagger_SwaggerScheme `protobuf:"varint,5,rep,packed,name=schemes,proto3,enum=grpc.gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme" json:"schemes,omitempty"`
+ Consumes []string `protobuf:"bytes,6,rep,name=consumes,proto3" json:"consumes,omitempty"`
+ Produces []string `protobuf:"bytes,7,rep,name=produces,proto3" json:"produces,omitempty"`
+ Responses map[string]*Response `protobuf:"bytes,10,rep,name=responses,proto3" json:"responses,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+ SecurityDefinitions *SecurityDefinitions `protobuf:"bytes,11,opt,name=security_definitions,json=securityDefinitions,proto3" json:"security_definitions,omitempty"`
+ Security []*SecurityRequirement `protobuf:"bytes,12,rep,name=security,proto3" json:"security,omitempty"`
+ ExternalDocs *ExternalDocumentation `protobuf:"bytes,14,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"`
+ Extensions map[string]*_struct.Value `protobuf:"bytes,15,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Swagger) Reset() { *m = Swagger{} }
+func (m *Swagger) String() string { return proto.CompactTextString(m) }
+func (*Swagger) ProtoMessage() {}
+func (*Swagger) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{0}
+}
+func (m *Swagger) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Swagger.Unmarshal(m, b)
+}
+func (m *Swagger) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Swagger.Marshal(b, m, deterministic)
+}
+func (dst *Swagger) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Swagger.Merge(dst, src)
+}
+func (m *Swagger) XXX_Size() int {
+ return xxx_messageInfo_Swagger.Size(m)
+}
+func (m *Swagger) XXX_DiscardUnknown() {
+ xxx_messageInfo_Swagger.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Swagger proto.InternalMessageInfo
+
+func (m *Swagger) GetSwagger() string {
+ if m != nil {
+ return m.Swagger
+ }
+ return ""
+}
+
+func (m *Swagger) GetInfo() *Info {
+ if m != nil {
+ return m.Info
+ }
+ return nil
+}
+
+func (m *Swagger) GetHost() string {
+ if m != nil {
+ return m.Host
+ }
+ return ""
+}
+
+func (m *Swagger) GetBasePath() string {
+ if m != nil {
+ return m.BasePath
+ }
+ return ""
+}
+
+func (m *Swagger) GetSchemes() []Swagger_SwaggerScheme {
+ if m != nil {
+ return m.Schemes
+ }
+ return nil
+}
+
+func (m *Swagger) GetConsumes() []string {
+ if m != nil {
+ return m.Consumes
+ }
+ return nil
+}
+
+func (m *Swagger) GetProduces() []string {
+ if m != nil {
+ return m.Produces
+ }
+ return nil
+}
+
+func (m *Swagger) GetResponses() map[string]*Response {
+ if m != nil {
+ return m.Responses
+ }
+ return nil
+}
+
+func (m *Swagger) GetSecurityDefinitions() *SecurityDefinitions {
+ if m != nil {
+ return m.SecurityDefinitions
+ }
+ return nil
+}
+
+func (m *Swagger) GetSecurity() []*SecurityRequirement {
+ if m != nil {
+ return m.Security
+ }
+ return nil
+}
+
+func (m *Swagger) GetExternalDocs() *ExternalDocumentation {
+ if m != nil {
+ return m.ExternalDocs
+ }
+ return nil
+}
+
+func (m *Swagger) GetExtensions() map[string]*_struct.Value {
+ if m != nil {
+ return m.Extensions
+ }
+ return nil
+}
+
+// `Operation` is a representation of OpenAPI v2 specification's Operation object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject
+//
+// TODO(ivucica): document fields
+type Operation struct {
+ Tags []string `protobuf:"bytes,1,rep,name=tags,proto3" json:"tags,omitempty"`
+ Summary string `protobuf:"bytes,2,opt,name=summary,proto3" json:"summary,omitempty"`
+ Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
+ ExternalDocs *ExternalDocumentation `protobuf:"bytes,4,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"`
+ OperationId string `protobuf:"bytes,5,opt,name=operation_id,json=operationId,proto3" json:"operation_id,omitempty"`
+ Consumes []string `protobuf:"bytes,6,rep,name=consumes,proto3" json:"consumes,omitempty"`
+ Produces []string `protobuf:"bytes,7,rep,name=produces,proto3" json:"produces,omitempty"`
+ Responses map[string]*Response `protobuf:"bytes,9,rep,name=responses,proto3" json:"responses,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+ Schemes []string `protobuf:"bytes,10,rep,name=schemes,proto3" json:"schemes,omitempty"`
+ Deprecated bool `protobuf:"varint,11,opt,name=deprecated,proto3" json:"deprecated,omitempty"`
+ Security []*SecurityRequirement `protobuf:"bytes,12,rep,name=security,proto3" json:"security,omitempty"`
+ Extensions map[string]*_struct.Value `protobuf:"bytes,13,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Operation) Reset() { *m = Operation{} }
+func (m *Operation) String() string { return proto.CompactTextString(m) }
+func (*Operation) ProtoMessage() {}
+func (*Operation) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{1}
+}
+func (m *Operation) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Operation.Unmarshal(m, b)
+}
+func (m *Operation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Operation.Marshal(b, m, deterministic)
+}
+func (dst *Operation) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Operation.Merge(dst, src)
+}
+func (m *Operation) XXX_Size() int {
+ return xxx_messageInfo_Operation.Size(m)
+}
+func (m *Operation) XXX_DiscardUnknown() {
+ xxx_messageInfo_Operation.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Operation proto.InternalMessageInfo
+
+func (m *Operation) GetTags() []string {
+ if m != nil {
+ return m.Tags
+ }
+ return nil
+}
+
+func (m *Operation) GetSummary() string {
+ if m != nil {
+ return m.Summary
+ }
+ return ""
+}
+
+func (m *Operation) GetDescription() string {
+ if m != nil {
+ return m.Description
+ }
+ return ""
+}
+
+func (m *Operation) GetExternalDocs() *ExternalDocumentation {
+ if m != nil {
+ return m.ExternalDocs
+ }
+ return nil
+}
+
+func (m *Operation) GetOperationId() string {
+ if m != nil {
+ return m.OperationId
+ }
+ return ""
+}
+
+func (m *Operation) GetConsumes() []string {
+ if m != nil {
+ return m.Consumes
+ }
+ return nil
+}
+
+func (m *Operation) GetProduces() []string {
+ if m != nil {
+ return m.Produces
+ }
+ return nil
+}
+
+func (m *Operation) GetResponses() map[string]*Response {
+ if m != nil {
+ return m.Responses
+ }
+ return nil
+}
+
+func (m *Operation) GetSchemes() []string {
+ if m != nil {
+ return m.Schemes
+ }
+ return nil
+}
+
+func (m *Operation) GetDeprecated() bool {
+ if m != nil {
+ return m.Deprecated
+ }
+ return false
+}
+
+func (m *Operation) GetSecurity() []*SecurityRequirement {
+ if m != nil {
+ return m.Security
+ }
+ return nil
+}
+
+func (m *Operation) GetExtensions() map[string]*_struct.Value {
+ if m != nil {
+ return m.Extensions
+ }
+ return nil
+}
+
+// `Response` is a representation of OpenAPI v2 specification's Response object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#responseObject
+//
+type Response struct {
+ // `Description` is a short description of the response.
+ // GFM syntax can be used for rich text representation.
+ Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"`
+ // `Schema` optionally defines the structure of the response.
+ // If `Schema` is not provided, it means there is no content to the response.
+ Schema *Schema `protobuf:"bytes,2,opt,name=schema,proto3" json:"schema,omitempty"`
+ Extensions map[string]*_struct.Value `protobuf:"bytes,5,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Response) Reset() { *m = Response{} }
+func (m *Response) String() string { return proto.CompactTextString(m) }
+func (*Response) ProtoMessage() {}
+func (*Response) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{2}
+}
+func (m *Response) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Response.Unmarshal(m, b)
+}
+func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Response.Marshal(b, m, deterministic)
+}
+func (dst *Response) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Response.Merge(dst, src)
+}
+func (m *Response) XXX_Size() int {
+ return xxx_messageInfo_Response.Size(m)
+}
+func (m *Response) XXX_DiscardUnknown() {
+ xxx_messageInfo_Response.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Response proto.InternalMessageInfo
+
+func (m *Response) GetDescription() string {
+ if m != nil {
+ return m.Description
+ }
+ return ""
+}
+
+func (m *Response) GetSchema() *Schema {
+ if m != nil {
+ return m.Schema
+ }
+ return nil
+}
+
+func (m *Response) GetExtensions() map[string]*_struct.Value {
+ if m != nil {
+ return m.Extensions
+ }
+ return nil
+}
+
+// `Info` is a representation of OpenAPI v2 specification's Info object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject
+//
+// TODO(ivucica): document fields
+type Info struct {
+ Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
+ Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
+ TermsOfService string `protobuf:"bytes,3,opt,name=terms_of_service,json=termsOfService,proto3" json:"terms_of_service,omitempty"`
+ Contact *Contact `protobuf:"bytes,4,opt,name=contact,proto3" json:"contact,omitempty"`
+ License *License `protobuf:"bytes,5,opt,name=license,proto3" json:"license,omitempty"`
+ Version string `protobuf:"bytes,6,opt,name=version,proto3" json:"version,omitempty"`
+ Extensions map[string]*_struct.Value `protobuf:"bytes,7,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Info) Reset() { *m = Info{} }
+func (m *Info) String() string { return proto.CompactTextString(m) }
+func (*Info) ProtoMessage() {}
+func (*Info) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{3}
+}
+func (m *Info) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Info.Unmarshal(m, b)
+}
+func (m *Info) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Info.Marshal(b, m, deterministic)
+}
+func (dst *Info) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Info.Merge(dst, src)
+}
+func (m *Info) XXX_Size() int {
+ return xxx_messageInfo_Info.Size(m)
+}
+func (m *Info) XXX_DiscardUnknown() {
+ xxx_messageInfo_Info.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Info proto.InternalMessageInfo
+
+func (m *Info) GetTitle() string {
+ if m != nil {
+ return m.Title
+ }
+ return ""
+}
+
+func (m *Info) GetDescription() string {
+ if m != nil {
+ return m.Description
+ }
+ return ""
+}
+
+func (m *Info) GetTermsOfService() string {
+ if m != nil {
+ return m.TermsOfService
+ }
+ return ""
+}
+
+func (m *Info) GetContact() *Contact {
+ if m != nil {
+ return m.Contact
+ }
+ return nil
+}
+
+func (m *Info) GetLicense() *License {
+ if m != nil {
+ return m.License
+ }
+ return nil
+}
+
+func (m *Info) GetVersion() string {
+ if m != nil {
+ return m.Version
+ }
+ return ""
+}
+
+func (m *Info) GetExtensions() map[string]*_struct.Value {
+ if m != nil {
+ return m.Extensions
+ }
+ return nil
+}
+
+// `Contact` is a representation of OpenAPI v2 specification's Contact object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject
+//
+// TODO(ivucica): document fields
+type Contact struct {
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"`
+ Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Contact) Reset() { *m = Contact{} }
+func (m *Contact) String() string { return proto.CompactTextString(m) }
+func (*Contact) ProtoMessage() {}
+func (*Contact) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{4}
+}
+func (m *Contact) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Contact.Unmarshal(m, b)
+}
+func (m *Contact) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Contact.Marshal(b, m, deterministic)
+}
+func (dst *Contact) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Contact.Merge(dst, src)
+}
+func (m *Contact) XXX_Size() int {
+ return xxx_messageInfo_Contact.Size(m)
+}
+func (m *Contact) XXX_DiscardUnknown() {
+ xxx_messageInfo_Contact.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Contact proto.InternalMessageInfo
+
+func (m *Contact) GetName() string {
+ if m != nil {
+ return m.Name
+ }
+ return ""
+}
+
+func (m *Contact) GetUrl() string {
+ if m != nil {
+ return m.Url
+ }
+ return ""
+}
+
+func (m *Contact) GetEmail() string {
+ if m != nil {
+ return m.Email
+ }
+ return ""
+}
+
+// `License` is a representation of OpenAPI v2 specification's License object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#licenseObject
+//
+type License struct {
+ // Required. The license name used for the API.
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ // A URL to the license used for the API.
+ Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *License) Reset() { *m = License{} }
+func (m *License) String() string { return proto.CompactTextString(m) }
+func (*License) ProtoMessage() {}
+func (*License) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{5}
+}
+func (m *License) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_License.Unmarshal(m, b)
+}
+func (m *License) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_License.Marshal(b, m, deterministic)
+}
+func (dst *License) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_License.Merge(dst, src)
+}
+func (m *License) XXX_Size() int {
+ return xxx_messageInfo_License.Size(m)
+}
+func (m *License) XXX_DiscardUnknown() {
+ xxx_messageInfo_License.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_License proto.InternalMessageInfo
+
+func (m *License) GetName() string {
+ if m != nil {
+ return m.Name
+ }
+ return ""
+}
+
+func (m *License) GetUrl() string {
+ if m != nil {
+ return m.Url
+ }
+ return ""
+}
+
+// `ExternalDocumentation` is a representation of OpenAPI v2 specification's
+// ExternalDocumentation object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject
+//
+// TODO(ivucica): document fields
+type ExternalDocumentation struct {
+ Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"`
+ Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ExternalDocumentation) Reset() { *m = ExternalDocumentation{} }
+func (m *ExternalDocumentation) String() string { return proto.CompactTextString(m) }
+func (*ExternalDocumentation) ProtoMessage() {}
+func (*ExternalDocumentation) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{6}
+}
+func (m *ExternalDocumentation) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ExternalDocumentation.Unmarshal(m, b)
+}
+func (m *ExternalDocumentation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ExternalDocumentation.Marshal(b, m, deterministic)
+}
+func (dst *ExternalDocumentation) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ExternalDocumentation.Merge(dst, src)
+}
+func (m *ExternalDocumentation) XXX_Size() int {
+ return xxx_messageInfo_ExternalDocumentation.Size(m)
+}
+func (m *ExternalDocumentation) XXX_DiscardUnknown() {
+ xxx_messageInfo_ExternalDocumentation.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ExternalDocumentation proto.InternalMessageInfo
+
+func (m *ExternalDocumentation) GetDescription() string {
+ if m != nil {
+ return m.Description
+ }
+ return ""
+}
+
+func (m *ExternalDocumentation) GetUrl() string {
+ if m != nil {
+ return m.Url
+ }
+ return ""
+}
+
+// `Schema` is a representation of OpenAPI v2 specification's Schema object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
+//
+// TODO(ivucica): document fields
+type Schema struct {
+ JsonSchema *JSONSchema `protobuf:"bytes,1,opt,name=json_schema,json=jsonSchema,proto3" json:"json_schema,omitempty"`
+ Discriminator string `protobuf:"bytes,2,opt,name=discriminator,proto3" json:"discriminator,omitempty"`
+ ReadOnly bool `protobuf:"varint,3,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"`
+ ExternalDocs *ExternalDocumentation `protobuf:"bytes,5,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"`
+ Example *any.Any `protobuf:"bytes,6,opt,name=example,proto3" json:"example,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Schema) Reset() { *m = Schema{} }
+func (m *Schema) String() string { return proto.CompactTextString(m) }
+func (*Schema) ProtoMessage() {}
+func (*Schema) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{7}
+}
+func (m *Schema) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Schema.Unmarshal(m, b)
+}
+func (m *Schema) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Schema.Marshal(b, m, deterministic)
+}
+func (dst *Schema) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Schema.Merge(dst, src)
+}
+func (m *Schema) XXX_Size() int {
+ return xxx_messageInfo_Schema.Size(m)
+}
+func (m *Schema) XXX_DiscardUnknown() {
+ xxx_messageInfo_Schema.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Schema proto.InternalMessageInfo
+
+func (m *Schema) GetJsonSchema() *JSONSchema {
+ if m != nil {
+ return m.JsonSchema
+ }
+ return nil
+}
+
+func (m *Schema) GetDiscriminator() string {
+ if m != nil {
+ return m.Discriminator
+ }
+ return ""
+}
+
+func (m *Schema) GetReadOnly() bool {
+ if m != nil {
+ return m.ReadOnly
+ }
+ return false
+}
+
+func (m *Schema) GetExternalDocs() *ExternalDocumentation {
+ if m != nil {
+ return m.ExternalDocs
+ }
+ return nil
+}
+
+func (m *Schema) GetExample() *any.Any {
+ if m != nil {
+ return m.Example
+ }
+ return nil
+}
+
+// `JSONSchema` represents properties from JSON Schema taken, and as used, in
+// the OpenAPI v2 spec.
+//
+// This includes changes made by OpenAPI v2.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
+//
+// See also: https://cswr.github.io/JsonSchema/spec/basic_types/,
+// https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json
+//
+// TODO(ivucica): document fields
+type JSONSchema struct {
+ // Ref is used to define an external reference to include in the message.
+ // This could be a fully qualified proto message reference, and that type must be imported
+ // into the protofile. If no message is identified, the Ref will be used verbatim in
+ // the output.
+ // For example:
+ // `ref: ".google.protobuf.Timestamp"`.
+ Ref string `protobuf:"bytes,3,opt,name=ref,proto3" json:"ref,omitempty"`
+ Title string `protobuf:"bytes,5,opt,name=title,proto3" json:"title,omitempty"`
+ Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"`
+ Default string `protobuf:"bytes,7,opt,name=default,proto3" json:"default,omitempty"`
+ ReadOnly bool `protobuf:"varint,8,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"`
+ MultipleOf float64 `protobuf:"fixed64,10,opt,name=multiple_of,json=multipleOf,proto3" json:"multiple_of,omitempty"`
+ Maximum float64 `protobuf:"fixed64,11,opt,name=maximum,proto3" json:"maximum,omitempty"`
+ ExclusiveMaximum bool `protobuf:"varint,12,opt,name=exclusive_maximum,json=exclusiveMaximum,proto3" json:"exclusive_maximum,omitempty"`
+ Minimum float64 `protobuf:"fixed64,13,opt,name=minimum,proto3" json:"minimum,omitempty"`
+ ExclusiveMinimum bool `protobuf:"varint,14,opt,name=exclusive_minimum,json=exclusiveMinimum,proto3" json:"exclusive_minimum,omitempty"`
+ MaxLength uint64 `protobuf:"varint,15,opt,name=max_length,json=maxLength,proto3" json:"max_length,omitempty"`
+ MinLength uint64 `protobuf:"varint,16,opt,name=min_length,json=minLength,proto3" json:"min_length,omitempty"`
+ Pattern string `protobuf:"bytes,17,opt,name=pattern,proto3" json:"pattern,omitempty"`
+ MaxItems uint64 `protobuf:"varint,20,opt,name=max_items,json=maxItems,proto3" json:"max_items,omitempty"`
+ MinItems uint64 `protobuf:"varint,21,opt,name=min_items,json=minItems,proto3" json:"min_items,omitempty"`
+ UniqueItems bool `protobuf:"varint,22,opt,name=unique_items,json=uniqueItems,proto3" json:"unique_items,omitempty"`
+ MaxProperties uint64 `protobuf:"varint,24,opt,name=max_properties,json=maxProperties,proto3" json:"max_properties,omitempty"`
+ MinProperties uint64 `protobuf:"varint,25,opt,name=min_properties,json=minProperties,proto3" json:"min_properties,omitempty"`
+ Required []string `protobuf:"bytes,26,rep,name=required,proto3" json:"required,omitempty"`
+ // Items in 'array' must be unique.
+ Array []string `protobuf:"bytes,34,rep,name=array,proto3" json:"array,omitempty"`
+ Type []JSONSchema_JSONSchemaSimpleTypes `protobuf:"varint,35,rep,packed,name=type,proto3,enum=grpc.gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes" json:"type,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *JSONSchema) Reset() { *m = JSONSchema{} }
+func (m *JSONSchema) String() string { return proto.CompactTextString(m) }
+func (*JSONSchema) ProtoMessage() {}
+func (*JSONSchema) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{8}
+}
+func (m *JSONSchema) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_JSONSchema.Unmarshal(m, b)
+}
+func (m *JSONSchema) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_JSONSchema.Marshal(b, m, deterministic)
+}
+func (dst *JSONSchema) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_JSONSchema.Merge(dst, src)
+}
+func (m *JSONSchema) XXX_Size() int {
+ return xxx_messageInfo_JSONSchema.Size(m)
+}
+func (m *JSONSchema) XXX_DiscardUnknown() {
+ xxx_messageInfo_JSONSchema.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_JSONSchema proto.InternalMessageInfo
+
+func (m *JSONSchema) GetRef() string {
+ if m != nil {
+ return m.Ref
+ }
+ return ""
+}
+
+func (m *JSONSchema) GetTitle() string {
+ if m != nil {
+ return m.Title
+ }
+ return ""
+}
+
+func (m *JSONSchema) GetDescription() string {
+ if m != nil {
+ return m.Description
+ }
+ return ""
+}
+
+func (m *JSONSchema) GetDefault() string {
+ if m != nil {
+ return m.Default
+ }
+ return ""
+}
+
+func (m *JSONSchema) GetReadOnly() bool {
+ if m != nil {
+ return m.ReadOnly
+ }
+ return false
+}
+
+func (m *JSONSchema) GetMultipleOf() float64 {
+ if m != nil {
+ return m.MultipleOf
+ }
+ return 0
+}
+
+func (m *JSONSchema) GetMaximum() float64 {
+ if m != nil {
+ return m.Maximum
+ }
+ return 0
+}
+
+func (m *JSONSchema) GetExclusiveMaximum() bool {
+ if m != nil {
+ return m.ExclusiveMaximum
+ }
+ return false
+}
+
+func (m *JSONSchema) GetMinimum() float64 {
+ if m != nil {
+ return m.Minimum
+ }
+ return 0
+}
+
+func (m *JSONSchema) GetExclusiveMinimum() bool {
+ if m != nil {
+ return m.ExclusiveMinimum
+ }
+ return false
+}
+
+func (m *JSONSchema) GetMaxLength() uint64 {
+ if m != nil {
+ return m.MaxLength
+ }
+ return 0
+}
+
+func (m *JSONSchema) GetMinLength() uint64 {
+ if m != nil {
+ return m.MinLength
+ }
+ return 0
+}
+
+func (m *JSONSchema) GetPattern() string {
+ if m != nil {
+ return m.Pattern
+ }
+ return ""
+}
+
+func (m *JSONSchema) GetMaxItems() uint64 {
+ if m != nil {
+ return m.MaxItems
+ }
+ return 0
+}
+
+func (m *JSONSchema) GetMinItems() uint64 {
+ if m != nil {
+ return m.MinItems
+ }
+ return 0
+}
+
+func (m *JSONSchema) GetUniqueItems() bool {
+ if m != nil {
+ return m.UniqueItems
+ }
+ return false
+}
+
+func (m *JSONSchema) GetMaxProperties() uint64 {
+ if m != nil {
+ return m.MaxProperties
+ }
+ return 0
+}
+
+func (m *JSONSchema) GetMinProperties() uint64 {
+ if m != nil {
+ return m.MinProperties
+ }
+ return 0
+}
+
+func (m *JSONSchema) GetRequired() []string {
+ if m != nil {
+ return m.Required
+ }
+ return nil
+}
+
+func (m *JSONSchema) GetArray() []string {
+ if m != nil {
+ return m.Array
+ }
+ return nil
+}
+
+func (m *JSONSchema) GetType() []JSONSchema_JSONSchemaSimpleTypes {
+ if m != nil {
+ return m.Type
+ }
+ return nil
+}
+
+// `Tag` is a representation of OpenAPI v2 specification's Tag object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject
+//
+// TODO(ivucica): document fields
+type Tag struct {
+ // TODO(ivucica): Description should be extracted from comments on the proto
+ // service object.
+ Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
+ ExternalDocs *ExternalDocumentation `protobuf:"bytes,3,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Tag) Reset() { *m = Tag{} }
+func (m *Tag) String() string { return proto.CompactTextString(m) }
+func (*Tag) ProtoMessage() {}
+func (*Tag) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{9}
+}
+func (m *Tag) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Tag.Unmarshal(m, b)
+}
+func (m *Tag) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Tag.Marshal(b, m, deterministic)
+}
+func (dst *Tag) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Tag.Merge(dst, src)
+}
+func (m *Tag) XXX_Size() int {
+ return xxx_messageInfo_Tag.Size(m)
+}
+func (m *Tag) XXX_DiscardUnknown() {
+ xxx_messageInfo_Tag.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Tag proto.InternalMessageInfo
+
+func (m *Tag) GetDescription() string {
+ if m != nil {
+ return m.Description
+ }
+ return ""
+}
+
+func (m *Tag) GetExternalDocs() *ExternalDocumentation {
+ if m != nil {
+ return m.ExternalDocs
+ }
+ return nil
+}
+
+// `SecurityDefinitions` is a representation of OpenAPI v2 specification's
+// Security Definitions object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityDefinitionsObject
+//
+// A declaration of the security schemes available to be used in the
+// specification. This does not enforce the security schemes on the operations
+// and only serves to provide the relevant details for each scheme.
+type SecurityDefinitions struct {
+ // A single security scheme definition, mapping a "name" to the scheme it defines.
+ Security map[string]*SecurityScheme `protobuf:"bytes,1,rep,name=security,proto3" json:"security,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *SecurityDefinitions) Reset() { *m = SecurityDefinitions{} }
+func (m *SecurityDefinitions) String() string { return proto.CompactTextString(m) }
+func (*SecurityDefinitions) ProtoMessage() {}
+func (*SecurityDefinitions) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{10}
+}
+func (m *SecurityDefinitions) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_SecurityDefinitions.Unmarshal(m, b)
+}
+func (m *SecurityDefinitions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_SecurityDefinitions.Marshal(b, m, deterministic)
+}
+func (dst *SecurityDefinitions) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_SecurityDefinitions.Merge(dst, src)
+}
+func (m *SecurityDefinitions) XXX_Size() int {
+ return xxx_messageInfo_SecurityDefinitions.Size(m)
+}
+func (m *SecurityDefinitions) XXX_DiscardUnknown() {
+ xxx_messageInfo_SecurityDefinitions.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_SecurityDefinitions proto.InternalMessageInfo
+
+func (m *SecurityDefinitions) GetSecurity() map[string]*SecurityScheme {
+ if m != nil {
+ return m.Security
+ }
+ return nil
+}
+
+// `SecurityScheme` is a representation of OpenAPI v2 specification's
+// Security Scheme object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securitySchemeObject
+//
+// Allows the definition of a security scheme that can be used by the
+// operations. Supported schemes are basic authentication, an API key (either as
+// a header or as a query parameter) and OAuth2's common flows (implicit,
+// password, application and access code).
+type SecurityScheme struct {
+ // Required. The type of the security scheme. Valid values are "basic",
+ // "apiKey" or "oauth2".
+ Type SecurityScheme_Type `protobuf:"varint,1,opt,name=type,proto3,enum=grpc.gateway.protoc_gen_swagger.options.SecurityScheme_Type" json:"type,omitempty"`
+ // A short description for security scheme.
+ Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
+ // Required. The name of the header or query parameter to be used.
+ //
+ // Valid for apiKey.
+ Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
+ // Required. The location of the API key. Valid values are "query" or "header".
+ //
+ // Valid for apiKey.
+ In SecurityScheme_In `protobuf:"varint,4,opt,name=in,proto3,enum=grpc.gateway.protoc_gen_swagger.options.SecurityScheme_In" json:"in,omitempty"`
+ // Required. The flow used by the OAuth2 security scheme. Valid values are
+ // "implicit", "password", "application" or "accessCode".
+ //
+ // Valid for oauth2.
+ Flow SecurityScheme_Flow `protobuf:"varint,5,opt,name=flow,proto3,enum=grpc.gateway.protoc_gen_swagger.options.SecurityScheme_Flow" json:"flow,omitempty"`
+ // Required. The authorization URL to be used for this flow. This SHOULD be in
+ // the form of a URL.
+ //
+ // Valid for oauth2/implicit and oauth2/accessCode.
+ AuthorizationUrl string `protobuf:"bytes,6,opt,name=authorization_url,json=authorizationUrl,proto3" json:"authorization_url,omitempty"`
+ // Required. The token URL to be used for this flow. This SHOULD be in the
+ // form of a URL.
+ //
+ // Valid for oauth2/password, oauth2/application and oauth2/accessCode.
+ TokenUrl string `protobuf:"bytes,7,opt,name=token_url,json=tokenUrl,proto3" json:"token_url,omitempty"`
+ // Required. The available scopes for the OAuth2 security scheme.
+ //
+ // Valid for oauth2.
+ Scopes *Scopes `protobuf:"bytes,8,opt,name=scopes,proto3" json:"scopes,omitempty"`
+ Extensions map[string]*_struct.Value `protobuf:"bytes,9,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *SecurityScheme) Reset() { *m = SecurityScheme{} }
+func (m *SecurityScheme) String() string { return proto.CompactTextString(m) }
+func (*SecurityScheme) ProtoMessage() {}
+func (*SecurityScheme) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{11}
+}
+func (m *SecurityScheme) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_SecurityScheme.Unmarshal(m, b)
+}
+func (m *SecurityScheme) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_SecurityScheme.Marshal(b, m, deterministic)
+}
+func (dst *SecurityScheme) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_SecurityScheme.Merge(dst, src)
+}
+func (m *SecurityScheme) XXX_Size() int {
+ return xxx_messageInfo_SecurityScheme.Size(m)
+}
+func (m *SecurityScheme) XXX_DiscardUnknown() {
+ xxx_messageInfo_SecurityScheme.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_SecurityScheme proto.InternalMessageInfo
+
+func (m *SecurityScheme) GetType() SecurityScheme_Type {
+ if m != nil {
+ return m.Type
+ }
+ return SecurityScheme_TYPE_INVALID
+}
+
+func (m *SecurityScheme) GetDescription() string {
+ if m != nil {
+ return m.Description
+ }
+ return ""
+}
+
+func (m *SecurityScheme) GetName() string {
+ if m != nil {
+ return m.Name
+ }
+ return ""
+}
+
+func (m *SecurityScheme) GetIn() SecurityScheme_In {
+ if m != nil {
+ return m.In
+ }
+ return SecurityScheme_IN_INVALID
+}
+
+func (m *SecurityScheme) GetFlow() SecurityScheme_Flow {
+ if m != nil {
+ return m.Flow
+ }
+ return SecurityScheme_FLOW_INVALID
+}
+
+func (m *SecurityScheme) GetAuthorizationUrl() string {
+ if m != nil {
+ return m.AuthorizationUrl
+ }
+ return ""
+}
+
+func (m *SecurityScheme) GetTokenUrl() string {
+ if m != nil {
+ return m.TokenUrl
+ }
+ return ""
+}
+
+func (m *SecurityScheme) GetScopes() *Scopes {
+ if m != nil {
+ return m.Scopes
+ }
+ return nil
+}
+
+func (m *SecurityScheme) GetExtensions() map[string]*_struct.Value {
+ if m != nil {
+ return m.Extensions
+ }
+ return nil
+}
+
+// `SecurityRequirement` is a representation of OpenAPI v2 specification's
+// Security Requirement object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityRequirementObject
+//
+// Lists the required security schemes to execute this operation. The object can
+// have multiple security schemes declared in it which are all required (that
+// is, there is a logical AND between the schemes).
+//
+// The name used for each property MUST correspond to a security scheme
+// declared in the Security Definitions.
+type SecurityRequirement struct {
+ // Each name must correspond to a security scheme which is declared in
+ // the Security Definitions. If the security scheme is of type "oauth2",
+ // then the value is a list of scope names required for the execution.
+ // For other security scheme types, the array MUST be empty.
+ SecurityRequirement map[string]*SecurityRequirement_SecurityRequirementValue `protobuf:"bytes,1,rep,name=security_requirement,json=securityRequirement,proto3" json:"security_requirement,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *SecurityRequirement) Reset() { *m = SecurityRequirement{} }
+func (m *SecurityRequirement) String() string { return proto.CompactTextString(m) }
+func (*SecurityRequirement) ProtoMessage() {}
+func (*SecurityRequirement) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{12}
+}
+func (m *SecurityRequirement) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_SecurityRequirement.Unmarshal(m, b)
+}
+func (m *SecurityRequirement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_SecurityRequirement.Marshal(b, m, deterministic)
+}
+func (dst *SecurityRequirement) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_SecurityRequirement.Merge(dst, src)
+}
+func (m *SecurityRequirement) XXX_Size() int {
+ return xxx_messageInfo_SecurityRequirement.Size(m)
+}
+func (m *SecurityRequirement) XXX_DiscardUnknown() {
+ xxx_messageInfo_SecurityRequirement.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_SecurityRequirement proto.InternalMessageInfo
+
+func (m *SecurityRequirement) GetSecurityRequirement() map[string]*SecurityRequirement_SecurityRequirementValue {
+ if m != nil {
+ return m.SecurityRequirement
+ }
+ return nil
+}
+
+// If the security scheme is of type "oauth2", then the value is a list of
+// scope names required for the execution. For other security scheme types,
+// the array MUST be empty.
+type SecurityRequirement_SecurityRequirementValue struct {
+ Scope []string `protobuf:"bytes,1,rep,name=scope,proto3" json:"scope,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *SecurityRequirement_SecurityRequirementValue) Reset() {
+ *m = SecurityRequirement_SecurityRequirementValue{}
+}
+func (m *SecurityRequirement_SecurityRequirementValue) String() string {
+ return proto.CompactTextString(m)
+}
+func (*SecurityRequirement_SecurityRequirementValue) ProtoMessage() {}
+func (*SecurityRequirement_SecurityRequirementValue) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{12, 0}
+}
+func (m *SecurityRequirement_SecurityRequirementValue) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_SecurityRequirement_SecurityRequirementValue.Unmarshal(m, b)
+}
+func (m *SecurityRequirement_SecurityRequirementValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_SecurityRequirement_SecurityRequirementValue.Marshal(b, m, deterministic)
+}
+func (dst *SecurityRequirement_SecurityRequirementValue) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_SecurityRequirement_SecurityRequirementValue.Merge(dst, src)
+}
+func (m *SecurityRequirement_SecurityRequirementValue) XXX_Size() int {
+ return xxx_messageInfo_SecurityRequirement_SecurityRequirementValue.Size(m)
+}
+func (m *SecurityRequirement_SecurityRequirementValue) XXX_DiscardUnknown() {
+ xxx_messageInfo_SecurityRequirement_SecurityRequirementValue.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_SecurityRequirement_SecurityRequirementValue proto.InternalMessageInfo
+
+func (m *SecurityRequirement_SecurityRequirementValue) GetScope() []string {
+ if m != nil {
+ return m.Scope
+ }
+ return nil
+}
+
+// `Scopes` is a representation of OpenAPI v2 specification's Scopes object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#scopesObject
+//
+// Lists the available scopes for an OAuth2 security scheme.
+type Scopes struct {
+ // Maps between a name of a scope to a short description of it (as the value
+ // of the property).
+ Scope map[string]string `protobuf:"bytes,1,rep,name=scope,proto3" json:"scope,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Scopes) Reset() { *m = Scopes{} }
+func (m *Scopes) String() string { return proto.CompactTextString(m) }
+func (*Scopes) ProtoMessage() {}
+func (*Scopes) Descriptor() ([]byte, []int) {
+ return fileDescriptor_openapiv2_7182f700aabb5117, []int{13}
+}
+func (m *Scopes) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Scopes.Unmarshal(m, b)
+}
+func (m *Scopes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Scopes.Marshal(b, m, deterministic)
+}
+func (dst *Scopes) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Scopes.Merge(dst, src)
+}
+func (m *Scopes) XXX_Size() int {
+ return xxx_messageInfo_Scopes.Size(m)
+}
+func (m *Scopes) XXX_DiscardUnknown() {
+ xxx_messageInfo_Scopes.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Scopes proto.InternalMessageInfo
+
+func (m *Scopes) GetScope() map[string]string {
+ if m != nil {
+ return m.Scope
+ }
+ return nil
+}
+
+func init() {
+ proto.RegisterType((*Swagger)(nil), "grpc.gateway.protoc_gen_swagger.options.Swagger")
+ proto.RegisterMapType((map[string]*_struct.Value)(nil), "grpc.gateway.protoc_gen_swagger.options.Swagger.ExtensionsEntry")
+ proto.RegisterMapType((map[string]*Response)(nil), "grpc.gateway.protoc_gen_swagger.options.Swagger.ResponsesEntry")
+ proto.RegisterType((*Operation)(nil), "grpc.gateway.protoc_gen_swagger.options.Operation")
+ proto.RegisterMapType((map[string]*_struct.Value)(nil), "grpc.gateway.protoc_gen_swagger.options.Operation.ExtensionsEntry")
+ proto.RegisterMapType((map[string]*Response)(nil), "grpc.gateway.protoc_gen_swagger.options.Operation.ResponsesEntry")
+ proto.RegisterType((*Response)(nil), "grpc.gateway.protoc_gen_swagger.options.Response")
+ proto.RegisterMapType((map[string]*_struct.Value)(nil), "grpc.gateway.protoc_gen_swagger.options.Response.ExtensionsEntry")
+ proto.RegisterType((*Info)(nil), "grpc.gateway.protoc_gen_swagger.options.Info")
+ proto.RegisterMapType((map[string]*_struct.Value)(nil), "grpc.gateway.protoc_gen_swagger.options.Info.ExtensionsEntry")
+ proto.RegisterType((*Contact)(nil), "grpc.gateway.protoc_gen_swagger.options.Contact")
+ proto.RegisterType((*License)(nil), "grpc.gateway.protoc_gen_swagger.options.License")
+ proto.RegisterType((*ExternalDocumentation)(nil), "grpc.gateway.protoc_gen_swagger.options.ExternalDocumentation")
+ proto.RegisterType((*Schema)(nil), "grpc.gateway.protoc_gen_swagger.options.Schema")
+ proto.RegisterType((*JSONSchema)(nil), "grpc.gateway.protoc_gen_swagger.options.JSONSchema")
+ proto.RegisterType((*Tag)(nil), "grpc.gateway.protoc_gen_swagger.options.Tag")
+ proto.RegisterType((*SecurityDefinitions)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityDefinitions")
+ proto.RegisterMapType((map[string]*SecurityScheme)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityDefinitions.SecurityEntry")
+ proto.RegisterType((*SecurityScheme)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityScheme")
+ proto.RegisterMapType((map[string]*_struct.Value)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityScheme.ExtensionsEntry")
+ proto.RegisterType((*SecurityRequirement)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityRequirement")
+ proto.RegisterMapType((map[string]*SecurityRequirement_SecurityRequirementValue)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityRequirement.SecurityRequirementEntry")
+ proto.RegisterType((*SecurityRequirement_SecurityRequirementValue)(nil), "grpc.gateway.protoc_gen_swagger.options.SecurityRequirement.SecurityRequirementValue")
+ proto.RegisterType((*Scopes)(nil), "grpc.gateway.protoc_gen_swagger.options.Scopes")
+ proto.RegisterMapType((map[string]string)(nil), "grpc.gateway.protoc_gen_swagger.options.Scopes.ScopeEntry")
+ proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme", Swagger_SwaggerScheme_name, Swagger_SwaggerScheme_value)
+ proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes", JSONSchema_JSONSchemaSimpleTypes_name, JSONSchema_JSONSchemaSimpleTypes_value)
+ proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.SecurityScheme_Type", SecurityScheme_Type_name, SecurityScheme_Type_value)
+ proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.SecurityScheme_In", SecurityScheme_In_name, SecurityScheme_In_value)
+ proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.SecurityScheme_Flow", SecurityScheme_Flow_name, SecurityScheme_Flow_value)
+}
+
+func init() {
+ proto.RegisterFile("protoc-gen-swagger/options/openapiv2.proto", fileDescriptor_openapiv2_7182f700aabb5117)
+}
+
+var fileDescriptor_openapiv2_7182f700aabb5117 = []byte{
+ // 1884 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x58, 0x5b, 0x73, 0xdb, 0xc6,
+ 0xf5, 0x0f, 0x48, 0x90, 0x04, 0x0f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0b, 0x54, 0x36, 0xa9, 0x2f, 0xcc, 0x9e, 0xff, 0x70, 0xe7, 0x89, 0xcb, 0x7f, 0x0e, 0x30,
+ 0x67, 0xae, 0xb8, 0xed, 0x76, 0xf6, 0xb6, 0xe5, 0xcc, 0xb1, 0x0e, 0x0e, 0x7f, 0xdf, 0x1a, 0x3b,
+ 0xf1, 0x45, 0x72, 0xde, 0xb4, 0x03, 0x6f, 0x8f, 0x1e, 0xe4, 0x29, 0xb1, 0x83, 0x68, 0x1a, 0xc5,
+ 0x44, 0x90, 0xe2, 0x5c, 0x7b, 0xdf, 0xff, 0xd7, 0xff, 0x79, 0x91, 0xc9, 0x3e, 0xfb, 0x6f, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x29, 0x5a, 0xd3, 0x93, 0x1f, 0x18, 0x00, 0x00,
+}
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/openapiv2.proto b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/openapiv2.proto
new file mode 100644
index 0000000..83cb564
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/openapiv2.proto
@@ -0,0 +1,379 @@
+syntax = "proto3";
+
+package grpc.gateway.protoc_gen_swagger.options;
+
+option go_package = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options";
+
+import "google/protobuf/any.proto";
+import "google/protobuf/struct.proto";
+
+// `Swagger` is a representation of OpenAPI v2 specification's Swagger object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject
+//
+// TODO(ivucica): document fields
+message Swagger {
+ string swagger = 1;
+ Info info = 2;
+ string host = 3;
+ // `base_path` is the common prefix path used on all API endpoints (ie. /api, /v1, etc.). By adding this,
+ // it allows you to remove this portion from the path endpoints in your Swagger file making them easier
+ // to read. Note that using `base_path` does not change the endpoint paths that are generated in the resulting
+ // Swagger file. If you wish to use `base_path` with relatively generated Swagger paths, the
+ // `base_path` prefix must be manually removed from your `google.api.http` paths and your code changed to
+ // serve the API from the `base_path`.
+ string base_path = 4;
+ enum SwaggerScheme {
+ UNKNOWN = 0;
+ HTTP = 1;
+ HTTPS = 2;
+ WS = 3;
+ WSS = 4;
+ }
+ repeated SwaggerScheme schemes = 5;
+ repeated string consumes = 6;
+ repeated string produces = 7;
+ // field 8 is reserved for 'paths'.
+ reserved 8;
+ // field 9 is reserved for 'definitions', which at this time are already
+ // exposed as and customizable as proto messages.
+ reserved 9;
+ map<string, Response> responses = 10;
+ SecurityDefinitions security_definitions = 11;
+ repeated SecurityRequirement security = 12;
+ // field 13 is reserved for 'tags', which are supposed to be exposed as and
+ // customizable as proto services. TODO(ivucica): add processing of proto
+ // service objects into OpenAPI v2 Tag objects.
+ reserved 13;
+ ExternalDocumentation external_docs = 14;
+ map<string, google.protobuf.Value> extensions = 15;
+}
+
+// `Operation` is a representation of OpenAPI v2 specification's Operation object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject
+//
+// TODO(ivucica): document fields
+message Operation {
+ repeated string tags = 1;
+ string summary = 2;
+ string description = 3;
+ ExternalDocumentation external_docs = 4;
+ string operation_id = 5;
+ repeated string consumes = 6;
+ repeated string produces = 7;
+ // field 8 is reserved for 'parameters'.
+ reserved 8;
+ map<string, Response> responses = 9;
+ repeated string schemes = 10;
+ bool deprecated = 11;
+ repeated SecurityRequirement security = 12;
+ map<string, google.protobuf.Value> extensions = 13;
+}
+
+// `Response` is a representation of OpenAPI v2 specification's Response object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#responseObject
+//
+message Response {
+ // `Description` is a short description of the response.
+ // GFM syntax can be used for rich text representation.
+ string description = 1;
+ // `Schema` optionally defines the structure of the response.
+ // If `Schema` is not provided, it means there is no content to the response.
+ Schema schema = 2;
+ // field 3 is reserved for 'headers'.
+ reserved 3;
+ // field 3 is reserved for 'example'.
+ reserved 4;
+ map<string, google.protobuf.Value> extensions = 5;
+}
+
+// `Info` is a representation of OpenAPI v2 specification's Info object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject
+//
+// TODO(ivucica): document fields
+message Info {
+ string title = 1;
+ string description = 2;
+ string terms_of_service = 3;
+ Contact contact = 4;
+ License license = 5;
+ string version = 6;
+ map<string, google.protobuf.Value> extensions = 7;
+}
+
+// `Contact` is a representation of OpenAPI v2 specification's Contact object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject
+//
+// TODO(ivucica): document fields
+message Contact {
+ string name = 1;
+ string url = 2;
+ string email = 3;
+}
+
+// `License` is a representation of OpenAPI v2 specification's License object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#licenseObject
+//
+message License {
+ // Required. The license name used for the API.
+ string name = 1;
+ // A URL to the license used for the API.
+ string url = 2;
+}
+
+// `ExternalDocumentation` is a representation of OpenAPI v2 specification's
+// ExternalDocumentation object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject
+//
+// TODO(ivucica): document fields
+message ExternalDocumentation {
+ string description = 1;
+ string url = 2;
+}
+
+// `Schema` is a representation of OpenAPI v2 specification's Schema object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
+//
+// TODO(ivucica): document fields
+message Schema {
+ JSONSchema json_schema = 1;
+ string discriminator = 2;
+ bool read_only = 3;
+ // field 4 is reserved for 'xml'.
+ reserved 4;
+ ExternalDocumentation external_docs = 5;
+ google.protobuf.Any example = 6;
+}
+
+// `JSONSchema` represents properties from JSON Schema taken, and as used, in
+// the OpenAPI v2 spec.
+//
+// This includes changes made by OpenAPI v2.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
+//
+// See also: https://cswr.github.io/JsonSchema/spec/basic_types/,
+// https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json
+//
+// TODO(ivucica): document fields
+message JSONSchema {
+ // field 1 is reserved for '$id', omitted from OpenAPI v2.
+ reserved 1;
+ // field 2 is reserved for '$schema', omitted from OpenAPI v2.
+ reserved 2;
+ // Ref is used to define an external reference to include in the message.
+ // This could be a fully qualified proto message reference, and that type must be imported
+ // into the protofile. If no message is identified, the Ref will be used verbatim in
+ // the output.
+ // For example:
+ // `ref: ".google.protobuf.Timestamp"`.
+ string ref = 3;
+ // field 4 is reserved for '$comment', omitted from OpenAPI v2.
+ reserved 4;
+ string title = 5;
+ string description = 6;
+ string default = 7;
+ bool read_only = 8;
+ // field 9 is reserved for 'examples', which is omitted from OpenAPI v2 in favor of 'example' field.
+ reserved 9;
+ double multiple_of = 10;
+ double maximum = 11;
+ bool exclusive_maximum = 12;
+ double minimum = 13;
+ bool exclusive_minimum = 14;
+ uint64 max_length = 15;
+ uint64 min_length = 16;
+ string pattern = 17;
+ // field 18 is reserved for 'additionalItems', omitted from OpenAPI v2.
+ reserved 18;
+ // field 19 is reserved for 'items', but in OpenAPI-specific way. TODO(ivucica): add 'items'?
+ reserved 19;
+ uint64 max_items = 20;
+ uint64 min_items = 21;
+ bool unique_items = 22;
+ // field 23 is reserved for 'contains', omitted from OpenAPI v2.
+ reserved 23;
+ uint64 max_properties = 24;
+ uint64 min_properties = 25;
+ repeated string required = 26;
+ // field 27 is reserved for 'additionalProperties', but in OpenAPI-specific way. TODO(ivucica): add 'additionalProperties'?
+ reserved 27;
+ // field 28 is reserved for 'definitions', omitted from OpenAPI v2.
+ reserved 28;
+ // field 29 is reserved for 'properties', but in OpenAPI-specific way. TODO(ivucica): add 'additionalProperties'?
+ reserved 29;
+ // following fields are reserved, as the properties have been omitted from OpenAPI v2:
+ // patternProperties, dependencies, propertyNames, const
+ reserved 30 to 33;
+ // Items in 'array' must be unique.
+ repeated string array = 34;
+
+ enum JSONSchemaSimpleTypes {
+ UNKNOWN = 0;
+ ARRAY = 1;
+ BOOLEAN = 2;
+ INTEGER = 3;
+ NULL = 4;
+ NUMBER = 5;
+ OBJECT = 6;
+ STRING = 7;
+ }
+
+ repeated JSONSchemaSimpleTypes type = 35;
+ // following fields are reserved, as the properties have been omitted from OpenAPI v2:
+ // format, contentMediaType, contentEncoding, if, then, else
+ reserved 36 to 41;
+ // field 42 is reserved for 'allOf', but in OpenAPI-specific way. TODO(ivucica): add 'allOf'?
+ reserved 42;
+ // following fields are reserved, as the properties have been omitted from OpenAPI v2:
+ // anyOf, oneOf, not
+ reserved 43 to 45;
+}
+
+// `Tag` is a representation of OpenAPI v2 specification's Tag object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject
+//
+// TODO(ivucica): document fields
+message Tag {
+ // field 1 is reserved for 'name'. In our generator, this is (to be) extracted
+ // from the name of proto service, and thus not exposed to the user, as
+ // changing tag object's name would break the link to the references to the
+ // tag in individual operation specifications.
+ //
+ // TODO(ivucica): Add 'name' property. Use it to allow override of the name of
+ // global Tag object, then use that name to reference the tag throughout the
+ // Swagger file.
+ reserved 1;
+ // TODO(ivucica): Description should be extracted from comments on the proto
+ // service object.
+ string description = 2;
+ ExternalDocumentation external_docs = 3;
+}
+
+// `SecurityDefinitions` is a representation of OpenAPI v2 specification's
+// Security Definitions object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityDefinitionsObject
+//
+// A declaration of the security schemes available to be used in the
+// specification. This does not enforce the security schemes on the operations
+// and only serves to provide the relevant details for each scheme.
+message SecurityDefinitions {
+ // A single security scheme definition, mapping a "name" to the scheme it defines.
+ map<string, SecurityScheme> security = 1;
+}
+
+// `SecurityScheme` is a representation of OpenAPI v2 specification's
+// Security Scheme object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securitySchemeObject
+//
+// Allows the definition of a security scheme that can be used by the
+// operations. Supported schemes are basic authentication, an API key (either as
+// a header or as a query parameter) and OAuth2's common flows (implicit,
+// password, application and access code).
+message SecurityScheme {
+ // Required. The type of the security scheme. Valid values are "basic",
+ // "apiKey" or "oauth2".
+ enum Type {
+ TYPE_INVALID = 0;
+ TYPE_BASIC = 1;
+ TYPE_API_KEY = 2;
+ TYPE_OAUTH2 = 3;
+ }
+
+ // Required. The location of the API key. Valid values are "query" or "header".
+ enum In {
+ IN_INVALID = 0;
+ IN_QUERY = 1;
+ IN_HEADER = 2;
+ }
+
+ // Required. The flow used by the OAuth2 security scheme. Valid values are
+ // "implicit", "password", "application" or "accessCode".
+ enum Flow {
+ FLOW_INVALID = 0;
+ FLOW_IMPLICIT = 1;
+ FLOW_PASSWORD = 2;
+ FLOW_APPLICATION = 3;
+ FLOW_ACCESS_CODE = 4;
+ }
+
+ // Required. The type of the security scheme. Valid values are "basic",
+ // "apiKey" or "oauth2".
+ Type type = 1;
+ // A short description for security scheme.
+ string description = 2;
+ // Required. The name of the header or query parameter to be used.
+ //
+ // Valid for apiKey.
+ string name = 3;
+ // Required. The location of the API key. Valid values are "query" or "header".
+ //
+ // Valid for apiKey.
+ In in = 4;
+ // Required. The flow used by the OAuth2 security scheme. Valid values are
+ // "implicit", "password", "application" or "accessCode".
+ //
+ // Valid for oauth2.
+ Flow flow = 5;
+ // Required. The authorization URL to be used for this flow. This SHOULD be in
+ // the form of a URL.
+ //
+ // Valid for oauth2/implicit and oauth2/accessCode.
+ string authorization_url = 6;
+ // Required. The token URL to be used for this flow. This SHOULD be in the
+ // form of a URL.
+ //
+ // Valid for oauth2/password, oauth2/application and oauth2/accessCode.
+ string token_url = 7;
+ // Required. The available scopes for the OAuth2 security scheme.
+ //
+ // Valid for oauth2.
+ Scopes scopes = 8;
+ map<string, google.protobuf.Value> extensions = 9;
+}
+
+// `SecurityRequirement` is a representation of OpenAPI v2 specification's
+// Security Requirement object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityRequirementObject
+//
+// Lists the required security schemes to execute this operation. The object can
+// have multiple security schemes declared in it which are all required (that
+// is, there is a logical AND between the schemes).
+//
+// The name used for each property MUST correspond to a security scheme
+// declared in the Security Definitions.
+message SecurityRequirement {
+ // If the security scheme is of type "oauth2", then the value is a list of
+ // scope names required for the execution. For other security scheme types,
+ // the array MUST be empty.
+ message SecurityRequirementValue {
+ repeated string scope = 1;
+ }
+ // Each name must correspond to a security scheme which is declared in
+ // the Security Definitions. If the security scheme is of type "oauth2",
+ // then the value is a list of scope names required for the execution.
+ // For other security scheme types, the array MUST be empty.
+ map<string, SecurityRequirementValue> security_requirement = 1;
+}
+
+// `Scopes` is a representation of OpenAPI v2 specification's Scopes object.
+//
+// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#scopesObject
+//
+// Lists the available scopes for an OAuth2 security scheme.
+message Scopes {
+ // Maps between a name of a scope to a short description of it (as the value
+ // of the property).
+ map<string, string> scope = 1;
+}