Skip to content

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

@tomdracz

Description

@tomdracz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions