Giter VIP home page Giter VIP logo

pbparser's People

Contributors

tallstoat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pbparser's Issues

Cannot find messages when package is defined across more than one dependency

When a package is defined across more than one file, pbparser should account for parsed messages defined in all files when performing verification.

Currenty pbparser parses all messages however only retains a reference to the first dependancy protofile. Only messages defined in the main package protofile and the first dependancy protofile are checked when performing verification.

Multiple protos in the same package importing each other

The following fails:

dependent.proto:

syntax = "proto3";
package dep;

import "dependency.proto";

message Dependent {
    SamePackageDependencyMessage field = 1;
}

dependency.proto:

syntax = "proto3";
package dep;

message SamePackageDependencyMessage {
    string field = 1;
}

If the two files are defined in different packages, this works well. If they are defined under the same package, it fails with error "Datatype: 'SamePackageDependencyMessage' referenced in field: 'field' is not defined".

[BUG] Message within message causes not defined error

The following is a legitimate protobuf file that works as expected when used over the wire:

syntax = "proto3";

package XYZ;

service CityService {
    rpc GetCitiesAndDistricts(Query) returns (Result) {}
}

message Query {}

message Result {
    message Countries {
        repeated City cities = 2;
    }

    message City {}
}

Note how a Countries contains repeated City's.

Trying to parse this with pbparser gives the following error:

unable to parse photo file: Datatype: 'City' referenced in field 'cities' is not defined

When I move the City outside Result, so at the same level as Result, pbparser can parse it correctly.

I will be searching through the source code and trying to fix this as I need the functionality, but if you think it's a small task and would take you a tenth of the time to fix it please let me know :)

Cannot handle grpc gateway options

It looks like the library cannot handle rpc options - specifically I am using the grpc gateway annotations:

rpc CreateWorkspace(CreateWorkspaceRequest) returns (CreateWorkspaceResponse) {
        option (google.api.http) = { post: "/v1/workspaces" body: "*" };
}

also it will complain about external dependencies(imports) which I'm not interested in.

parser comments will cause infinite loop

The program will enter an infinite loop, when parse proto file with comments like this \********* test ********\.
For example, parser the following proto file:

\****** test *****\
syntax = "proto3";

suggest replace readMultiLineComment#parser.go from

func (p *parser) readMultiLineComment() string {
	var buf bytes.Buffer
	for {
		c := p.read()
		if c != '*' {
			_, _ = buf.WriteRune(c)
		} else {
			c2 := p.read()
			if c2 == '/' {
				break
			}
			_, _ = buf.WriteRune(c2)
		}
	}
	str := buf.String()
	return strings.TrimSpace(str)
}

to

func (p *parser) readMultiLineComment() string {
	var buf bytes.Buffer
	for {
		c := p.read()
		if c == '*' {
			if c2 := p.read(); c2 == '/' {
				break
			}
			p.unread()
		}
		_, _ = buf.WriteRune(c)
	}
	str := buf.String()
	return strings.TrimSpace(str)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.