Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Update protobuf package (#91)
Browse files Browse the repository at this point in the history
* Using new proto package

* Used the latest protoc to generate go code, has fully removed the old reference

Co-authored-by: Chrusty <>
  • Loading branch information
chrusty authored Sep 30, 2021
1 parent f8da8a9 commit 3710ff9
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 26 deletions.
4 changes: 2 additions & 2 deletions cmd/protoc-gen-jsonschema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"fmt"
"os"

"github.com/golang/protobuf/proto"
plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/proto"
plugin "google.golang.org/protobuf/types/pluginpb"

"github.com/chrusty/protoc-gen-jsonschema/internal/converter"
)
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.14

require (
github.com/alecthomas/jsonschema v0.0.0-20210918223802-a1d3f4b43d7b
github.com/golang/protobuf v1.5.0
github.com/iancoleman/orderedmap v0.2.0
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kr/pretty v0.1.0 // indirect
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ github.com/alecthomas/jsonschema v0.0.0-20210918223802-a1d3f4b43d7b/go.mod h1:/n
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
Expand Down
6 changes: 3 additions & 3 deletions internal/converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"strings"

"github.com/alecthomas/jsonschema"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/proto"
descriptor "google.golang.org/protobuf/types/descriptorpb"
plugin "google.golang.org/protobuf/types/pluginpb"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions internal/converter/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"strings"
"testing"

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/xeipuuv/gojsonschema"
"google.golang.org/protobuf/proto"
descriptor "google.golang.org/protobuf/types/descriptorpb"
plugin "google.golang.org/protobuf/types/pluginpb"

"github.com/chrusty/protoc-gen-jsonschema/internal/converter/testdata"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/converter/proto_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package converter
import (
"strings"

"github.com/golang/protobuf/protoc-gen-go/descriptor"
descriptor "google.golang.org/protobuf/types/descriptorpb"
)

// ProtoPackage describes a package of Protobuf, which is an container of message types.
Expand Down
4 changes: 2 additions & 2 deletions internal/converter/sourcecodeinfo.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package converter

import (
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
"google.golang.org/protobuf/proto"
descriptor "google.golang.org/protobuf/types/descriptorpb"
)

// Protobuf tag values for relevant message fields. Full list here:
Expand Down
2 changes: 1 addition & 1 deletion internal/converter/sourcecodeinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package converter
import (
"testing"

"github.com/golang/protobuf/protoc-gen-go/descriptor"
descriptor "google.golang.org/protobuf/types/descriptorpb"
)

func TestSourceInfoLookup(t *testing.T) {
Expand Down
9 changes: 4 additions & 5 deletions internal/converter/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (

"github.com/alecthomas/jsonschema"
"github.com/chrusty/protoc-gen-jsonschema/internal/protos"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
"github.com/iancoleman/orderedmap"
"github.com/xeipuuv/gojsonschema"
"google.golang.org/protobuf/proto"
descriptor "google.golang.org/protobuf/types/descriptorpb"
)

var (
Expand Down Expand Up @@ -481,14 +481,13 @@ func (c *Converter) recursiveConvertMessageType(curPkg *ProtoPackage, msg *descr
jsonSchemaType.AdditionalProperties = []byte("true")
}

c.logger.WithField("message_str", proto.MarshalTextString(msg)).Trace("Converting message")
c.logger.WithField("message_str", msg.String()).Trace("Converting message")
for _, fieldDesc := range msg.GetField() {

// Check for our custom field options:
opts := fieldDesc.GetOptions()
if opts != nil && proto.HasExtension(opts, protos.E_FieldOptions) {
opt, err := proto.GetExtension(opts, protos.E_FieldOptions)
if err == nil {
if opt := proto.GetExtension(opts, protos.E_FieldOptions); opt != nil {
if fieldOptions, ok := opt.(*protos.FieldOptions); ok {

// "Ignored" fields are simply skipped:
Expand Down
14 changes: 7 additions & 7 deletions internal/protos/options.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3710ff9

Please sign in to comment.