feat: Numeric enums in routing headers#2328
Conversation
|
After commit d63e854, the local testing shows this O/P. Getting "getFKingdomValue" in the method name. |
|
Code changes description: In first case (routingHeaderRule() == null, createRequestParamsExtractorBodyForHttpBindings() is called), createRequestFieldGetterExpr() is modified to accept an extra boolean parameter, isFieldEnum(). And if the field is enum, I am adding an extra “Value” to the fieldMethod name (https://github.com/googleapis/sdk-platform-java/pull/2328/files#diff-13cc1d69966fca5c433b2c243aa4e8414520cf05e295f02ed52f2fe5097cac21R1474) during the last iteration of the descendant fields. In the 2nd case when routingHeaderRule()!=null, I am sending false in isFieldEnum() because |
|
FYI @ddixit14, we have Showcase ITs for Dynamic Routing Headers at https://github.com/googleapis/sdk-platform-java/blob/762c125abadb5e56682224c9f1587c71e5c6e653/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITDynamicRoutingHeaders.java I think the compliance.proto has a enum field that you can possibly test against. It may be possible to add a test to intercept the the enum value is sent as an int value in the headers. |
| } | ||
|
|
||
| @Test | ||
| public void testGrpc_implicitHeadersEnum() { |
There was a problem hiding this comment.
nit: Rename this to be a bit more descriptive. Something like testGrpc_implicitHeaders_enumsEncodedasInt() to describe that this test covers specifically enums -> int.
There was a problem hiding this comment.
Also, can you add an httpjson test case as well. I think it affects both transports. Ignore this comment if it only affects gRPC.
There was a problem hiding this comment.
nit: Rename this to be a bit more descriptive. Something like
testGrpc_implicitHeaders_enumsEncodedasInt()to describe that this test covers specifically enums -> int.
+1000 to this. See unit tests naming for details.
There was a problem hiding this comment.
renamed the tests and added httpjson case as well. thank you.
|
Also, we talked earlier about possibly enhancing echo.proto to also test for some explicit + implicit dynamic routing enum use cases. I took another look into echo.proto and I think it makes sense since a bulk of the routing header test cases are there: https://github.com/googleapis/gapic-showcase/blob/330a3a25eb8c4d0948860f1898fe7dcc05dc4ea5/schema/google/showcase/v1beta1/echo.proto#L48-L86 I think you can create an issue in the gapic-showcase repo and someone can pick it up in the future. |
If we already have a test case in |
For now, it's mainly for the latter reason. Agreed that ideally we would have a separate showcase proto for routing headers, but it looks like the explicit headers are mostly contained in the echo proto. It's not urgent to add an enum to the echo proto, but a smaller task to enable showcase tests for more routing headers use cases is to add it there (especially for any future explicit enhancements/ improvements). In the future/whenever someone has the time, we can create a new proto specifically for routing headers. |
|
|
* chore: Numeric enums in routing headers


Solves - #2368 (Numeric enums in implicit routing headers)
FYI, only implicit routing headers can be fixed currently because explicit routing headers are implemented as strings by design. See this doc for more details.