google-cloud-node
google-cloud-node copied to clipboard
enum type in protos isn't well represented in reference docs
see: https://github.com/googleapis/nodejs-vision/issues/439
In a variety of places I believe the string representation of proto enums is used, e.g., LIKELY, VERY_LIKELY, in the vision API, however, the docs indicate an integer return type. It would be nice if enums were better described in documentation.
In general, it's a bit confusing that a string is treated as an enum, it might be worth instead having actual types, like Likelihood.LIKELY, Likelihood.VERY_LIKELY.
The typecript definition of the likelyhood is :
google.cloud.vision.v1.Likelihood | "UNKNOWN" | "VERY_UNLIKELY" | "UNLIKELY" | "POSSIBLE" | "LIKELY" | "VERY_LIKELY" | null | undefined
Which makes it very confusing, and the official example themselves are wrong if that typing is correct.
To check if something is unlikely one has to check that:
safeSearchResult?.adult == 'VERY_UNLIKELY' || safeSearchResult?.adult == google.cloud.vision.v1.Likelihood.UNLIKELY
Just use an one version of that variable, no need to have it sometimes be an enum int and sometimes be a string. It's unnecessarily confusing
This is very late, I believe this has been fixed, at least it's no longer listed as a string (rather as an enum): https://cloud.google.com/nodejs/docs/reference/vision/latest/vision/protos.google.cloud.vision.v1.faceannotation-class
I may be misunderstanding your original problem though, if so please let me know if so.
@sofisl
it can be either a number from the enum or a string from the union.
This has been closed since a request for information has not been answered for 15 days. It can be reopened when the requested information is provided.
It was answered the comment before. Please reopen and change the label, or ask for further detail if that was not clear.