Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you add features? Can you add comments when parsing a file? #2

Open
Aaron009 opened this issue Jan 13, 2019 · 3 comments
Open

Can you add features? Can you add comments when parsing a file? #2

Aaron009 opened this issue Jan 13, 2019 · 3 comments

Comments

@Aaron009
Copy link

Aaron009 commented Jan 13, 2019

// SearchRequest note
message SearchRequest {
  string query = 1;         // note1
  int32 page_number = 2;    // note2
  int32 result_per_page = 3;  // note3
  repeated string snippets = 4; // note4
  Corpus corpus = 5;
}

// Parsing return time
// example
{
	"type": "field",
	"typename": "map",
	"key": "int32",
	"value": "string",
	"name": "bla",
    "note": "note 4"    // this add
	"fieldNo": 1,
	"opts": {}
}

To give a suggestion, it is best to put an example.proto file in the library, so that it is easy to understand.

@lal12
Copy link
Owner

lal12 commented May 3, 2019

Added an example section in the README. It is not that easily possible to add a note in the result as you suggested. Since it is not really clear to which node the comment belongs to. It would probably be possible to add another object containing only a comment, which would appear between the fields. Just give a hint if that would be sufficient.

@maltegrosse
Copy link

I like the idea of adding kind of comments, but I would prefer to have it in a structured way.
For example https://github.com/favadi/protoc-go-inject-tag/blob/master/README.md#usage
use
// @inject_tag: valid:"ip"
thus we could define required fields which needs to be handled in the front end (for example in forms) - as the required/optional parameter was dropped in proto3
// @inject_tag: required:"true"

which would be parsed as
....{ .... "required": true ... }

@inject_tag would be nice as I already use it for my go backend.
PS. the tag is always placed above the parameter

@Aaron009
Copy link
Author

@lal12 @maltegrosse
In fact, as long as the method of annotation is fixed, you can determine which annotations this is.
I'm also very familiar with regular expressions now, and writing this is relatively simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants