[SEBA-660] : Adding Igmp support in BbSim
Change-Id: I9f5c7d8ad39ac82850b04e2c997996d6c47b32d2
diff --git a/vendor/github.com/google/gopacket/layers/gen.go b/vendor/github.com/google/gopacket/layers/gen.go
new file mode 100644
index 0000000..ab7a0c0
--- /dev/null
+++ b/vendor/github.com/google/gopacket/layers/gen.go
@@ -0,0 +1,109 @@
+// Copyright 2012 Google, Inc. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the LICENSE file in the root of the source
+// tree.
+
+// +build ignore
+
+// This binary pulls known ports from IANA, and uses them to populate
+// iana_ports.go's TCPPortNames and UDPPortNames maps.
+//
+// go run gen.go | gofmt > iana_ports.go
+package main
+
+import (
+ "bytes"
+ "encoding/xml"
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "os"
+ "strconv"
+ "time"
+)
+
+const fmtString = `// Copyright 2012 Google, Inc. All rights reserved.
+
+package layers
+
+// Created by gen.go, don't edit manually
+// Generated at %s
+// Fetched from %q
+
+// TCPPortNames contains the port names for all TCP ports.
+var TCPPortNames = tcpPortNames
+
+// UDPPortNames contains the port names for all UDP ports.
+var UDPPortNames = udpPortNames
+
+// SCTPPortNames contains the port names for all SCTP ports.
+var SCTPPortNames = sctpPortNames
+
+var tcpPortNames = map[TCPPort]string{
+%s}
+var udpPortNames = map[UDPPort]string{
+%s}
+var sctpPortNames = map[SCTPPort]string{
+%s}
+`
+
+var url = flag.String("url", "http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml", "URL to grab port numbers from")
+
+func main() {
+ fmt.Fprintf(os.Stderr, "Fetching ports from %q\n", *url)
+ resp, err := http.Get(*url)
+ if err != nil {
+ panic(err)
+ }
+ defer resp.Body.Close()
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ panic(err)
+ }
+ fmt.Fprintln(os.Stderr, "Parsing XML")
+ var registry struct {
+ Records []struct {
+ Protocol string `xml:"protocol"`
+ Number string `xml:"number"`
+ Name string `xml:"name"`
+ } `xml:"record"`
+ }
+ xml.Unmarshal(body, ®istry)
+ var tcpPorts bytes.Buffer
+ var udpPorts bytes.Buffer
+ var sctpPorts bytes.Buffer
+ done := map[string]map[int]bool{
+ "tcp": map[int]bool{},
+ "udp": map[int]bool{},
+ "sctp": map[int]bool{},
+ }
+ for _, r := range registry.Records {
+ port, err := strconv.Atoi(r.Number)
+ if err != nil {
+ continue
+ }
+ if r.Name == "" {
+ continue
+ }
+ var b *bytes.Buffer
+ switch r.Protocol {
+ case "tcp":
+ b = &tcpPorts
+ case "udp":
+ b = &udpPorts
+ case "sctp":
+ b = &sctpPorts
+ default:
+ continue
+ }
+ if done[r.Protocol][port] {
+ continue
+ }
+ done[r.Protocol][port] = true
+ fmt.Fprintf(b, "\t%d: %q,\n", port, r.Name)
+ }
+ fmt.Fprintln(os.Stderr, "Writing results to stdout")
+ fmt.Printf(fmtString, time.Now(), *url, tcpPorts.String(), udpPorts.String(), sctpPorts.String())
+}
diff --git a/vendor/github.com/google/gopacket/layers/gen2.go b/vendor/github.com/google/gopacket/layers/gen2.go
new file mode 100644
index 0000000..150cad7
--- /dev/null
+++ b/vendor/github.com/google/gopacket/layers/gen2.go
@@ -0,0 +1,104 @@
+// Copyright 2012 Google, Inc. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the LICENSE file in the root of the source
+// tree.
+
+// +build ignore
+
+// This binary handles creating string constants and function templates for enums.
+//
+// go run gen.go | gofmt > enums_generated.go
+package main
+
+import (
+ "fmt"
+ "log"
+ "os"
+ "text/template"
+ "time"
+)
+
+const fmtString = `// Copyright 2012 Google, Inc. All rights reserved.
+
+package layers
+
+// Created by gen2.go, don't edit manually
+// Generated at %s
+
+import (
+ "fmt"
+
+ "github.com/google/gopacket"
+)
+
+`
+
+var funcsTmpl = template.Must(template.New("foo").Parse(`
+// Decoder calls {{.Name}}Metadata.DecodeWith's decoder.
+func (a {{.Name}}) Decode(data []byte, p gopacket.PacketBuilder) error {
+ return {{.Name}}Metadata[a].DecodeWith.Decode(data, p)
+}
+// String returns {{.Name}}Metadata.Name.
+func (a {{.Name}}) String() string {
+ return {{.Name}}Metadata[a].Name
+}
+// LayerType returns {{.Name}}Metadata.LayerType.
+func (a {{.Name}}) LayerType() gopacket.LayerType {
+ return {{.Name}}Metadata[a].LayerType
+}
+
+type errorDecoderFor{{.Name}} int
+func (a *errorDecoderFor{{.Name}}) Decode(data []byte, p gopacket.PacketBuilder) error {
+ return a
+}
+func (a *errorDecoderFor{{.Name}}) Error() string {
+ return fmt.Sprintf("Unable to decode {{.Name}} %d", int(*a))
+}
+
+var errorDecodersFor{{.Name}} [{{.Num}}]errorDecoderFor{{.Name}}
+var {{.Name}}Metadata [{{.Num}}]EnumMetadata
+
+func initUnknownTypesFor{{.Name}}() {
+ for i := 0; i < {{.Num}}; i++ {
+ errorDecodersFor{{.Name}}[i] = errorDecoderFor{{.Name}}(i)
+ {{.Name}}Metadata[i] = EnumMetadata{
+ DecodeWith: &errorDecodersFor{{.Name}}[i],
+ Name: "Unknown{{.Name}}",
+ }
+ }
+}
+`))
+
+func main() {
+ fmt.Fprintf(os.Stderr, "Writing results to stdout\n")
+ fmt.Printf(fmtString, time.Now())
+ types := []struct {
+ Name string
+ Num int
+ }{
+ {"LinkType", 256},
+ {"EthernetType", 65536},
+ {"PPPType", 65536},
+ {"IPProtocol", 256},
+ {"SCTPChunkType", 256},
+ {"PPPoECode", 256},
+ {"FDDIFrameControl", 256},
+ {"EAPOLType", 256},
+ {"ProtocolFamily", 256},
+ {"Dot11Type", 256},
+ {"USBTransportType", 256},
+ }
+
+ fmt.Println("func init() {")
+ for _, t := range types {
+ fmt.Printf("initUnknownTypesFor%s()\n", t.Name)
+ }
+ fmt.Println("initActualTypeData()")
+ fmt.Println("}")
+ for _, t := range types {
+ if err := funcsTmpl.Execute(os.Stdout, t); err != nil {
+ log.Fatalf("Failed to execute template %s: %v", t.Name, err)
+ }
+ }
+}
diff --git a/vendor/github.com/google/gopacket/pcap/generate_defs.go b/vendor/github.com/google/gopacket/pcap/generate_defs.go
new file mode 100644
index 0000000..bcbf161
--- /dev/null
+++ b/vendor/github.com/google/gopacket/pcap/generate_defs.go
@@ -0,0 +1,157 @@
+// Copyright 2019 The GoPacket Authors. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the LICENSE file in the root of the source
+// tree.
+
+// +build ignore
+
+package main
+
+// This file generates the godefs needed for the windows version.
+// Rebuild is only necessary if additional libpcap functionality is implemented, or a new arch is implemented in golang.
+// Call with go run generate_windows.go [-I includepath]
+// Needs npcap sdk, go tool cgo, and gofmt to work. Location of npcap includes can be specified with -I
+
+import (
+ "bytes"
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "log"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+)
+
+const header = `// Copyright 2019 The GoPacket Authors. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the LICENSE file in the root of the source
+// tree.
+
+// This file contains necessary structs/constants generated from libpcap headers with cgo -godefs
+// generated with: %s
+// DO NOT MODIFY
+
+`
+
+const source = `
+package pcap
+
+//#include <pcap.h>
+import "C"
+
+import "syscall" // needed for RawSockaddr
+
+const errorBufferSize = C.PCAP_ERRBUF_SIZE
+
+const (
+ pcapErrorNotActivated = C.PCAP_ERROR_NOT_ACTIVATED
+ pcapErrorActivated = C.PCAP_ERROR_ACTIVATED
+ pcapWarningPromisc = C.PCAP_WARNING_PROMISC_NOTSUP
+ pcapErrorNoSuchDevice = C.PCAP_ERROR_NO_SUCH_DEVICE
+ pcapErrorDenied = C.PCAP_ERROR_PERM_DENIED
+ pcapErrorNotUp = C.PCAP_ERROR_IFACE_NOT_UP
+ pcapError = C.PCAP_ERROR
+ pcapWarning = C.PCAP_WARNING
+ pcapDIN = C.PCAP_D_IN
+ pcapDOUT = C.PCAP_D_OUT
+ pcapDINOUT = C.PCAP_D_INOUT
+ pcapNetmaskUnknown = C.PCAP_NETMASK_UNKNOWN
+ pcapTstampPrecisionMicro = C.PCAP_TSTAMP_PRECISION_MICRO
+ pcapTstampPrecisionNano = C.PCAP_TSTAMP_PRECISION_NANO
+)
+
+type timeval C.struct_timeval
+type pcapPkthdr C.struct_pcap_pkthdr
+type pcapTPtr uintptr
+type pcapBpfInstruction C.struct_bpf_insn
+type pcapBpfProgram C.struct_bpf_program
+type pcapStats C.struct_pcap_stat
+type pcapCint C.int
+type pcapIf C.struct_pcap_if
+// +godefs map struct_sockaddr syscall.RawSockaddr
+type pcapAddr C.struct_pcap_addr
+`
+
+var includes = flag.String("I", "C:\\npcap-sdk-1.01\\Include", "Include path containing libpcap headers")
+
+func main() {
+ flag.Parse()
+
+ infile, err := ioutil.TempFile(".", "defs.*.go")
+ if err != nil {
+ log.Fatal("Couldn't create temporary source file: ", err)
+ }
+ defer infile.Close()
+ defer os.Remove(infile.Name())
+
+ _, err = infile.WriteString(source)
+ if err != nil {
+ log.Fatalf("Couldn't write definitions to temporary file %s: %s", infile.Name(), err)
+ }
+ err = infile.Close()
+ if err != nil {
+ log.Fatalf("Couldn't close temporary source file %s: %s", infile.Name(), err)
+ }
+
+ archs := []string{"386", "amd64"}
+ for _, arch := range archs {
+ env := append(os.Environ(), "GOARCH="+arch)
+ cmd := exec.Command("go", "tool", "cgo", "-godefs", "--", "-I", *includes, infile.Name())
+ cmd.Env = env
+ cmd.Stderr = os.Stderr
+ var generated bytes.Buffer
+ cmd.Stdout = &generated
+ err := cmd.Run()
+ if err != nil {
+ log.Fatalf("Couldn't generated defs for %s: %s\n", arch, err)
+ }
+
+ cmd = exec.Command("gofmt")
+ cmd.Env = env
+ cmd.Stderr = os.Stderr
+ outName := fmt.Sprintf("defs_windows_%s.go", arch)
+ out, err := os.Create(outName)
+ if err != nil {
+ log.Fatalf("Couldn't open file %s: %s", outName, err)
+ }
+ cmd.Stdout = out
+ in, err := cmd.StdinPipe()
+ if err != nil {
+ log.Fatal("Couldn't create input pipe for gofmt: ", err)
+ }
+ err = cmd.Start()
+ if err != nil {
+ log.Fatal("Couldn't start gofmt: ", err)
+ }
+
+ _, err = fmt.Fprintf(in, header, strings.Join(append([]string{filepath.Base(os.Args[0])}, os.Args[1:]...), " "))
+ if err != nil {
+ log.Fatal("Couldn't write header to gofmt: ", err)
+ }
+
+ for {
+ line, err := generated.ReadBytes('\n')
+ if err != nil {
+ break
+ }
+ // remove godefs comments
+ if bytes.HasPrefix(line, []byte("//")) {
+ continue
+ }
+ _, err = in.Write(line)
+ if err != nil {
+ log.Fatal("Couldn't write line to gofmt: ", err)
+ }
+ }
+ in.Close()
+ err = cmd.Wait()
+ if err != nil {
+ log.Fatal("gofmt failed: ", err)
+ }
+ out.Close()
+ }
+}
diff --git a/vendor/github.com/google/gopacket/pcap/pcap_tester.go b/vendor/github.com/google/gopacket/pcap/pcap_tester.go
new file mode 100644
index 0000000..7873a96
--- /dev/null
+++ b/vendor/github.com/google/gopacket/pcap/pcap_tester.go
@@ -0,0 +1,108 @@
+// Copyright 2012 Google, Inc. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style license
+// that can be found in the LICENSE file in the root of the source
+// tree.
+
+// +build ignore
+
+// This binary tests that PCAP packet capture is working correctly by issuing
+// HTTP requests, then making sure we actually capture data off the wire.
+package main
+
+import (
+ "errors"
+ "flag"
+ "fmt"
+ "log"
+ "net/http"
+ "os"
+ "time"
+
+ "github.com/google/gopacket/pcap"
+)
+
+var mode = flag.String("mode", "basic", "One of: basic,filtered,timestamp")
+
+func generatePackets() {
+ if resp, err := http.Get("http://code.google.com"); err != nil {
+ log.Printf("Could not get HTTP: %v", err)
+ } else {
+ resp.Body.Close()
+ }
+}
+
+func main() {
+ flag.Parse()
+ ifaces, err := pcap.FindAllDevs()
+ if err != nil {
+ log.Fatal(err)
+ }
+ for _, iface := range ifaces {
+ log.Printf("Trying capture on %q", iface.Name)
+ if err := tryCapture(iface); err != nil {
+ log.Printf("Error capturing on %q: %v", iface.Name, err)
+ } else {
+ log.Printf("Successfully captured on %q", iface.Name)
+ return
+ }
+ }
+ os.Exit(1)
+}
+
+func tryCapture(iface pcap.Interface) error {
+ if iface.Name[:2] == "lo" {
+ return errors.New("skipping loopback")
+ }
+ var h *pcap.Handle
+ var err error
+ switch *mode {
+ case "basic":
+ h, err = pcap.OpenLive(iface.Name, 65536, false, time.Second*3)
+ if err != nil {
+ return fmt.Errorf("openlive: %v", err)
+ }
+ defer h.Close()
+ case "filtered":
+ h, err = pcap.OpenLive(iface.Name, 65536, false, time.Second*3)
+ if err != nil {
+ return fmt.Errorf("openlive: %v", err)
+ }
+ defer h.Close()
+ if err := h.SetBPFFilter("port 80 or port 443"); err != nil {
+ return fmt.Errorf("setbpf: %v", err)
+ }
+ case "timestamp":
+ u, err := pcap.NewInactiveHandle(iface.Name)
+ if err != nil {
+ return err
+ }
+ defer u.CleanUp()
+ if err = u.SetSnapLen(65536); err != nil {
+ return err
+ } else if err = u.SetPromisc(false); err != nil {
+ return err
+ } else if err = u.SetTimeout(time.Second * 3); err != nil {
+ return err
+ }
+ sources := u.SupportedTimestamps()
+ if len(sources) == 0 {
+ return errors.New("no supported timestamp sources")
+ } else if err := u.SetTimestampSource(sources[0]); err != nil {
+ return fmt.Errorf("settimestampsource(%v): %v", sources[0], err)
+ } else if h, err = u.Activate(); err != nil {
+ return fmt.Errorf("could not activate: %v", err)
+ }
+ defer h.Close()
+ default:
+ panic("Invalid --mode: " + *mode)
+ }
+ go generatePackets()
+ h.ReadPacketData() // Do one dummy read to clear any timeouts.
+ data, ci, err := h.ReadPacketData()
+ if err != nil {
+ return fmt.Errorf("readpacketdata: %v", err)
+ }
+ log.Printf("Read packet, %v bytes, CI: %+v", len(data), ci)
+ return nil
+}
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/internal/BUILD.bazel b/vendor/github.com/grpc-ecosystem/grpc-gateway/internal/BUILD.bazel
index 76cafe6..5f73042 100644
--- a/vendor/github.com/grpc-ecosystem/grpc-gateway/internal/BUILD.bazel
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/internal/BUILD.bazel
@@ -1,3 +1,4 @@
+load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/internal/stream_chunk.pb.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/internal/stream_chunk.pb.go
index 8858f06..1eca68e 100644
--- a/vendor/github.com/grpc-ecosystem/grpc-gateway/internal/stream_chunk.pb.go
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/internal/stream_chunk.pb.go
@@ -3,10 +3,12 @@
package internal
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import any "github.com/golang/protobuf/ptypes/any"
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ any "github.com/golang/protobuf/ptypes/any"
+ math "math"
+)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
@@ -17,7 +19,7 @@
// 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
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// StreamError is a response type which is returned when
// streaming rpc returns an error.
@@ -36,16 +38,17 @@
func (m *StreamError) String() string { return proto.CompactTextString(m) }
func (*StreamError) ProtoMessage() {}
func (*StreamError) Descriptor() ([]byte, []int) {
- return fileDescriptor_stream_chunk_a2afb657504565d7, []int{0}
+ return fileDescriptor_9d15b670e96bbb5a, []int{0}
}
+
func (m *StreamError) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StreamError.Unmarshal(m, b)
}
func (m *StreamError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_StreamError.Marshal(b, m, deterministic)
}
-func (dst *StreamError) XXX_Merge(src proto.Message) {
- xxx_messageInfo_StreamError.Merge(dst, src)
+func (m *StreamError) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_StreamError.Merge(m, src)
}
func (m *StreamError) XXX_Size() int {
return xxx_messageInfo_StreamError.Size(m)
@@ -95,11 +98,9 @@
proto.RegisterType((*StreamError)(nil), "grpc.gateway.runtime.StreamError")
}
-func init() {
- proto.RegisterFile("internal/stream_chunk.proto", fileDescriptor_stream_chunk_a2afb657504565d7)
-}
+func init() { proto.RegisterFile("internal/stream_chunk.proto", fileDescriptor_9d15b670e96bbb5a) }
-var fileDescriptor_stream_chunk_a2afb657504565d7 = []byte{
+var fileDescriptor_9d15b670e96bbb5a = []byte{
// 223 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x34, 0x90, 0x41, 0x4e, 0xc3, 0x30,
0x10, 0x45, 0x15, 0x4a, 0x69, 0x3b, 0xd9, 0x45, 0x5d, 0x18, 0xba, 0x20, 0x62, 0x95, 0x95, 0x23,
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor/registry.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor/registry.go
index 2f05636..b73c123 100644
--- a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor/registry.go
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor/registry.go
@@ -71,6 +71,10 @@
// allowColonFinalSegments determines whether colons are permitted
// in the final segment of a path.
allowColonFinalSegments bool
+
+ // useGoTemplate determines whether you want to use GO templates
+ // in your protofile comments
+ useGoTemplate bool
}
type repeatedFieldSeparator struct {
@@ -446,6 +450,16 @@
return r.mergeFileName
}
+// SetUseGoTemplate sets useGoTemplate
+func (r *Registry) SetUseGoTemplate(use bool) {
+ r.useGoTemplate = use
+}
+
+// GetUseGoTemplate returns useGoTemplate
+func (r *Registry) GetUseGoTemplate() bool {
+ return r.useGoTemplate
+}
+
// sanitizePackageName replaces unallowed character in package name
// with allowed character.
func sanitizePackageName(pkgName string) string {
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
index 4f90807..2cb1f22 100644
--- 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
@@ -4,128 +4,165 @@
Optionally applies settings from the grpc-service configuration.
"""
-def _collect_includes(gen_dir, srcs):
- """Build an include path mapping.
+load("@rules_proto//proto:defs.bzl", "ProtoInfo")
- It is important to not just collect unique dirnames, to also support
- proto files of the same name from different packages.
+# TODO(yannic): Replace with |proto_common.direct_source_infos| when
+# https://github.com/bazelbuild/rules_proto/pull/22 lands.
+def _direct_source_infos(proto_info, provided_sources = []):
+ """Returns sequence of `ProtoFileInfo` for `proto_info`'s direct sources.
- The implementation below is similar to what bazel does in its
- ProtoCompileActionBuilder.java
+ Files that are both in `proto_info`'s direct sources and in
+ `provided_sources` are skipped. This is useful, e.g., for well-known
+ protos that are already provided by the Protobuf runtime.
+
+ Args:
+ proto_info: An instance of `ProtoInfo`.
+ provided_sources: Optional. A sequence of files to ignore.
+ Usually, these files are already provided by the
+ Protocol Buffer runtime (e.g. Well-Known protos).
+
+ Returns: A sequence of `ProtoFileInfo` containing information about
+ `proto_info`'s direct sources.
"""
- includes = []
- for src in srcs:
- ref_path = src.path
- if ref_path.startswith(gen_dir):
- ref_path = ref_path[len(gen_dir):].lstrip("/")
+ source_root = proto_info.proto_source_root
+ if "." == source_root:
+ return [struct(file = src, import_path = src.path) for src in proto_info.direct_sources]
- if src.owner.workspace_root:
- workspace_root = src.owner.workspace_root
- ref_path = ref_path[len(workspace_root):].lstrip("/")
+ offset = len(source_root) + 1 # + '/'.
- include = ref_path + "=" + src.path
- if include not in includes:
- includes.append(include)
+ infos = []
+ for src in proto_info.direct_sources:
+ # TODO(yannic): Remove this hack when we drop support for Bazel < 1.0.
+ local_offset = offset
+ if src.root.path and not source_root.startswith(src.root.path):
+ # Before Bazel 1.0, `proto_source_root` wasn't guaranteed to be a
+ # prefix of `src.path`. This could happend, e.g., if `file` was
+ # generated (https://github.com/bazelbuild/bazel/issues/9215).
+ local_offset += len(src.root.path) + 1 # + '/'.
+ infos.append(struct(file = src, import_path = src.path[local_offset:]))
- return includes
+ return infos
-def _run_proto_gen_swagger(ctx, direct_proto_srcs, transitive_proto_srcs, actions, protoc, protoc_gen_swagger, grpc_api_configuration, single_output):
- swagger_files = []
+def _run_proto_gen_swagger(
+ actions,
+ proto_info,
+ target_name,
+ transitive_proto_srcs,
+ protoc,
+ protoc_gen_swagger,
+ grpc_api_configuration,
+ single_output,
+ json_names_for_fields):
+ args = actions.args()
- inputs = direct_proto_srcs + transitive_proto_srcs
- tools = [protoc_gen_swagger]
+ args.add("--plugin", "protoc-gen-swagger=%s" % protoc_gen_swagger.path)
- options = ["logtostderr=true", "allow_repeated_fields_in_body=true"]
+ args.add("--swagger_opt", "logtostderr=true")
+ args.add("--swagger_opt", "allow_repeated_fields_in_body=true")
+
+ extra_inputs = []
if grpc_api_configuration:
- options.append("grpc_api_configuration=%s" % grpc_api_configuration.path)
- inputs.append(grpc_api_configuration)
+ extra_inputs.append(grpc_api_configuration)
+ args.add("--swagger_opt", "grpc_api_configuration=%s" % grpc_api_configuration.path)
- includes = _collect_includes(ctx.genfiles_dir.path, direct_proto_srcs + transitive_proto_srcs)
+ if json_names_for_fields:
+ args.add("--swagger_opt", "json_names_for_fields=true")
+
+ proto_file_infos = _direct_source_infos(proto_info)
+
+ # TODO(yannic): Use |proto_info.transitive_descriptor_sets| when
+ # https://github.com/bazelbuild/bazel/issues/9337 is fixed.
+ args.add_all(proto_info.transitive_proto_path, format_each = "--proto_path=%s")
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])
+ args.add("--swagger_opt", "allow_merge=true")
+ args.add("--swagger_opt", "merge_file_name=%s" % target_name)
- output_dir = "/".join([output_dir, direct_proto_srcs[0].dirname])
+ swagger_file = actions.declare_file("%s.swagger.json" % target_name)
+ args.add("--swagger_out", swagger_file.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])
+ args.add_all([f.import_path for f in proto_file_infos])
actions.run(
executable = protoc,
- inputs = inputs,
- tools = tools,
+ tools = [protoc_gen_swagger],
+ inputs = depset(
+ direct = extra_inputs,
+ transitive = [transitive_proto_srcs],
+ ),
outputs = [swagger_file],
arguments = [args],
)
+ return [swagger_file]
+
+ # TODO(yannic): We may be able to generate all files in a single action,
+ # but that will change at least the semantics of `use_go_template.proto`.
+ swagger_files = []
+ for proto_file_info in proto_file_infos:
+ # TODO(yannic): This probably doesn't work as expected: we only add this
+ # option after we have seen it, so `.proto` sources that happen to be
+ # in the list of `.proto` files before `use_go_template.proto` will be
+ # compiled without this option, and all sources that get compiled after
+ # `use_go_template.proto` will have this option on.
+ if proto_file_info.file.basename == "use_go_template.proto":
+ args.add("--swagger_opt", "use_go_templates=true")
+
+ file_name = "%s.swagger.json" % proto_file_info.import_path[:-len(".proto")]
+ swagger_file = actions.declare_file(
+ "_virtual_imports/%s/%s" % (target_name, file_name),
+ )
+
+ file_args = actions.args()
+
+ offset = len(file_name) + 1 # + '/'.
+ file_args.add("--swagger_out", swagger_file.path[:-offset])
+
+ file_args.add(proto_file_info.import_path)
+
+ actions.run(
+ executable = protoc,
+ tools = [protoc_gen_swagger],
+ inputs = depset(
+ direct = extra_inputs,
+ transitive = [transitive_proto_srcs],
+ ),
+ outputs = [swagger_file],
+ arguments = [args, file_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,
+ return [
+ DefaultInfo(
+ files = depset(
+ _run_proto_gen_swagger(
+ actions = ctx.actions,
+ proto_info = proto,
+ target_name = ctx.attr.name,
+ transitive_proto_srcs = depset(
+ direct = ctx.files._well_known_protos,
+ transitive = [proto.transitive_sources],
+ ),
+ protoc = ctx.executable._protoc,
+ protoc_gen_swagger = ctx.executable._protoc_gen_swagger,
+ grpc_api_configuration = ctx.file.grpc_api_configuration,
+ single_output = ctx.attr.single_output,
+ json_names_for_fields = ctx.attr.json_names_for_fields,
+ ),
),
),
- )]
+ ]
protoc_gen_swagger = rule(
attrs = {
"proto": attr.label(
- allow_rules = ["proto_library"],
mandatory = True,
- providers = ["proto"],
+ providers = [ProtoInfo],
),
"grpc_api_configuration": attr.label(
allow_single_file = True,
@@ -135,6 +172,10 @@
default = False,
mandatory = False,
),
+ "json_names_for_fields": attr.bool(
+ default = False,
+ mandatory = False,
+ ),
"_protoc": attr.label(
default = "@com_google_protobuf//:protoc",
executable = True,
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
index 929d0cf..c89eb04 100644
--- 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
@@ -7,6 +7,8 @@
srcs = [
"doc.go",
"generator.go",
+ "helpers.go",
+ "helpers_go111_old.go",
"template.go",
"types.go",
],
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
index 31409ac..ecf1135 100644
--- 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
@@ -52,9 +52,6 @@
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
}
@@ -67,10 +64,6 @@
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).
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/helpers.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/helpers.go
new file mode 100644
index 0000000..3615596
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/helpers.go
@@ -0,0 +1,9 @@
+//+build go1.12
+
+package genswagger
+
+import "strings"
+
+func fieldName(k string) string {
+ return strings.ReplaceAll(strings.Title(k), "-", "_")
+}
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/helpers_go111_old.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/helpers_go111_old.go
new file mode 100644
index 0000000..8e9458d
--- /dev/null
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/helpers_go111_old.go
@@ -0,0 +1,9 @@
+//+build !go1.12
+
+package genswagger
+
+import "strings"
+
+func fieldName(k string) string {
+ return strings.Replace(strings.Title(k), "-", "_", -1)
+}
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
index 3d97207..1b9e14d 100644
--- 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
@@ -1,8 +1,10 @@
package genswagger
import (
+ "bytes"
"encoding/json"
"fmt"
+ "io/ioutil"
"os"
"reflect"
"regexp"
@@ -10,13 +12,14 @@
"strconv"
"strings"
"sync"
+ "text/template"
"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"
+ structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor"
swagger_options "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"
)
@@ -122,7 +125,7 @@
fieldType := field.GetTypeName()
if message.File != nil {
comments := fieldProtoComments(reg, message, field)
- if err := updateSwaggerDataFromComments(&schema, comments, false); err != nil {
+ if err := updateSwaggerDataFromComments(reg, &schema, message, comments, false); err != nil {
return nil, err
}
}
@@ -285,7 +288,7 @@
},
}
msgComments := protoComments(reg, msg.File, msg.Outers, "MessageType", int32(msg.Index))
- if err := updateSwaggerDataFromComments(&schema, msgComments, false); err != nil {
+ if err := updateSwaggerDataFromComments(reg, &schema, msg, msgComments, false); err != nil {
panic(err)
}
opts, err := extractSchemaOptionFromMessageDescriptor(msg.DescriptorProto)
@@ -293,7 +296,7 @@
panic(err)
}
if opts != nil {
- protoSchema := swaggerSchemaFromProtoSchema(opts, reg, customRefs)
+ protoSchema := swaggerSchemaFromProtoSchema(opts, reg, customRefs, msg)
// Warning: Make sure not to overwrite any fields already set on the schema type.
schema.ExternalDocs = protoSchema.ExternalDocs
@@ -330,7 +333,7 @@
for _, f := range msg.Fields {
fieldValue := schemaOfField(f, reg, customRefs)
comments := fieldProtoComments(reg, msg, f)
- if err := updateSwaggerDataFromComments(&fieldValue, comments, false); err != nil {
+ if err := updateSwaggerDataFromComments(reg, &fieldValue, f, comments, false); err != nil {
panic(err)
}
@@ -349,42 +352,6 @@
}
}
-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 (
@@ -461,7 +428,7 @@
}
if j, err := extractJSONSchemaFromFieldDescriptor(fd); err == nil {
- updateSwaggerObjectFromJSONSchema(&ret, j)
+ updateSwaggerObjectFromJSONSchema(&ret, j, reg, f)
}
return ret
@@ -535,7 +502,7 @@
Default: defaultValue,
},
}
- if err := updateSwaggerDataFromComments(&enumSchemaObject, enumComments, false); err != nil {
+ if err := updateSwaggerDataFromComments(reg, &enumSchemaObject, enum, enumComments, false); err != nil {
panic(err)
}
@@ -618,7 +585,7 @@
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 {
+func templateToSwaggerPath(path string, reg *descriptor.Registry, fields []*descriptor.Field) 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.
@@ -647,7 +614,7 @@
if reg.GetUseJSONNamesForFields() &&
len(jsonBuffer) > 1 {
jsonSnakeCaseName := string(jsonBuffer[1:])
- jsonCamelCaseName := string(lowerCamelCase(jsonSnakeCaseName))
+ jsonCamelCaseName := string(lowerCamelCase(jsonSnakeCaseName, fields))
prev := string(buffer[:len(buffer)-len(jsonSnakeCaseName)-2])
buffer = strings.Join([]string{prev, "{", jsonCamelCaseName, "}"}, "")
jsonBuffer = ""
@@ -766,7 +733,7 @@
}
parameterString := parameter.String()
if reg.GetUseJSONNamesForFields() {
- parameterString = lowerCamelCase(parameterString)
+ parameterString = lowerCamelCase(parameterString, meth.RequestType.Fields)
}
parameters = append(parameters, swaggerParameterObject{
Name: parameterString,
@@ -833,7 +800,7 @@
parameters = append(parameters, queryParams...)
}
- pathItemObject, ok := paths[templateToSwaggerPath(b.PathTmpl.Template, reg)]
+ pathItemObject, ok := paths[templateToSwaggerPath(b.PathTmpl.Template, reg, meth.RequestType.Fields)]
if !ok {
pathItemObject = swaggerPathItemObject{}
}
@@ -874,8 +841,26 @@
}
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)
+ responseSchema.Type = "object"
+ responseSchema.Title = fmt.Sprintf("Stream result of %s", fullyQualifiedNameToSwaggerName(meth.ResponseType.FQMN(), reg))
+ responseSchema.Properties = &swaggerSchemaObjectProperties{
+ keyVal{
+ Key: "result",
+ Value: swaggerSchemaObject{
+ schemaCore: schemaCore{
+ Ref: responseSchema.Ref,
+ },
+ },
+ },
+ keyVal{
+ Key: "error",
+ Value: swaggerSchemaObject{
+ schemaCore: schemaCore{
+ Ref: fmt.Sprintf("#/definitions/%s", fullyQualifiedNameToSwaggerName(".grpc.gateway.runtime.StreamError", reg))},
+ },
+ },
+ }
+ responseSchema.Ref = ""
}
tag := svc.GetName()
@@ -907,8 +892,8 @@
}
}
- methComments := protoComments(reg, svc.File, nil, "Method", int32(svcIdx), methProtoPath, int32(methIdx))
- if err := updateSwaggerDataFromComments(operationObject, methComments, false); err != nil {
+ methComments := protoComments(reg, svc.File, nil, "Service", int32(svcIdx), methProtoPath, int32(methIdx))
+ if err := updateSwaggerDataFromComments(reg, operationObject, meth, methComments, false); err != nil {
panic(err)
}
@@ -917,7 +902,7 @@
if err != nil {
panic(err)
}
- operationObject.ExternalDocs = protoExternalDocumentationToSwaggerExternalDocumentation(opts.ExternalDocs)
+ operationObject.ExternalDocs = protoExternalDocumentationToSwaggerExternalDocumentation(opts.ExternalDocs, reg, meth)
// TODO(ivucica): this would be better supported by looking whether the method is deprecated in the proto file
operationObject.Deprecated = opts.Deprecated
@@ -931,6 +916,9 @@
operationObject.Tags = make([]string, len(opts.Tags))
copy(operationObject.Tags, opts.Tags)
}
+ if opts.OperationId != "" {
+ operationObject.OperationID = opts.OperationId
+ }
if opts.Security != nil {
newSecurity := []swaggerSecurityRequirementObject{}
if operationObject.Security != nil {
@@ -958,7 +946,7 @@
for name, resp := range opts.Responses {
respObj := swaggerResponseObject{
Description: resp.Description,
- Schema: swaggerSchemaFromProtoSchema(resp.Schema, reg, customRefs),
+ Schema: swaggerSchemaFromProtoSchema(resp.Schema, reg, customRefs, meth),
}
if resp.Extensions != nil {
exts, err := processExtensions(resp.Extensions)
@@ -999,7 +987,7 @@
pathItemObject.Patch = operationObject
break
}
- paths[templateToSwaggerPath(b.PathTmpl.Template, reg)] = pathItemObject
+ paths[templateToSwaggerPath(b.PathTmpl.Template, reg, meth.RequestType.Fields)] = pathItemObject
}
}
}
@@ -1014,13 +1002,11 @@
// 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),
+ Swagger: "2.0",
+ Consumes: []string{"application/json"},
+ Produces: []string{"application/json"},
+ Paths: make(swaggerPathsObject),
+ Definitions: make(swaggerDefinitionsObject),
Info: swaggerInfoObject{
Title: *p.File.Name,
Version: "version not set",
@@ -1042,13 +1028,12 @@
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 {
+ if err := updateSwaggerDataFromComments(p.reg, &s, p, packageComments, true); err != nil {
panic(err)
}
@@ -1216,7 +1201,7 @@
}
s.Security = newSecurity
}
- s.ExternalDocs = protoExternalDocumentationToSwaggerExternalDocumentation(spb.ExternalDocs)
+ s.ExternalDocs = protoExternalDocumentationToSwaggerExternalDocumentation(spb.ExternalDocs, p.reg, spb)
// Populate all Paths with Responses set at top level,
// preferring Responses already set over those at the top level.
if spb.Responses != nil {
@@ -1246,7 +1231,7 @@
}
respMap[k] = swaggerResponseObject{
Description: v.Description,
- Schema: swaggerSchemaFromProtoSchema(v.Schema, p.reg, customRefs),
+ Schema: swaggerSchemaFromProtoSchema(v.Schema, p.reg, customRefs, nil),
}
}
}
@@ -1300,11 +1285,16 @@
//
// 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 {
+func updateSwaggerDataFromComments(reg *descriptor.Registry, swaggerObject interface{}, data interface{}, comment string, isPackageObject bool) error {
if len(comment) == 0 {
return nil
}
+ // Checks whether the "use_go_templates" flag is set to true
+ if reg.GetUseGoTemplate() {
+ comment = goTemplateComments(comment, data, reg)
+ }
+
// Figure out what to apply changes to.
swaggerObjectValue := reflect.ValueOf(swaggerObject)
infoObjectValue := swaggerObjectValue.Elem().FieldByName("Info")
@@ -1435,6 +1425,37 @@
return ""
}
+func goTemplateComments(comment string, data interface{}, reg *descriptor.Registry) string {
+ var temp bytes.Buffer
+ tpl, err := template.New("").Funcs(template.FuncMap{
+ // Allows importing documentation from a file
+ "import": func(name string) string {
+ file, err := ioutil.ReadFile(name)
+ if err != nil {
+ return err.Error()
+ }
+ // Runs template over imported file
+ return goTemplateComments(string(file), data, reg)
+ },
+ // Grabs title and description from a field
+ "fieldcomments": func(msg *descriptor.Message, field *descriptor.Field) string {
+ return strings.Replace(fieldProtoComments(reg, msg, field), "\n", "<br>", -1)
+ },
+ }).Parse(comment)
+ if err != nil {
+ // If there is an error parsing the templating insert the error as string in the comment
+ // to make it easier to debug the template error
+ return err.Error()
+ }
+ err = tpl.Execute(&temp, data)
+ if err != nil {
+ // If there is an error executing the templating insert the error as string in the comment
+ // to make it easier to debug the error
+ return err.Error()
+ }
+ return temp.String()
+}
+
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")
@@ -1638,9 +1659,14 @@
return ret
}
-func updateSwaggerObjectFromJSONSchema(s *swaggerSchemaObject, j *swagger_options.JSONSchema) {
+func updateSwaggerObjectFromJSONSchema(s *swaggerSchemaObject, j *swagger_options.JSONSchema, reg *descriptor.Registry, data interface{}) {
s.Title = j.GetTitle()
s.Description = j.GetDescription()
+ if reg.GetUseGoTemplate() {
+ s.Title = goTemplateComments(s.Title, data, reg)
+ s.Description = goTemplateComments(s.Description, data, reg)
+ }
+
s.ReadOnly = j.GetReadOnly()
s.MultipleOf = j.GetMultipleOf()
s.Maximum = j.GetMaximum()
@@ -1662,13 +1688,13 @@
}
}
-func swaggerSchemaFromProtoSchema(s *swagger_options.Schema, reg *descriptor.Registry, refs refMap) swaggerSchemaObject {
+func swaggerSchemaFromProtoSchema(s *swagger_options.Schema, reg *descriptor.Registry, refs refMap, data interface{}) swaggerSchemaObject {
ret := swaggerSchemaObject{
- ExternalDocs: protoExternalDocumentationToSwaggerExternalDocumentation(s.GetExternalDocs()),
+ ExternalDocs: protoExternalDocumentationToSwaggerExternalDocumentation(s.GetExternalDocs(), reg, data),
}
ret.schemaCore = protoJSONSchemaToSwaggerSchemaCore(s.GetJsonSchema(), reg, refs)
- updateSwaggerObjectFromJSONSchema(&ret, s.GetJsonSchema())
+ updateSwaggerObjectFromJSONSchema(&ret, s.GetJsonSchema(), reg, data)
if s != nil && s.Example != nil {
ret.Example = json.RawMessage(s.Example.Value)
@@ -1712,11 +1738,15 @@
}
}
-func protoExternalDocumentationToSwaggerExternalDocumentation(in *swagger_options.ExternalDocumentation) *swaggerExternalDocumentationObject {
+func protoExternalDocumentationToSwaggerExternalDocumentation(in *swagger_options.ExternalDocumentation, reg *descriptor.Registry, data interface{}) *swaggerExternalDocumentationObject {
if in == nil {
return nil
}
+ if reg.GetUseGoTemplate() {
+ in.Description = goTemplateComments(in.Description, data, reg)
+ }
+
return &swaggerExternalDocumentationObject{
Description: in.Description,
URL: in.Url,
@@ -1755,8 +1785,13 @@
addCustomRefs(d, reg, refs)
}
-func lowerCamelCase(parameter string) string {
- parameterString := gogen.CamelCase(parameter)
+func lowerCamelCase(fieldName string, fields []*descriptor.Field) string {
+ for _, oneField := range fields {
+ if oneField.GetName() == fieldName {
+ return oneField.GetJsonName()
+ }
+ }
+ parameterString := gogen.CamelCase(fieldName)
builder := &strings.Builder{}
builder.WriteString(strings.ToLower(string(parameterString[0])))
builder.WriteString(parameterString[1:])
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
index 77db96d..5765706 100644
--- 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
@@ -59,12 +59,11 @@
Info swaggerInfoObject `json:"info"`
Host string `json:"host,omitempty"`
BasePath string `json:"basePath,omitempty"`
- Schemes []string `json:"schemes"`
+ Schemes []string `json:"schemes,omitempty"`
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"`
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
index 237e460..9befc25 100644
--- 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
@@ -27,6 +27,7 @@
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")
+ useGoTemplate = flag.Bool("use_go_templates", false, "if set, you can use Go templates in protofile comments")
)
// Variables set by goreleaser at build time
@@ -78,6 +79,7 @@
reg.SetAllowRepeatedFieldsInBody(*allowRepeatedFieldsInBody)
reg.SetIncludePackageInTags(*includePackageInTags)
reg.SetUseFQNForSwaggerName(*useFQNForSwaggerName)
+ reg.SetUseGoTemplate(*useGoTemplate)
if err := reg.SetRepeatedPathParamSeparator(*repeatedPathParamSeparator); err != nil {
emitError(err)
return
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
index 8dea43d..464a56d 100644
--- 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
@@ -1,3 +1,4 @@
+load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
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
index 9fc282b..6514002 100644
--- 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
@@ -1,12 +1,14 @@
// 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"
+package options
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
+ math "math"
+)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
@@ -17,14 +19,14 @@
// 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
+const _ = proto.ProtoPackageIsVersion3 // 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",
+ Tag: "bytes,1042,opt,name=openapiv2_swagger",
Filename: "protoc-gen-swagger/options/annotations.proto",
}
@@ -33,7 +35,7 @@
ExtensionType: (*Operation)(nil),
Field: 1042,
Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_operation",
- Tag: "bytes,1042,opt,name=openapiv2_operation,json=openapiv2Operation",
+ Tag: "bytes,1042,opt,name=openapiv2_operation",
Filename: "protoc-gen-swagger/options/annotations.proto",
}
@@ -42,7 +44,7 @@
ExtensionType: (*Schema)(nil),
Field: 1042,
Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_schema",
- Tag: "bytes,1042,opt,name=openapiv2_schema,json=openapiv2Schema",
+ Tag: "bytes,1042,opt,name=openapiv2_schema",
Filename: "protoc-gen-swagger/options/annotations.proto",
}
@@ -51,7 +53,7 @@
ExtensionType: (*Tag)(nil),
Field: 1042,
Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_tag",
- Tag: "bytes,1042,opt,name=openapiv2_tag,json=openapiv2Tag",
+ Tag: "bytes,1042,opt,name=openapiv2_tag",
Filename: "protoc-gen-swagger/options/annotations.proto",
}
@@ -60,7 +62,7 @@
ExtensionType: (*JSONSchema)(nil),
Field: 1042,
Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_field",
- Tag: "bytes,1042,opt,name=openapiv2_field,json=openapiv2Field",
+ Tag: "bytes,1042,opt,name=openapiv2_field",
Filename: "protoc-gen-swagger/options/annotations.proto",
}
@@ -73,31 +75,31 @@
}
func init() {
- proto.RegisterFile("protoc-gen-swagger/options/annotations.proto", fileDescriptor_annotations_8378bd63c2853a5a)
+ proto.RegisterFile("protoc-gen-swagger/options/annotations.proto", fileDescriptor_a6a34ca6badab664)
}
-var fileDescriptor_annotations_8378bd63c2853a5a = []byte{
+var fileDescriptor_a6a34ca6badab664 = []byte{
// 346 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x4f, 0x4f, 0xea, 0x40,
0x14, 0xc5, 0xc3, 0xe6, 0xe5, 0xa5, 0xef, 0xa9, 0x58, 0x37, 0x86, 0xf8, 0x87, 0x9d, 0xc6, 0xc0,
0x8c, 0x81, 0x5d, 0x77, 0x6a, 0xe2, 0xc2, 0x44, 0x49, 0x0a, 0x2b, 0x37, 0x64, 0x18, 0x2e, 0x97,
0x49, 0x4a, 0xef, 0x64, 0x66, 0x80, 0x90, 0xb0, 0xf4, 0x13, 0xf8, 0x89, 0x8d, 0xd3, 0xd2, 0x9a,
- 0x8a, 0xa6, 0xbb, 0xde, 0xdb, 0x39, 0xe7, 0x77, 0x7a, 0x3a, 0x41, 0x47, 0x1b, 0x72, 0x24, 0xbb,
+ 0x8a, 0xa6, 0xbb, 0xce, 0xe9, 0xbd, 0xe7, 0x77, 0x7a, 0x3a, 0x41, 0x47, 0x1b, 0x72, 0x24, 0xbb,
0x08, 0x69, 0xd7, 0xae, 0x05, 0x22, 0x18, 0x4e, 0xda, 0x29, 0x4a, 0x2d, 0x17, 0x69, 0x4a, 0x4e,
- 0xf8, 0x67, 0xe6, 0x8f, 0x85, 0x57, 0x68, 0xb4, 0x64, 0x28, 0x1c, 0xac, 0xc5, 0x26, 0xdb, 0xc9,
- 0x31, 0x42, 0x3a, 0xce, 0xa5, 0x2c, 0x97, 0xb6, 0x6e, 0x7e, 0xb1, 0x25, 0x0d, 0xa9, 0xd0, 0x6a,
- 0xd5, 0xcb, 0x0c, 0x5a, 0x6d, 0x24, 0xc2, 0x04, 0xb8, 0x9f, 0x26, 0xcb, 0x19, 0x9f, 0x82, 0x95,
- 0x46, 0x69, 0x47, 0x26, 0x3b, 0x11, 0x6d, 0x83, 0xe3, 0x42, 0xb4, 0x43, 0x85, 0x67, 0x2c, 0xd3,
- 0xb1, 0x9d, 0x8e, 0x3d, 0xaa, 0x04, 0x06, 0x19, 0xe4, 0xf4, 0xfd, 0x6f, 0xbb, 0x71, 0xfd, 0xaf,
- 0x77, 0xcb, 0x6a, 0x26, 0x66, 0xc3, 0x6c, 0x8e, 0x9b, 0x05, 0x29, 0xdf, 0x44, 0x6f, 0x8d, 0xe0,
+ 0xf8, 0x67, 0xe6, 0xc7, 0xc2, 0x2b, 0x34, 0x5a, 0x32, 0x14, 0x0e, 0xd6, 0x62, 0x93, 0x69, 0x72,
+ 0x8c, 0x90, 0x8e, 0xf3, 0x55, 0x96, 0xaf, 0xb6, 0xda, 0x48, 0x84, 0x09, 0x70, 0x3f, 0x32, 0x59,
+ 0xce, 0xf8, 0x14, 0xac, 0x34, 0x4a, 0x3b, 0x32, 0xd9, 0x5a, 0xeb, 0xe6, 0x17, 0x30, 0x69, 0x48,
+ 0x85, 0x56, 0xab, 0x5e, 0x36, 0x1b, 0x6d, 0x83, 0xe3, 0x42, 0xda, 0xa1, 0xc2, 0x33, 0x96, 0x31,
+ 0xd8, 0x8e, 0xc1, 0x1e, 0x55, 0x02, 0x83, 0xcc, 0xe2, 0xf4, 0xfd, 0x6f, 0xbb, 0x71, 0xfd, 0xaf,
+ 0x77, 0xcb, 0x6a, 0x26, 0x66, 0xc3, 0xec, 0x1c, 0x37, 0x0b, 0x52, 0xae, 0x44, 0x6f, 0x8d, 0xe0,
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,
+ 0x42, 0xaf, 0x76, 0x84, 0xc1, 0xce, 0x3a, 0x0e, 0x0b, 0x5e, 0xa1, 0x45, 0xdb, 0xa0, 0xf9, 0xa5,
+ 0x04, 0x39, 0x87, 0x85, 0x08, 0x2f, 0xf7, 0x44, 0xb0, 0x56, 0x60, 0xb5, 0x06, 0x5e, 0xbf, 0x06,
+ 0x6f, 0x1c, 0x1f, 0x95, 0x2d, 0x78, 0x21, 0xb2, 0xc1, 0x41, 0x49, 0x77, 0x02, 0xf7, 0xa0, 0x87,
+ 0x60, 0x56, 0x4a, 0x56, 0xd1, 0x9d, 0xda, 0xe8, 0x91, 0xc0, 0xf8, 0x7f, 0x01, 0x19, 0x09, 0x8c,
+ 0xb6, 0x41, 0x99, 0x63, 0x3c, 0x53, 0x90, 0x4c, 0xc3, 0xf3, 0x3d, 0x7f, 0x1d, 0x92, 0x6a, 0xe7,
+ 0xfd, 0xda, 0xd0, 0xa7, 0xe1, 0xe0, 0x25, 0xff, 0xe6, 0xc3, 0x82, 0xe5, 0x2d, 0xef, 0x1f, 0x5e,
+ 0xef, 0x50, 0xb9, 0xf9, 0x72, 0xc2, 0x24, 0x2d, 0xf8, 0xa7, 0x61, 0x17, 0x24, 0xd9, 0x8d, 0x75,
+ 0x90, 0x1f, 0x73, 0x7f, 0xfe, 0xf3, 0x55, 0x9e, 0xfc, 0xf1, 0xef, 0xfa, 0x1f, 0x01, 0x00, 0x00,
+ 0xff, 0xff, 0x59, 0x78, 0xb0, 0x03, 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
index 2c0f594..5151fd5 100644
--- 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
@@ -4,8 +4,8 @@
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";
+import "protoc-gen-swagger/options/openapiv2.proto";
extend google.protobuf.FileOptions {
// ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project.
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
index 6720071..727ca52 100644
--- 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
@@ -1,13 +1,15 @@
// 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"
+package 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"
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ any "github.com/golang/protobuf/ptypes/any"
+ _struct "github.com/golang/protobuf/ptypes/struct"
+ math "math"
+)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
@@ -18,7 +20,7 @@
// 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
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type Swagger_SwaggerScheme int32
@@ -37,6 +39,7 @@
3: "WS",
4: "WSS",
}
+
var Swagger_SwaggerScheme_value = map[string]int32{
"UNKNOWN": 0,
"HTTP": 1,
@@ -48,8 +51,9 @@
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}
+ return fileDescriptor_ba35ad8af024fb48, []int{0, 0}
}
type JSONSchema_JSONSchemaSimpleTypes int32
@@ -75,6 +79,7 @@
6: "OBJECT",
7: "STRING",
}
+
var JSONSchema_JSONSchemaSimpleTypes_value = map[string]int32{
"UNKNOWN": 0,
"ARRAY": 1,
@@ -89,8 +94,9 @@
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}
+ return fileDescriptor_ba35ad8af024fb48, []int{8, 0}
}
// Required. The type of the security scheme. Valid values are "basic",
@@ -110,6 +116,7 @@
2: "TYPE_API_KEY",
3: "TYPE_OAUTH2",
}
+
var SecurityScheme_Type_value = map[string]int32{
"TYPE_INVALID": 0,
"TYPE_BASIC": 1,
@@ -120,8 +127,9 @@
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}
+ return fileDescriptor_ba35ad8af024fb48, []int{11, 0}
}
// Required. The location of the API key. Valid values are "query" or "header".
@@ -138,6 +146,7 @@
1: "IN_QUERY",
2: "IN_HEADER",
}
+
var SecurityScheme_In_value = map[string]int32{
"IN_INVALID": 0,
"IN_QUERY": 1,
@@ -147,8 +156,9 @@
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}
+ return fileDescriptor_ba35ad8af024fb48, []int{11, 1}
}
// Required. The flow used by the OAuth2 security scheme. Valid values are
@@ -170,6 +180,7 @@
3: "FLOW_APPLICATION",
4: "FLOW_ACCESS_CODE",
}
+
var SecurityScheme_Flow_value = map[string]int32{
"FLOW_INVALID": 0,
"FLOW_IMPLICIT": 1,
@@ -181,8 +192,9 @@
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}
+ return fileDescriptor_ba35ad8af024fb48, []int{11, 2}
}
// `Swagger` is a representation of OpenAPI v2 specification's Swagger object.
@@ -218,16 +230,17 @@
func (m *Swagger) String() string { return proto.CompactTextString(m) }
func (*Swagger) ProtoMessage() {}
func (*Swagger) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{0}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_Swagger.Merge(m, src)
}
func (m *Swagger) XXX_Size() int {
return xxx_messageInfo_Swagger.Size(m)
@@ -349,16 +362,17 @@
func (m *Operation) String() string { return proto.CompactTextString(m) }
func (*Operation) ProtoMessage() {}
func (*Operation) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{1}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_Operation.Merge(m, src)
}
func (m *Operation) XXX_Size() int {
return xxx_messageInfo_Operation.Size(m)
@@ -474,16 +488,17 @@
func (m *Response) String() string { return proto.CompactTextString(m) }
func (*Response) ProtoMessage() {}
func (*Response) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{2}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_Response.Merge(m, src)
}
func (m *Response) XXX_Size() int {
return xxx_messageInfo_Response.Size(m)
@@ -537,16 +552,17 @@
func (m *Info) String() string { return proto.CompactTextString(m) }
func (*Info) ProtoMessage() {}
func (*Info) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{3}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_Info.Merge(m, src)
}
func (m *Info) XXX_Size() int {
return xxx_messageInfo_Info.Size(m)
@@ -624,16 +640,17 @@
func (m *Contact) String() string { return proto.CompactTextString(m) }
func (*Contact) ProtoMessage() {}
func (*Contact) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{4}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_Contact.Merge(m, src)
}
func (m *Contact) XXX_Size() int {
return xxx_messageInfo_Contact.Size(m)
@@ -683,16 +700,17 @@
func (m *License) String() string { return proto.CompactTextString(m) }
func (*License) ProtoMessage() {}
func (*License) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{5}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_License.Merge(m, src)
}
func (m *License) XXX_Size() int {
return xxx_messageInfo_License.Size(m)
@@ -735,16 +753,17 @@
func (m *ExternalDocumentation) String() string { return proto.CompactTextString(m) }
func (*ExternalDocumentation) ProtoMessage() {}
func (*ExternalDocumentation) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{6}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_ExternalDocumentation.Merge(m, src)
}
func (m *ExternalDocumentation) XXX_Size() int {
return xxx_messageInfo_ExternalDocumentation.Size(m)
@@ -789,16 +808,17 @@
func (m *Schema) String() string { return proto.CompactTextString(m) }
func (*Schema) ProtoMessage() {}
func (*Schema) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{7}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_Schema.Merge(m, src)
}
func (m *Schema) XXX_Size() int {
return xxx_messageInfo_Schema.Size(m)
@@ -893,16 +913,17 @@
func (m *JSONSchema) String() string { return proto.CompactTextString(m) }
func (*JSONSchema) ProtoMessage() {}
func (*JSONSchema) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{8}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_JSONSchema.Merge(m, src)
}
func (m *JSONSchema) XXX_Size() int {
return xxx_messageInfo_JSONSchema.Size(m)
@@ -1079,16 +1100,17 @@
func (m *Tag) String() string { return proto.CompactTextString(m) }
func (*Tag) ProtoMessage() {}
func (*Tag) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{9}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_Tag.Merge(m, src)
}
func (m *Tag) XXX_Size() int {
return xxx_messageInfo_Tag.Size(m)
@@ -1133,16 +1155,17 @@
func (m *SecurityDefinitions) String() string { return proto.CompactTextString(m) }
func (*SecurityDefinitions) ProtoMessage() {}
func (*SecurityDefinitions) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{10}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_SecurityDefinitions.Merge(m, src)
}
func (m *SecurityDefinitions) XXX_Size() int {
return xxx_messageInfo_SecurityDefinitions.Size(m)
@@ -1212,16 +1235,17 @@
func (m *SecurityScheme) String() string { return proto.CompactTextString(m) }
func (*SecurityScheme) ProtoMessage() {}
func (*SecurityScheme) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{11}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_SecurityScheme.Merge(m, src)
}
func (m *SecurityScheme) XXX_Size() int {
return xxx_messageInfo_SecurityScheme.Size(m)
@@ -1321,16 +1345,17 @@
func (m *SecurityRequirement) String() string { return proto.CompactTextString(m) }
func (*SecurityRequirement) ProtoMessage() {}
func (*SecurityRequirement) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{12}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_SecurityRequirement.Merge(m, src)
}
func (m *SecurityRequirement) XXX_Size() int {
return xxx_messageInfo_SecurityRequirement.Size(m)
@@ -1366,16 +1391,17 @@
}
func (*SecurityRequirement_SecurityRequirementValue) ProtoMessage() {}
func (*SecurityRequirement_SecurityRequirementValue) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{12, 0}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_SecurityRequirement_SecurityRequirementValue.Merge(m, src)
}
func (m *SecurityRequirement_SecurityRequirementValue) XXX_Size() int {
return xxx_messageInfo_SecurityRequirement_SecurityRequirementValue.Size(m)
@@ -1411,16 +1437,17 @@
func (m *Scopes) String() string { return proto.CompactTextString(m) }
func (*Scopes) ProtoMessage() {}
func (*Scopes) Descriptor() ([]byte, []int) {
- return fileDescriptor_openapiv2_7182f700aabb5117, []int{13}
+ return fileDescriptor_ba35ad8af024fb48, []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_Merge(src proto.Message) {
+ xxx_messageInfo_Scopes.Merge(m, src)
}
func (m *Scopes) XXX_Size() int {
return xxx_messageInfo_Scopes.Size(m)
@@ -1439,6 +1466,11 @@
}
func init() {
+ 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)
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")
@@ -1464,18 +1496,13 @@
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)
+ proto.RegisterFile("protoc-gen-swagger/options/openapiv2.proto", fileDescriptor_ba35ad8af024fb48)
}
-var fileDescriptor_openapiv2_7182f700aabb5117 = []byte{
+var fileDescriptor_ba35ad8af024fb48 = []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, 0x45, 0x7a, 0xbd, 0x96, 0xf3, 0x47, 0x18, 0xdb, 0x7f, 0x85,
diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/query.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/query.go
index ee0207e..80ff21c 100644
--- a/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/query.go
+++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/query.go
@@ -117,14 +117,16 @@
props := proto.GetProperties(m.Type())
// look up field name in oneof map
- if op, ok := props.OneofTypes[name]; ok {
- v := reflect.New(op.Type.Elem())
- field := m.Field(op.Field)
- if !field.IsNil() {
- return reflect.Value{}, nil, fmt.Errorf("field already set for %s oneof", props.Prop[op.Field].OrigName)
+ for _, op := range props.OneofTypes {
+ if name == op.Prop.OrigName || name == op.Prop.JSONName {
+ v := reflect.New(op.Type.Elem())
+ field := m.Field(op.Field)
+ if !field.IsNil() {
+ return reflect.Value{}, nil, fmt.Errorf("field already set for %s oneof", props.Prop[op.Field].OrigName)
+ }
+ field.Set(v)
+ return v.Elem().Field(0), op.Prop, nil
}
- field.Set(v)
- return v.Elem().Field(0), op.Prop, nil
}
for _, p := range props.Prop {