You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using [(google.api.field_visibility).restriction = "INTERNAL"] and it works perfectly by excluding internal items from OpenAPI spec. I would expect internal fields to be excluded from grpc-gateway responses as well.
In theory you could accomplish this today with a custom marshaler that performs introspection on the fields as it marshals. I don't think we need to add this feature to the gateway directly unless there is a great demand for it. I encourage you to explore a custom marshaler implementation though, that shouldn't be too hard and completely possible today.
Custom marshaler would do this on runtime, and might be added performance penalty as it would travers most types and do some field checking.
easiest way to achieve something like this would be to add json:"-" into generated code to just not marshal those fields using default marshaler. But this is not something you can do now.
But shouldn't this be the default behaviour? Having it only hidden in OpenAPI spec adds even more confusion since user sees one state of the API while looking at the spec and then gets completely different response while calling it
The grpc-gateway depends on the behavior of the official Go protobuf JSON marshaler in this case. It's not something we control. If you want to make the case that the official Go protobuf JSON marshaler should ignore these fields, you'll have to raise an issue at https://github.com/golang/protobuf/issues.
馃殌 Feature
I am using
[(google.api.field_visibility).restriction = "INTERNAL"]
and it works perfectly by excluding internal items from OpenAPI spec. I would expect internal fields to be excluded fromgrpc-gateway
responses as well.Having:
curl -L -X POST 'localhost:8080/v1/example/echo/5?num=6&previewField=ok&internalField=not_ok'
I would expect following response:
Current response:
The text was updated successfully, but these errors were encountered: