Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions internal/plugin/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,27 @@ func typeFromField(pkg protoreflect.FullName, field protoreflect.FieldDescriptor
}
}

// JSON Mapping: https://developers.google.com/protocol-buffers/docs/proto3#json
func namedTypeFromField(pkg protoreflect.FullName, field protoreflect.FieldDescriptor) Type {
switch field.Kind() {
case protoreflect.StringKind, protoreflect.BytesKind:
case
protoreflect.StringKind,
protoreflect.BytesKind,
protoreflect.Int64Kind,
protoreflect.Uint64Kind,
protoreflect.Fixed64Kind,
protoreflect.Sfixed64Kind,
protoreflect.Sint64Kind:
return Type{IsNamed: true, Name: "string"}
case protoreflect.BoolKind:
return Type{IsNamed: true, Name: "boolean"}
case
protoreflect.Int32Kind,
protoreflect.Int64Kind,
protoreflect.Uint32Kind,
protoreflect.Uint64Kind,
protoreflect.DoubleKind,
protoreflect.Fixed32Kind,
protoreflect.Fixed64Kind,
protoreflect.Sfixed32Kind,
protoreflect.Sfixed64Kind,
protoreflect.Sint32Kind,
protoreflect.Sint64Kind,
protoreflect.FloatKind:
return Type{IsNamed: true, Name: "number"}
case protoreflect.MessageKind:
Expand Down