-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(regapic): accept numeric enums, allow testing enum round trips (#…
…1159) This introduces the RPCs `Compliance.GetEnum()` and `Compliance.VerifyEnum()`. The first returns one enum value that is either known or unknown to the client. The client can then send that response as the request message to the second RPC, which will verify that the value received was the same as the one originally sent. This thus tests that enum fields that are populated by the server with an unknown-to-the-client value (maybe because the client hasn't been regenerated for the latest proto version) and which are untouched by client code can be sent back to the server while preserving their value. This is particularly important in the REST transport case, and is the reason why we are separately implementing a feature to request that the server, if using REST, send all enums as numbers rather than strings. To test various types of responses from the command line, you can use the following commands: ``` curl -i -H "Content-Type: application/json" -H "X-Goog-Api-Client: rest/0.0.0 gapic/0.0.0" http://localhost:7469/v1beta1/compliance/enum\?unknownEnum\=true curl -i -H "Content-Type: application/json" -H "X-Goog-Api-Client: rest/0.0.0 gapic/0.0.0" http://localhost:7469/v1beta1/compliance/enum\?unknownEnum\=false curl -i -X POST -H "Content-Type: application/json" -H "X-Goog-Api-Client: rest/0.0.0 gapic/0.0.0" http://localhost:7469/v1beta1/compliance/enum?request.unknownEnum=true&continent=57 ``` To test requesting and verifying an enum from the command line: ``` echo -e "\n**** Request enum: ****\n" && \ REGAPIC_ENUM=$(curl -i -H "Content-Type: application/json" -H "X-Goog-Api-Client: rest/0.0.0 gapic/0.0.0" http://localhost:7469/v1beta1/compliance/enum\?unknownEnum\=true | tee /dev/tty | grep continent | grep -o -E -- '-?[0-9]+') && \ echo -e "\n\n**** Verify enum: ****\n" && \ curl -i -X POST -H "Content-Type: application/json" -H "X-Goog-Api-Client: rest/0.0.0 gapic/0.0.0" http://localhost:7469/v1beta1/compliance/enum?request.unknownEnum=true&continent=$REGAPIC_ENUM ``` (GAPICs should simply call the corresponding generated methods analogously.) As part of enabling this functionality, Showcase now allows receiving REST enum values JSON-encoded as numbers rather than strings. Earlier, there was an explicit prohibition against this.
- Loading branch information
1 parent
1d079d7
commit 1e863ae
Showing
5 changed files
with
129 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters