Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New enums or enum values in API break end user workflows #113

Open
cprivitere opened this issue Aug 16, 2023 · 4 comments
Open

New enums or enum values in API break end user workflows #113

cprivitere opened this issue Aug 16, 2023 · 4 comments

Comments

@cprivitere
Copy link
Member

When new enum values are added to the upstream Equinix Metal API, they can cause issues with tooling that expects every enum to exist in the SDK.

We need to investigate how to more automatically add new enum values to the SDK.

@displague
Copy link
Member

The generator offers an option that may be helpful here:
https://openapi-generator.tech/docs/generators/java/

Option Description Values Default
enumUnknownDefaultCase If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case. false No changes to the enum's are made, this is the default option.

true With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
false

@displague
Copy link
Member

displague commented Aug 17, 2023

Semi-related, we can improve the documentation in the Java SDK for enums by taking advantage of x-enum-description:
OpenAPITools/openapi-generator#1693

Redocly will also take advantage of this in certain editions:
https://redocly.com/docs/api-reference-docs/specification-extensions/x-enum-descriptions

@displague
Copy link
Member

Noting for search purposes that the status field enum value that triggered this discussion is delete_failed. https://deploy.equinix.com/developers/api/metal#tag/Interconnections/operation/getVirtualCircuit

@ctreatma
Copy link
Contributor

The enumUnknownDefaultCase setting avoids validation errors but unfortunately it also obscures the actual value of the field (it comes back from the SDK as unknown_default_open_api instead of, e.g., delete_failed).

I chatted with some folks in the openapi-generator Slack and the consensus there was that plain strings should be used instead of enums (on response models, at least) because of this particular behavior. The downside of plain strings is that it can have a negative impact on rendered docs. That said, our own docs for findDeviceById provide a potential alternative: the state field on the 200 response has a very long description that covers the potential values of state and what they mean, so removing the enum from that field would not really negatively impact those docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants