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

Map of list #493

Closed
mavle opened this issue Dec 3, 2017 · 1 comment
Closed

Map of list #493

mavle opened this issue Dec 3, 2017 · 1 comment

Comments

@mavle
Copy link

mavle commented Dec 3, 2017

Hello, I have a bit of an oddball inquiry. I am wanting to model:

{
  "http": {
    "/mypath": [
      {
        "action": "GET",
        "requestAttributes": {
          "query": {
            "user": "*"
          }
        }
      }
    ]
  }
}

Which is a map of arrays. Proto3 doesn't support repeated values in maps so they force a message wrapper. i.e.

message Request {
  map<string, RouteArray> http = 6;
}

message RequestAttributes{
  map<string, string> headers = 1;
  string ip = 2;
}

message RouteArray {
  repeated RoutePolicy routePolicies = 1;
}

message RoutePolicy {
  string actions = 1;
  RequestAttributes requestAttributes = 2;
}

This is unfortunate as its passed to the user in a bad form. I'm curious if you all would allow a PR for some sort of annotation that would flatten the nested message into a map of arrays?

@achew22
Copy link
Collaborator

achew22 commented Dec 9, 2017

If you want to go about this I think the correct place to do it would be in https://github.com/google/protobuf. We don't control the spec for JSONification of protos so I think this is not the correct abstraction layer for that code.

@achew22 achew22 closed this as completed Dec 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants