-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
We're using API generator for Ruby to generate OpenAPI clients from the spec file.
We've just generated new client using version 7.12.0 but this resulted in numerous breaking changes.
Those were caused by additions in #20672 that weren't marked as breaking.
Is raising errors on initialization a sensible approach? This feels slightly off. Consider a example API entity of user with required name attribute.
Calling generated model initialization method without arguments like
MyApi::User.new
Was working previously but will now raise an error as the name would be assigned to nil and the changes in setter method name= will mean it immediately fails.
In our apps this has manifested mostly in two places:
- specs constructing API gem models through FactoryBot no longer work. Workaround is to make sure to use FactoryBot
initialize_withdeclaration, otherwise I think default behaviour is to initialize empty model and then mass assign attributes later - Pact tests that were previously using partial responses for verification of what's required, now need every required field present, otherwise they will raise errors on initialization too.
Keen for any potential workarounds and other thoughts. Again the change was not noted as breaking but has got considerable knock on effect.