[Ruby] Add new `ruby-nextgen` client generator (opt-in idiomatic redesign)
Description
Adds a new opt-in Ruby client generator, ruby-idiomatic, that emits modern, DRY, multi-instance Ruby. It mirrors the recent Crystal idiomatic redesign (#24070) but as a separate generator — the existing ruby generator, its templates, and its samples are left byte-for-byte unchanged, so there is zero blast radius for its install base. Users opt in with -g ruby-idiomatic and migrate when they choose.
What it produces
- Namespaced sub-clients —
client.dcim.cable_terminations.listinstead of a flatDcimApiwith prefixed methods (path→route helper + a hybridmodulenesting with a configurableapiNamespacewrapper). - Single
Connection#callchoke-point (Faraday) — short declarative operations, keyword args everywhere, no_with_http_infotwins. - Delegating
Response(.data/.status/.headers) and one richApiError(all Faraday errors wrapped). - Native multi-instance — a
Clientfacade owns a per-instanceConfiguration/Connection; no global singleton. Configuration#useseam to register custom Faraday middleware (request signing à la OVH / AWS SigV4 that a static OpenAPI security scheme cannot model) without subclassing.- Models on a declarative
attributeDSL + sharedSerializable/Validationsmixins (replaces theEnumAttributeValidatorhierarchy and per-model duplication); recursivefrom_hashdeserializes nested models/arrays/maps/unions/enums into typed objects;additionalPropertiespreserved; anyOf/oneOf via aPolymorphismhelper. - Zeitwerk class loading (lazy, no generated require/autoload list); Ruby 3.0 floor;
frozen_string_literaleverywhere; FeatureSet declared honestly (JSON only, no XML, allOf/anyOf/oneOf/Union, apiKey/basic/bearer). - Clean gem scaffolding: modern gemspec, LICENSE, dev deps (rake, rspec, rubocop*, simplecov) + binstubs,
.rspec, cleanspec_helper, GitHub Actions CI, and a rich README (incl. the request-signing middleware example). The generated gem passesrubocopclean out of the box (no-Aneeded).
Testing / evidence
- Codegen unit tests:
RubyIdiomaticClientCodegenTest+RubyApiRoutingTest(19 tests) — green. - Samples:
petstore(16 examples, 0 failures) and a real-world Qdrant client undersamples/client/others/ruby-idiomatic-qdrant(577 examples, 0 failures; exercises anyOf / named enums). Both passrubocopwith no offenses. - On the Qdrant spec, generated model LOC is ~76% lower than the stock
rubygenerator. - Existing
ruby*samples are untouched.
PR checklist
- Read the contribution guidelines.
- Ran
./mvnw clean package, regenerated this generator's samples (./bin/generate-samples.sh bin/configs/ruby-idiomatic*.yaml) and its docs. Only the newruby-idiomaticgenerator's outputs change; no other generator output is affected. - @mention the Ruby technical committee for review.
cc @wing328 — new opt-in Ruby generator (idiomatic redesign), following up on the Crystal work in #24070.
Summary by cubic
Adds an opt-in Ruby client generator, ruby-idiomatic, that builds modern, namespaced, multi-instance clients on faraday + zeitwerk. Ships with generator docs (beta), SPI registration, unit tests, and sample clients (petstore and Qdrant) with CI; adds a samples workflow running petstore RSpec on Ruby 3.0/3.3 and links the new docs entry as ruby-idiomatic (beta).
-
New Features
- Namespaced sub-clients via path→route mapping (e.g.,
client.collections.points.search). - Single
Connection#call(faraday); keyword args only; no_with_http_info. - Unified
Response(data/status/headers) and richApiErrorwrapping Faraday errors. - Native multi-instance with per-client
Configuration/Connection; no globals. Configuration#useto register custom Faraday middleware.- Models use an
attributeDSL with sharedSerializable/Validations; anyOf/oneOf viaPolymorphism; preservesadditionalProperties. - Zeitwerk autoloading with nested module support and acronym inflections; Ruby >= 3.0; JSON-only; depends on
faraday,faraday-multipart,zeitwerk. - Generator docs page added and linked as
ruby-idiomatic (beta); unit tests; petstore + Qdrant samples with CI; samples workflow monitors both sample paths.
- Namespaced sub-clients via path→route mapping (e.g.,
-
Bug Fixes
- Normalize HTTP methods to lowercase symbols in
Connection#call. - Percent-encode path params when interpolating into URLs.
- Apply auth on every request and honor apiKey locations (header/query/cookie) plus basic/bearer.
- Do not materialize schema defaults in model constructors; optional fields remain nil so server defaults apply.
- Fix Windows CI: join API subpaths with '/' in
toApiFilenamefor consistent output and manifests across platforms. - Regenerated docs index and canonical FILES manifests to fix CI drift.
- Normalize HTTP methods to lowercase symbols in