Repository navigation
fix(ruby): autoload models so a client loads in any order, and generate idiomatic Ruby - #8301
Merged
Vincent Biret (baywet) merged 25 commits intoSep 29, 2026
Merged
Conversation
…of require order - barrels register their models and enums with autoload instead of requiring them - files require a namespace's barrel, never a model file it registers nor their own barrel - a type no barrel autoloads is required directly, from its own or a parent namespace too - barrels write ::File so a model named File cannot shadow it - remove the unused AddInheritedAndMethodTypesImports - the Ruby IT resolves every registered constant, since a bad registration now fails on first use
… instance variables
- stop linting comment annotations, since API descriptions can start with "Note:"
…-segment namespace - remove the IT bridge file that was hiding the misplaced barrel
- stabby lambdas and {} instead of lambda blocks and Hash.new
- no trailing comma on the last hash entry, and super or {} for models with no fields of their own
- one include per line, in the order that keeps method lookup unchanged
- spaces around parameter defaults, and no redundant self on the request generator call
- track in the language writer whether a block has just opened, so no blank line starts a class body
- a blank line after guard clauses, and modifier if/unless for one-statement conditionals - composed-type factories with nothing to assign return the new instance directly
…hen it adds nothing
- the Ruby IT checks that no autoload is left pending after eager_load!
Vincent Biret (baywet)
approved these changes
Sep 29, 2026
4 tasks
Merged
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Ruby barrels and models required each other, so loading depended on require order. Barrels now register models with
autoload, as Stripe's Ruby SDK does, and a type no barrel can autoload is required directly.On clients generated by current main, this fixes:
require "api_client"fails. The IT hid it with an exclusion, now removed.models/entityraisesNameError.--namespace-namecannot be loaded. The IT hid it with a bridge file, now deleted.The output now follows RuboCop defaults (29 more cops enforced),
ruby -wdrops from 36,548 warnings to 2 on Stripe, empty barrel files are gone, and enums are frozen (fixes microsoft/kiota-ruby#68). Public names are unchanged. Models load on first use, so require the client or a barrel rather than a single model file;eager_load!loads them all.New tests: a three-level inheritance description for every language (its Ruby spec fails on main), Ruby discriminator and query parameter specs, and a check that every referenced constant resolves.
Covers item 1 of #7956. Will be rebased on #8256 once it merges.