Skip to content

Commit

Permalink
Merge pull request #40 from thevault/fix-message-type-parsing
Browse files Browse the repository at this point in the history
Fix proto message type parsing.
  • Loading branch information
awalterschulze authored Feb 27, 2018
2 parents 566297a + d6b1350 commit de20242
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion form/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ func isNumber(f *descriptor.FieldDescriptorProto) bool {

func getMessage(f *descriptor.FieldDescriptorProto, fileDescriptorSet *descriptor.FileDescriptorSet) *descriptor.DescriptorProto {
typeNames := strings.Split(f.GetTypeName(), ".")
packageName, messageName := typeNames[1], typeNames[2]
messageName := typeNames[len(typeNames)-1]
packageName := strings.Join(typeNames[1:len(typeNames)-1], ".")
return fileDescriptorSet.GetMessage(packageName, messageName)
}

Expand Down
2 changes: 1 addition & 1 deletion form/form.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

syntax = "proto3";

package form;
package weird.form;

message Weird {
string Name = 1;
Expand Down
2 changes: 1 addition & 1 deletion form/form_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestCreateCustom(t *testing.T) {
g.BuildTypeNameMap()
g.Reset()
g.SetFile(desc.File[0])
formStr = CreateCustom("WeirdMethod", "form", "Weird", g, CustomBuildField)
formStr = CreateCustom("WeirdMethod", "weird.form", "Weird", g, CustomBuildField)
testserver := httptest.NewServer(http.HandlerFunc(handle))
defer testserver.Close()
resp, err := http.Get(testserver.URL + "/WeirdMethod?json={%22Name%22:%22%22,%22WeirdName%22:%22another%20string%22,%22Number%22:null}")
Expand Down

0 comments on commit de20242

Please sign in to comment.