OpenAPITools / OpenAPITools/openapi-generator
[Ruby] Added validations resulting in a breaking changes
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
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 https://github.com/OpenAPITools/openapi-generator/pull/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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Ruby client generation changes introduced by PR 20672 and compare version 7.12.0 with the prior behavior using the MyApi::User.new example and a required name. A contribution would need a maintainer decision on whether initialization validation is intended, plus a documented or tested resolution for the FactoryBot and Pact partial-response cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, ruby
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100