This commit allows models to keep JavaScript naming conventions in JSland (using camelCase for JSON-based Cocina data structures, e.g., in OpenAPI specifications) and Ruby naming conventions in Rubyland (using snake_case for Ruby bindings, e.g., hashes and method calls).
Fixes #335
Includes:
Convert attributes from camelCase to snake_case at generate time
Coerce attributes to camelCase when validating against the OpenAPI specification (i.e., using JSland conventions)
Generate self.new method into models even if they are not validatable to allow us to coerce attributes to underscore form (for Rubyland joy) at runtime
Add #method_missing to all models (via inheritance from Struct) to allow downstream codebases to continue using camelCase in Rubyland (backwards compatibility)
And leave tests untouched to demonstrate backwards compatibility
Deprecate and warn that backwards compatibility goes away as of version 1.0.0
Regenerate all models
Regenerate Rubocop TODOs
How was this change tested?
CI
Which documentation and/or configurations were updated?
Why was this change made?
This commit allows models to keep JavaScript naming conventions in JSland (using camelCase for JSON-based Cocina data structures, e.g., in OpenAPI specifications) and Ruby naming conventions in Rubyland (using snake_case for Ruby bindings, e.g., hashes and method calls).
Fixes #335
Includes:
self.new
method into models even if they are not validatable to allow us to coerce attributes to underscore form (for Rubyland joy) at runtime#method_missing
to all models (via inheritance fromStruct
) to allow downstream codebases to continue using camelCase in Rubyland (backwards compatibility)How was this change tested?
CI
Which documentation and/or configurations were updated?
None