-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Open
Labels
Description
Description
The changes to introduce better validation to the attributes hash in the initialize
method, should also apply in the build_from_hash
method.
openapi-generator version
$ docker run --rm openapitools/openapi-generator-cli version
4.2.3-SNAPSHOT
Steps to reproduce
- Generate any ruby API
- Build a hash with an incorrectly spelled attribute and create a model object with it.
E.g.
irb(main):012:0> Kubernetes::IoK8sApiBatchV1Job.new(api_version: 'batch/v1', kid: 'Job')
...
ArgumentError (`kid` is not a valid attribute in `Kubernetes::IoK8sApiBatchV1Job`. Please check the name to make sure it's valid. List of attributes: [:api_version, :kind, :metadata, :spec, :status])
vs
irb(main):013:0> Kubernetes::IoK8sApiBatchV1Job.build_from_hash(api_version: 'batch/v1', kid: 'Job')
=> #<Kubernetes::IoK8sApiBatchV1Job:0x000055ae59e2d238>
Related issues/PRs
Suggest a fix
Factor out the validation code from initialize and either call it directly from the 'build_from_hash' method, and/or add a 'strictValidation' parameter to allow backward compatibility.