-
Notifications
You must be signed in to change notification settings - Fork 12
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
Gracefully handle invalid transaction flag values from server #82
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking a look at this! ❤️
Just not sure this approach would stick, long-term. 🤔
return value | ||
else | ||
return nil | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect these changes not to stick and a regression to happen as soon as the API Ruby code is regenerated from the OpenAPI spec file (for example using rake generate
).
Is there a mechanism in place to prevent this kind of accidental regression to happen?
Note the comment at the top of most files:
Generated by: OpenAPI Generator (https://openapi-generator.tech) |
Update: I had missed that you added a code generation template at templates/partial_model_enum_class.mustache! I didn't even know that was a thing.
I don't know how those templates get picked up by the generator (update again: here?), but that looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - that template should ensure the changes stay intact on next generation.
The changes in this PR were just released in 3.6.0 🎉. |
The OpenAPI Generator, by default, throws an error if enum type data is received from the server that is not defined in the spec. In theory, the spec should always match what the server returns but in some cases there are unexpected values (new enum values not introduced in client, old enum values no longer in use, etc., bugs).
To work around this, we'll gracefully handle unsupported values by converting them to
nil
in the client, rather than throwing an error.Fixes #81