google-cloud-node icon indicating copy to clipboard operation
google-cloud-node copied to clipboard

enum type in protos isn't well represented in reference docs

Open bcoe opened this issue 6 years ago • 3 comments

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.

bcoe avatar Sep 13 '19 00:09 bcoe

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

cedvdb avatar Mar 13 '24 11:03 cedvdb

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 avatar Oct 10 '24 20:10 sofisl

@sofisl

it can be either a number from the enum or a string from the union.

image

cedvdb avatar Oct 10 '24 22:10 cedvdb

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.

github-actions[bot] avatar Oct 26 '24 01:10 github-actions[bot]

It was answered the comment before. Please reopen and change the label, or ask for further detail if that was not clear.

cedvdb avatar Oct 26 '24 10:10 cedvdb