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

[Ruby] Added validations resulting in a breaking changes #21029

Open
tomdracz opened this issue Apr 4, 2025 · 1 comment
Open

[Ruby] Added validations resulting in a breaking changes #21029

tomdracz opened this issue Apr 4, 2025 · 1 comment

Comments

@tomdracz
Copy link

tomdracz commented Apr 4, 2025

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_with declaration, 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.

@wing328
Copy link
Member

wing328 commented Apr 7, 2025

@tomdracz thanks for reporting the issue. I merged it as bug fixes. Sorry that it breaks your use cases.

@yujideveloper can you please review the feedback from @tomdracz when you've time? Thanks.

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

2 participants