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

Commit ef0ff69

Browse files
chrustyPrawn
andauthored
Using a proper package name for the generated options proto (#138)
Co-authored-by: Prawn <Prawn@Prawn>
1 parent 02c3b14 commit ef0ff69

File tree

3 files changed

+20
-603
lines changed

3 files changed

+20
-603
lines changed

internal/converter/converter.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
descriptor "google.golang.org/protobuf/types/descriptorpb"
1919
plugin "google.golang.org/protobuf/types/pluginpb"
2020

21-
"github.com/chrusty/protoc-gen-jsonschema/internal/protos"
21+
protoc_gen_jsonschema "github.com/chrusty/protoc-gen-jsonschema"
2222
)
2323

2424
const (
@@ -146,9 +146,9 @@ func (c *Converter) convertEnumType(enum *descriptor.EnumDescriptorProto, conver
146146
converterFlags.EnumsAsStringsOnly = c.Flags.EnumsAsStringsOnly
147147

148148
// Set some per-enum flags from config and options:
149-
if opts := enum.GetOptions(); opts != nil && proto.HasExtension(opts, protos.E_EnumOptions) {
150-
if opt := proto.GetExtension(opts, protos.E_EnumOptions); opt != nil {
151-
if enumOptions, ok := opt.(*protos.EnumOptions); ok {
149+
if opts := enum.GetOptions(); opts != nil && proto.HasExtension(opts, protoc_gen_jsonschema.E_EnumOptions) {
150+
if opt := proto.GetExtension(opts, protoc_gen_jsonschema.E_EnumOptions); opt != nil {
151+
if enumOptions, ok := opt.(*protoc_gen_jsonschema.EnumOptions); ok {
152152

153153
// ENUMs as constants:
154154
if enumOptions.GetEnumsAsConstants() {
@@ -301,9 +301,9 @@ func (c *Converter) convertFile(file *descriptor.FileDescriptorProto, fileExtens
301301
for _, msgDesc := range file.GetMessageType() {
302302

303303
// Check for our custom message options:
304-
if opts := msgDesc.GetOptions(); opts != nil && proto.HasExtension(opts, protos.E_MessageOptions) {
305-
if opt := proto.GetExtension(opts, protos.E_MessageOptions); opt != nil {
306-
if messageOptions, ok := opt.(*protos.MessageOptions); ok {
304+
if opts := msgDesc.GetOptions(); opts != nil && proto.HasExtension(opts, protoc_gen_jsonschema.E_MessageOptions) {
305+
if opt := proto.GetExtension(opts, protoc_gen_jsonschema.E_MessageOptions); opt != nil {
306+
if messageOptions, ok := opt.(*protoc_gen_jsonschema.MessageOptions); ok {
307307

308308
// "Ignored" messages are simply skipped:
309309
if messageOptions.GetIgnore() {
@@ -372,9 +372,9 @@ func (c *Converter) convert(request *plugin.CodeGeneratorRequest) (*plugin.CodeG
372372
fileExtension := c.schemaFileExtension
373373

374374
// Check for our custom file options:
375-
if opts := fileDesc.GetOptions(); opts != nil && proto.HasExtension(opts, protos.E_FileOptions) {
376-
if opt := proto.GetExtension(opts, protos.E_FileOptions); opt != nil {
377-
if fileOptions, ok := opt.(*protos.FileOptions); ok {
375+
if opts := fileDesc.GetOptions(); opts != nil && proto.HasExtension(opts, protoc_gen_jsonschema.E_FileOptions) {
376+
if opt := proto.GetExtension(opts, protoc_gen_jsonschema.E_FileOptions); opt != nil {
377+
if fileOptions, ok := opt.(*protoc_gen_jsonschema.FileOptions); ok {
378378

379379
// "Ignored" files are simply skipped:
380380
if fileOptions.GetIgnore() {

internal/converter/types.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"google.golang.org/protobuf/proto"
1212
descriptor "google.golang.org/protobuf/types/descriptorpb"
1313

14-
"github.com/chrusty/protoc-gen-jsonschema/internal/protos"
14+
protoc_gen_jsonschema "github.com/chrusty/protoc-gen-jsonschema"
1515
)
1616

1717
var (
@@ -148,9 +148,9 @@ func (c *Converter) convertField(curPkg *ProtoPackage, desc *descriptor.FieldDes
148148
stringDef := &jsonschema.Type{Type: gojsonschema.TYPE_STRING}
149149
// Check for custom options
150150
opts := desc.GetOptions()
151-
if opts != nil && proto.HasExtension(opts, protos.E_FieldOptions) {
152-
if opt := proto.GetExtension(opts, protos.E_FieldOptions); opt != nil {
153-
if fieldOptions, ok := opt.(*protos.FieldOptions); ok {
151+
if opts != nil && proto.HasExtension(opts, protoc_gen_jsonschema.E_FieldOptions) {
152+
if opt := proto.GetExtension(opts, protoc_gen_jsonschema.E_FieldOptions); opt != nil {
153+
if fieldOptions, ok := opt.(*protoc_gen_jsonschema.FieldOptions); ok {
154154
if fieldOptions.GetMinLength() > 0 {
155155
stringDef.MinLength = int(fieldOptions.GetMinLength())
156156
}
@@ -467,9 +467,9 @@ func (c *Converter) recursiveConvertMessageType(curPkg *ProtoPackage, msgDesc *d
467467

468468
// Set some per-message flags from config and options:
469469
messageFlags := c.Flags
470-
if opts := msgDesc.GetOptions(); opts != nil && proto.HasExtension(opts, protos.E_MessageOptions) {
471-
if opt := proto.GetExtension(opts, protos.E_MessageOptions); opt != nil {
472-
if messageOptions, ok := opt.(*protos.MessageOptions); ok {
470+
if opts := msgDesc.GetOptions(); opts != nil && proto.HasExtension(opts, protoc_gen_jsonschema.E_MessageOptions) {
471+
if opt := proto.GetExtension(opts, protoc_gen_jsonschema.E_MessageOptions); opt != nil {
472+
if messageOptions, ok := opt.(*protoc_gen_jsonschema.MessageOptions); ok {
473473

474474
// AllFieldsRequired:
475475
if messageOptions.GetAllFieldsRequired() {
@@ -578,9 +578,9 @@ func (c *Converter) recursiveConvertMessageType(curPkg *ProtoPackage, msgDesc *d
578578

579579
// Check for our custom field options:
580580
opts := fieldDesc.GetOptions()
581-
if opts != nil && proto.HasExtension(opts, protos.E_FieldOptions) {
582-
if opt := proto.GetExtension(opts, protos.E_FieldOptions); opt != nil {
583-
if fieldOptions, ok := opt.(*protos.FieldOptions); ok {
581+
if opts != nil && proto.HasExtension(opts, protoc_gen_jsonschema.E_FieldOptions) {
582+
if opt := proto.GetExtension(opts, protoc_gen_jsonschema.E_FieldOptions); opt != nil {
583+
if fieldOptions, ok := opt.(*protoc_gen_jsonschema.FieldOptions); ok {
584584

585585
// "Ignored" fields are simply skipped:
586586
if fieldOptions.GetIgnore() {

0 commit comments

Comments
 (0)