Repository navigation
[pull] master from OpenAPITools:master - #812
Merged
Merged
Conversation
…llOf parent (#24892) * [ruby] fix: build_from_hash maps attributes inherited from allOf parents A discriminator allOf child generates as a real subclass, but build_from_hash iterated only openapi_types/attribute_map - class methods that dispatch on the child class in every frame of the ancestry, so a parent's attributes were never mapped from the wire hash: a required inherited attribute made deserialization raise ArgumentError, an optional one came back silently nil. The pre-existing super(attributes) call could not help: its result was discarded, and it iterated the child's own types anyway. Walk the ancestry merging each ancestor's openapi_types and attribute_map (the child wins on a name clash) and drop the discarded-result super call. RubyClientCodegenTest asserts the walk on the generated two-level Lizard < Reptile < Pet fixture (fails without the template change), and the three petstore custom base_object specs now deserialize a Cat that carries its parent's attributes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz * update ruby samples Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz * [ruby] fix: to_hash loses the same inherited attributes The serialization direction has the identical defect: attribute_map and openapi_nullable dispatch on the child class in every ancestor frame, so the inherited super chain only repeated the child's own attributes and a round-tripped allOf child lost its parent's fields again on the way out. Walk the ancestry the same way build_from_hash now does; for a model without a generated parent the walk does not run and the output is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz * update ruby samples Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz * [ruby] fix: ancestor nullability defers to a child's redeclaration, and Set loads Two findings from review: the merged-nullable union let a parent's nullable flag survive a child redeclaring the attribute as non-nullable - an ancestor's entry now only applies to attributes no nearer class declares - and the walk evaluates openapi_nullable eagerly for every to_hash call, so the generated models require 'set' explicitly instead of leaning on the Set builtin autoload rubies before 3.2 do not have. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz * [ruby] fix: only hand an initializer the attributes it accepts, and load Set only where used build_from_hash and to_hash now take their attribute map from acceptable_attribute_map, the same map the generated initializer validates against. For a generated allOf child it is identical to the ancestry walk; for a consumer subclass that narrows attribute_map it keeps the attributes to the ones the subclass accepts, as on master, instead of passing its parent's fields to an initializer that rejects them. The ancestry walk remains for openapi_types and openapi_nullable. require 'set' is emitted only for generic models, the only ones whose openapi_nullable uses Set; enum classes and oneOf/anyOf modules no longer carry it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * [ruby] refactor: merge inherited types and nullability with the acceptable_attribute_map idiom acceptable_openapi_types and acceptable_openapi_nullable merge along the allOf ancestry the way acceptable_attribute_map already does, so build_from_hash and to_hash lose their while loops and the require 'set' block. Also drops the redundant map.key? guard, shortens the generated comments and specs, and reverts the stray ruby-faraday Gemfile.lock bump. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * [ruby] fix: models whose superclass is not a generated model do not delegate to it An alias to an array (ArrayAlias < Array) has a parent, so the ancestry helpers and the initializer called superclass methods Array does not provide. Gate the delegation on parentModel, so every model has a base case. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )