Conversation
I'm doing this because, and I'm not sure why, it's not being output to the generated SDK unless I add this, even though it's part of the template.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis PR adds comprehensive Ruby SDK generation support by introducing Makefile targets for Ruby client building/testing, OpenAPI generator configuration files, and 60+ Mustache templates covering API clients, models, configuration, documentation, and testing scaffolds for automated Ruby SDK generation. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 12
🤖 Fix all issues with AI agents
In `@config/clients/ruby/.openapi-generator-ignore`:
- Around line 1-18: The .openapi-generator-ignore file contains trailing spaces
on entries ".rspec ", ".travis.yml " and "Rakefile " causing patterns not to
match; edit the file to remove trailing whitespace from those entries so they
read ".rspec", ".travis.yml" and "Rakefile" (and scan the rest of the file for
any other trailing spaces) to ensure ignore rules behave like the intended
.gitignore-style patterns.
In `@config/clients/ruby/config.overrides.json`:
- Around line 4-5: The Ruby client override sets "packageVersion": "0.0.1" which
is inconsistent with other SDKs; confirm whether Ruby is intentionally starting
at 0.0.1 for a new SDK or update the override to match the project's standard
SDK versioning (e.g., align with 0.9.x used by other clients). If intentional,
add a clarifying comment in the override explaining why Ruby differs; otherwise
change the "packageVersion" for the packageName "openfga" to the agreed common
version (e.g., 0.9.9) so it matches the other SDKs.
- Around line 1-37: Add the missing fossaComplianceNoticeId property to the JSON
config by inserting a new top-level key "fossaComplianceNoticeId" with a unique
UUID string value (e.g., generate a new UUID v4) alongside the existing keys
like "sdkId", "gemName", and "moduleName"; ensure the key is placed at the same
object level as the other metadata fields and that the value is a quoted string
so the JSON remains valid.
In `@config/clients/ruby/template/api_client_httpx_partial.mustache`:
- Around line 54-59: The debug log references an undefined variable req_body
after assigning the request payload to body_params; update the logging to use
body_params (or assign build_request_body to req_body instead) so the debug
branch in the block handling %w[POST PATCH PUT DELETE] uses the same variable
that was created (refer to build_request_body, body_params and the
config.debugging logger call in the api_client_httpx_partial.mustache template).
In `@config/clients/ruby/template/api_client_typhoeus_partial.mustache`:
- Around line 130-159: The tempfile created in download_file (inside
request.on_headers) can be left on disk if the request later fails and call_api
raises ApiError; modify download_file so any error path deletes/unlinks the
tempfile: ensure request.on_complete inspects the final response status and,
before raising ApiError, calls tempfile.close and tempfile.unlink (or
tempfile.delete) when tempfile exists, and guard request.on_body to no-op if
tempfile is nil; also consider wrapping the lifecycle in a begin/rescue/ensure
within download_file so tempfile is always cleaned up on exceptions raised by
call_api or the request handlers.
- Line 56: The follow_location option is incorrectly always true because the
code uses truthy-or (opts[:follow_location] || true) which forces false to true;
change the assignment for follow_location to use a proper default lookup such as
using opts.fetch(:follow_location, true) or checking for nil (opts.key?/nil?
pattern) so an explicit false in opts[:follow_location] is preserved; update the
assignment where follow_location is defined to use that pattern (referencing the
follow_location variable and opts hash in the template).
In `@config/clients/ruby/template/configuration_faraday_partial.mustache`:
- Around line 10-15: Update the outdated Ruby stdlib documentation link in the
TLS/SSL comment near the attr_accessor :ssl_verify_mode so it points to a
current or version-agnostic doc URL (e.g., docs.ruby-lang.org or a 3.x
OpenSSL/SSL page) instead of the EOL ruby-doc.org/stdlib-2.5.1 path; edit the
comment block above ssl_verify_mode in configuration_faraday_partial.mustache to
replace the old link with the chosen up-to-date URL.
In `@config/clients/ruby/template/configuration_httpx_partial.mustache`:
- Line 2: Update the outdated Ruby docs link in
configuration_httpx_partial.mustache (the comment starting with "You can use
this to customize SSL Context settings") to point to a current, version-agnostic
Ruby docs URL such as https://docs.ruby-lang.org/en/ or the latest
OpenSSL::SSL::SSLContext page on docs.ruby-lang.org instead of the old
ruby-doc.org/stdlib-2.5.1 path so the comment references up-to-date
documentation.
In `@config/clients/ruby/template/gemspec.mustache`:
- Around line 39-40: Remove the deprecated assignment to s.test_files in the
gemspec template: delete the line that sets s.test_files (the `s.test_files =
`find spec/*`.split("\n")` entry) from
config/clients/ruby/template/gemspec.mustache so the generated gemspec no longer
includes the obsolete attribute; leave the s.files line unchanged.
In `@config/clients/ruby/template/partial_oneof_module_doc.mustache`:
- Around line 44-46: The heading in the partial docs is incorrect: change the
Markdown heading text from `openapi_discriminator_name` to
`openapi_discriminator_mapping` so it matches the documented method
`.openapi_discriminator_mapping` and the description "Returns the
discriminator's mapping"; update the single-line heading at the top of that
section (the line currently showing ### `openapi_discriminator_name`) to ###
`openapi_discriminator_mapping`.
In `@config/clients/ruby/template/README_calling_api.mustache`:
- Line 362: Replace the two hardcoded API doc URLs
"https://openfga.dev/api/service" in the README_calling_api.mustache template
(the links that render as "[API
Documentation](https://openfga.dev/api/service#/Relationship%20Queries/BatchCheck)"
and the other occurrence) with the mustache variable {{apiDocsUrl}} so the links
become dynamic; locate the literal string "https://openfga.dev/api/service" in
the file and swap it for {{apiDocsUrl}} while keeping the fragment/path (e.g.,
`#/Relationship`%20Queries/BatchCheck) intact.
In `@config/clients/ruby/template/README_installation.mustache`:
- Around line 1-23: Replace the hardcoded gem name "openfga" in
README_installation.mustache with the mustache variable {{{gemName}}};
specifically update the three occurrences (the `gem install ...` line, the `gem
'...'` entry in the Gemfile example, and the `require '...'` line) to use
{{{gemName}}} so the generated README stays in sync with the generator
configuration.
🧹 Nitpick comments (8)
Makefile (1)
269-277: Ruby targets not wired intobuild-all-clients/test-all-clients.
build-client-rubyandtest-client-rubyare not included in the aggregate targets on lines 55 and 58. If this is intentional for the initial phase, consider adding a comment to explain why, so future contributors don't assume it was an oversight.Also, the
test-client-rubytarget body is empty (comment-only), which meansmake test-client-rubywill silently succeed without running any tests. This is fine for bootstrapping, but a$(warning ...)or@echonoting that tests are not yet implemented would make CI output less misleading.Suggested improvement
.PHONY: test-client-ruby test-client-ruby: build-client-ruby - # ... any custom test code ... + `@echo` "WARNING: Ruby SDK tests are not yet implemented"config/clients/ruby/template/gem.mustache (1)
55-59: Generic upstream comment referencesusername/password— not applicable to OpenFGA.The
configureblock example referencesconfig.usernameandconfig.password, which are default OpenAPI generator boilerplate. For the OpenFGA SDK, this comment would be more useful if it showed OpenFGA-specific configuration (e.g.,api_url,store_id, orcredentials).config/clients/ruby/template/model_test.mustache (1)
32-32: HardcodedPetstorereference in commented example.The commented-out enum validator example references
Petstore::EnumTest::EnumAttributeValidatorinstead of using{{moduleName}}. While it's in a comment, generated test files will carry this stale reference, which may confuse SDK consumers.Suggested fix
- # validator = Petstore::EnumTest::EnumAttributeValidator.new('{{{dataType}}}', [{{`#allowableValues`}}{{`#enumVars`}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]) + # validator = {{moduleName}}::EnumAttributeValidator.new('{{{dataType}}}', [{{`#allowableValues`}}{{`#enumVars`}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}])config/clients/ruby/template/api_error.mustache (1)
23-25: Arbitrary instance variable injection from hash keys.
instance_variable_set "@#{k}", vsets ivars for every key in the hash without validation. While this is an established upstream OpenAPI generator pattern, be aware it allows setting unexpected internal state if callers pass extra keys.config/clients/ruby/template/partial_anyof_module.mustache (1)
40-91: Near-identicalfind_and_cast_into_typelogic duplicated withpartial_oneof_module.mustache.The
find_and_cast_into_typeprivate helper (Lines 45–91) and theSchemaMismatchErrordefinition (Line 42) are virtually identical to the corresponding code inpartial_oneof_module.mustache. The only difference is that the oneOf variant checksopenapi_one_ofat Line 118 vs.openapi_any_ofhere at Line 76.Consider extracting the shared type-casting logic into a common partial or helper module to avoid divergence over time.
config/clients/ruby/template/api_model_base.mustache (1)
12-49:_deserializesilently coercesnilfor primitive types.When
valueisnil, the primitive branches silently produce lossy defaults:nil.to_i → 0,nil.to_f → 0.0,nil.to_s → "", and the Boolean regex maps it tofalse. TheTime/Date/Array/Hashbranches will raise.This is a known pattern in upstream OpenAPI generators (callers are expected to nil-guard), but worth flagging given that the anyOf/oneOf
buildpaths could feed arbitrary data through here.config/clients/ruby/template/api_client_faraday_partial.mustache (1)
157-159: Potential nil dereference ifopts[:header_params]is missing.
connection(opts)accessesopts[:header_params]['Content-Type']without a nil guard. Ifconnectionis ever called with opts that don't include:header_params, this will raise aNoMethodError. Currently safe becausecall_apialways passes the full opts hash from the generated API methods, but this is fragile.🛡️ Suggested defensive fix
def connection(opts) - opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular + opts.dig(:header_params, 'Content-Type') == 'multipart/form-data' ? connection_multipart : connection_regular endconfig/clients/ruby/template/configuration.mustache (1)
368-388:gsub!mutates the URL string fromserver_settingsin-place.Lines 377 and 383 use
url.gsub!which mutates the string obtained viaurl = server[:url]. This is safe today becauseserver_settingsandoperation_server_settingsreturn fresh data structures on every call, but it would silently break if either method were memoized in the future. Using non-mutatinggsub(or.dupon line 369) would be more defensive.♻️ Suggested defensive fix
server = servers[index] - url = server[:url] + url = server[:url].dup
| Gemfile | ||
| .gitignore | ||
| .rspec | ||
| .rubocop.yml | ||
| .travis.yml | ||
| .gitlab-ci.yml | ||
| git_push.sh | ||
| .github/CODEOWNERS | ||
| .github/ISSUE_TEMPLATE/bug_report.yaml | ||
| .github/ISSUE_TEMPLATE/feature_request.yaml | ||
| .github/ISSUE_TEMPLATE/config.yaml | ||
| Rakefile | ||
| spec/api/* | ||
| spec/models/* | ||
| spec/api_client_spec.rb | ||
| spec/spec_helper.rb | ||
| spec/configuration_spec.rb | ||
| .codecov.yml No newline at end of file |
There was a problem hiding this comment.
Trailing whitespace on lines 3, 5, and 12 may prevent ignore rules from matching.
The .openapi-generator-ignore file uses .gitignore-like syntax. The trailing spaces on .rspec , .travis.yml , and Rakefile could be interpreted as literal characters in the pattern, causing these entries to silently fail to match.
Proposed fix — trim trailing whitespace
Gemfile
.gitignore
-.rspec
+.rspec
.rubocop.yml
-.travis.yml
+.travis.yml
.gitlab-ci.yml
git_push.sh
.github/CODEOWNERS
.github/ISSUE_TEMPLATE/bug_report.yaml
.github/ISSUE_TEMPLATE/feature_request.yaml
.github/ISSUE_TEMPLATE/config.yaml
-Rakefile
+Rakefile
spec/api/*
spec/models/*
spec/api_client_spec.rb
spec/spec_helper.rb
spec/configuration_spec.rb
.codecov.yml📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Gemfile | |
| .gitignore | |
| .rspec | |
| .rubocop.yml | |
| .travis.yml | |
| .gitlab-ci.yml | |
| git_push.sh | |
| .github/CODEOWNERS | |
| .github/ISSUE_TEMPLATE/bug_report.yaml | |
| .github/ISSUE_TEMPLATE/feature_request.yaml | |
| .github/ISSUE_TEMPLATE/config.yaml | |
| Rakefile | |
| spec/api/* | |
| spec/models/* | |
| spec/api_client_spec.rb | |
| spec/spec_helper.rb | |
| spec/configuration_spec.rb | |
| .codecov.yml | |
| Gemfile | |
| .gitignore | |
| .rspec | |
| .rubocop.yml | |
| .travis.yml | |
| .gitlab-ci.yml | |
| git_push.sh | |
| .github/CODEOWNERS | |
| .github/ISSUE_TEMPLATE/bug_report.yaml | |
| .github/ISSUE_TEMPLATE/feature_request.yaml | |
| .github/ISSUE_TEMPLATE/config.yaml | |
| Rakefile | |
| spec/api/* | |
| spec/models/* | |
| spec/api_client_spec.rb | |
| spec/spec_helper.rb | |
| spec/configuration_spec.rb | |
| .codecov.yml |
🤖 Prompt for AI Agents
In `@config/clients/ruby/.openapi-generator-ignore` around lines 1 - 18, The
.openapi-generator-ignore file contains trailing spaces on entries ".rspec ",
".travis.yml " and "Rakefile " causing patterns not to match; edit the file to
remove trailing whitespace from those entries so they read ".rspec",
".travis.yml" and "Rakefile" (and scan the rest of the file for any other
trailing spaces) to ensure ignore rules behave like the intended
.gitignore-style patterns.
| { | ||
| "sdkId": "ruby", | ||
| "gitRepoId": "ruby-sdk", | ||
| "packageName": "openfga", | ||
| "packageVersion": "0.0.1", | ||
| "packageDescription": "Ruby SDK for OpenFGA", | ||
| "packageDetailedDescription": "This is an autogenerated ruby SDK for OpenFGA. It provides a wrapper around the [OpenFGA API definition](https://openfga.dev/api).", | ||
| "allowUnicodeIdentifiers": false, | ||
| "disallowAdditionalPropertiesIfNotPresent": false, | ||
| "ensureUniqueParams": true, | ||
| "enumUnknownDefaultCase": false, | ||
| "gemAuthor": "OpenFGA", | ||
| "gemAuthorEmail": "contact@openfga.dev", | ||
| "gemHomepage": "https://openfga.dev", | ||
| "gemLicense": "Apache-2.0", | ||
| "gemMetadata": {}, | ||
| "gemName": "openfga", | ||
| "gemRequiredRubyVersion": ">=3.2", | ||
| "gemSummary": "This is an autogenerated ruby SDK for OpenFGA. It provides a wrapper around the [OpenFGA API definition](https://openfga.dev/api).", | ||
| "gemVersion": "0.0.1", | ||
| "hideGenerationTimestamp": true, | ||
| "library": "faraday", | ||
| "moduleName": "OpenFga", | ||
| "sortModelPropertiesByRequiredFlag": true, | ||
| "sortParamsByRequiredFlag": false, | ||
| "targetRubyVersion": "3.2", | ||
| "files": { | ||
| "api_model_base.mustache": { | ||
| "destinationFilename": "lib/openfga/api_model_base.rb", | ||
| "templateType": "SupportingFiles" | ||
| }, | ||
| "constants.mustache": { | ||
| "destinationFilename": "lib/openfga/constants.rb", | ||
| "templateType": "SupportingFiles" | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Find all config.overrides.json files for different language SDKs
find config/clients -name "config.overrides.json" -type f | head -20Repository: openfga/sdk-generator
Length of output: 316
🏁 Script executed:
# Check for fossaComplianceNoticeId in all config.overrides.json files
rg -A 2 "fossaComplianceNoticeId" config/clients/Repository: openfga/sdk-generator
Length of output: 1102
🏁 Script executed:
# Check Java config specifically
cat config/clients/java/config.overrides.json | rg -A 2 "fossaComplianceNoticeId"Repository: openfga/sdk-generator
Length of output: 47
Add missing FOSSA compliance notice ID.
The Ruby config is missing the fossaComplianceNoticeId field required by coding guidelines. Other language SDKs include this field (e.g., Python, JS, Go, Dotnet configs all have unique UUIDs). Please add a fossaComplianceNoticeId to maintain compliance.
🤖 Prompt for AI Agents
In `@config/clients/ruby/config.overrides.json` around lines 1 - 37, Add the
missing fossaComplianceNoticeId property to the JSON config by inserting a new
top-level key "fossaComplianceNoticeId" with a unique UUID string value (e.g.,
generate a new UUID v4) alongside the existing keys like "sdkId", "gemName", and
"moduleName"; ensure the key is placed at the same object level as the other
metadata fields and that the value is a quoted string so the JSON remains valid.
| "packageName": "openfga", | ||
| "packageVersion": "0.0.1", |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check base config version
echo "=== Base config version ==="
cat config/common/config.base.json | jq '.packageVersion // "not set"'
echo ""
echo "=== All language config.overrides.json versions ==="
# Find all config.overrides.json files and extract their packageVersion
fd "config.overrides.json" config/clients/ --exec sh -c 'echo "File: {}"; cat {} | jq ".packageVersion // \"not set\""; echo' \;Repository: openfga/sdk-generator
Length of output: 497
Clarify Ruby SDK version: 0.0.1 is significantly lower than other SDKs (0.7.3–0.9.9).
Base config does not define packageVersion, so there is no base version to enforce consistency. However, Ruby's version (0.0.1) is markedly different from other SDKs (Go: 0.7.3, JavaScript/dotnet: 0.9.0, Java: 0.9.3, Python: 0.9.9). Confirm whether this is intentional for a new Ruby SDK or if versioning should align with other SDKs.
🤖 Prompt for AI Agents
In `@config/clients/ruby/config.overrides.json` around lines 4 - 5, The Ruby
client override sets "packageVersion": "0.0.1" which is inconsistent with other
SDKs; confirm whether Ruby is intentionally starting at 0.0.1 for a new SDK or
update the override to match the project's standard SDK versioning (e.g., align
with 0.9.x used by other clients). If intentional, add a clarifying comment in
the override explaining why Ruby differs; otherwise change the "packageVersion"
for the packageName "openfga" to the agreed common version (e.g., 0.9.9) so it
matches the other SDKs.
| if %w[POST PATCH PUT DELETE].include?(http_method) | ||
| body_params = build_request_body(header_params, form_params, opts[:body]) | ||
| if config.debugging | ||
| config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n" | ||
| end | ||
| end |
There was a problem hiding this comment.
Bug: req_body is undefined — should be body_params.
Line 55 assigns the result of build_request_body to body_params, but line 57 logs req_body, which is not defined in this scope. This will raise a NameError at runtime whenever debugging is enabled for POST/PATCH/PUT/DELETE requests.
Compare with the Faraday partial (api_client_faraday_partial.mustache line 65-67) which correctly uses req_body consistently because it assigns to req_body on line 65.
🐛 Proposed fix
if %w[POST PATCH PUT DELETE].include?(http_method)
body_params = build_request_body(header_params, form_params, opts[:body])
if config.debugging
- config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
+ config.logger.debug "HTTP request body param ~BEGIN~\n#{body_params}\n~END~\n"
end
end📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if %w[POST PATCH PUT DELETE].include?(http_method) | |
| body_params = build_request_body(header_params, form_params, opts[:body]) | |
| if config.debugging | |
| config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n" | |
| end | |
| end | |
| if %w[POST PATCH PUT DELETE].include?(http_method) | |
| body_params = build_request_body(header_params, form_params, opts[:body]) | |
| if config.debugging | |
| config.logger.debug "HTTP request body param ~BEGIN~\n#{body_params}\n~END~\n" | |
| end | |
| end |
🤖 Prompt for AI Agents
In `@config/clients/ruby/template/api_client_httpx_partial.mustache` around lines
54 - 59, The debug log references an undefined variable req_body after assigning
the request payload to body_params; update the logging to use body_params (or
assign build_request_body to req_body instead) so the debug branch in the block
handling %w[POST PATCH PUT DELETE] uses the same variable that was created
(refer to build_request_body, body_params and the config.debugging logger call
in the api_client_httpx_partial.mustache template).
| header_params = @default_headers.merge(opts[:header_params] || {}) | ||
| query_params = opts[:query_params] || {} | ||
| form_params = opts[:form_params] || {} | ||
| follow_location = opts[:follow_location] || true |
There was a problem hiding this comment.
Bug: follow_location is always true — false can never be set.
opts[:follow_location] || true evaluates to true even when the option is explicitly set to false, because false || true is true. Use fetch with a default or an explicit nil check instead.
🐛 Proposed fix
- follow_location = opts[:follow_location] || true
+ follow_location = opts.fetch(:follow_location, true)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| follow_location = opts[:follow_location] || true | |
| follow_location = opts.fetch(:follow_location, true) |
🤖 Prompt for AI Agents
In `@config/clients/ruby/template/api_client_typhoeus_partial.mustache` at line
56, The follow_location option is incorrectly always true because the code uses
truthy-or (opts[:follow_location] || true) which forces false to true; change
the assignment for follow_location to use a proper default lookup such as using
opts.fetch(:follow_location, true) or checking for nil (opts.key?/nil? pattern)
so an explicit false in opts[:follow_location] is preserved; update the
assignment where follow_location is defined to use that pattern (referencing the
follow_location variable and opts hash in the template).
| @@ -0,0 +1,11 @@ | |||
| ### TLS/SSL setting | |||
| # You can use this to customize SSL Context settings (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html | |||
There was a problem hiding this comment.
Outdated Ruby documentation URL.
The link references ruby-doc.org/stdlib-2.5.1/... which is for Ruby 2.5.1 (EOL). Consider updating to a current Ruby version URL or the version-agnostic docs.ruby-lang.org equivalent.
🤖 Prompt for AI Agents
In `@config/clients/ruby/template/configuration_httpx_partial.mustache` at line 2,
Update the outdated Ruby docs link in configuration_httpx_partial.mustache (the
comment starting with "You can use this to customize SSL Context settings") to
point to a current, version-agnostic Ruby docs URL such as
https://docs.ruby-lang.org/en/ or the latest OpenSSL::SSL::SSLContext page on
docs.ruby-lang.org instead of the old ruby-doc.org/stdlib-2.5.1 path so the
comment references up-to-date documentation.
| s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? } | ||
| s.test_files = `find spec/*`.split("\n") |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
RubyGems s.test_files deprecated
💡 Result:
spec.test_files (or s.test_files) is effectively a legacy gemspec field: RubyGems keeps the attribute, but it’s no longer meaningfully used for “running tests on install” (the old gem install -t workflow was removed), so many projects simply stop setting it and instead control what’s packaged via spec.files. [2], [3]
What to do now
- Remove the
spec.test_files = ...line from your.gemspec. - If you don’t want tests shipped in the gem (common), exclude them from
spec.files, e.g. (typical Bundler template):
spec.files =git ls-files -z.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }[2] - If you do want tests shipped, just include them in
spec.files—test_filesdoesn’t buy you anything. [3]
Reference: RubyGems still documents test_files as an attribute on Gem::Specification, but that description reflects older behavior. [1]
Sources: [1] [2] [3]
🏁 Script executed:
# Get the full context of the gemspec.mustache file
cat -n config/clients/ruby/template/gemspec.mustache | head -50Repository: openfga/sdk-generator
Length of output: 2100
s.test_files is deprecated in RubyGems and should be removed.
The Gem::Specification#test_files= attribute is no longer used by RubyGems—the legacy gem install -t workflow was removed. Remove this line from the generated gemspec; test files are not shipped with the gem anyway.
Suggested fix
s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
- s.test_files = `find spec/*`.split("\n")
s.executables = []
s.require_paths = ["lib"]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? } | |
| s.test_files = `find spec/*`.split("\n") | |
| s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? } |
🤖 Prompt for AI Agents
In `@config/clients/ruby/template/gemspec.mustache` around lines 39 - 40, Remove
the deprecated assignment to s.test_files in the gemspec template: delete the
line that sets s.test_files (the `s.test_files = `find spec/*`.split("\n")`
entry) from config/clients/ruby/template/gemspec.mustache so the generated
gemspec no longer includes the obsolete attribute; leave the s.files line
unchanged.
|
|
||
| ### `openapi_discriminator_name` | ||
|
|
There was a problem hiding this comment.
Copy-paste bug: heading says openapi_discriminator_name but should be openapi_discriminator_mapping.
The section documents the mapping method (line 47 says "Returns the discriminator's mapping", line 54 calls .openapi_discriminator_mapping), but the heading on line 45 still reads openapi_discriminator_name.
Proposed fix
-### `openapi_discriminator_name`
+### `openapi_discriminator_mapping`📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ### `openapi_discriminator_name` | |
| ### `openapi_discriminator_mapping` | |
🤖 Prompt for AI Agents
In `@config/clients/ruby/template/partial_oneof_module_doc.mustache` around lines
44 - 46, The heading in the partial docs is incorrect: change the Markdown
heading text from `openapi_discriminator_name` to
`openapi_discriminator_mapping` so it matches the documented method
`.openapi_discriminator_mapping` and the description "Returns the
discriminator's mapping"; update the single-line heading at the top of that
section (the line currently showing ### `openapi_discriminator_name`) to ###
`openapi_discriminator_mapping`.
|
|
||
| Performs multiple relationship checks in a single batch request. | ||
|
|
||
| [API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/BatchCheck) |
There was a problem hiding this comment.
Hardcoded API doc URL — should use {{apiDocsUrl}} template variable.
Lines 362 and 473 hardcode https://openfga.dev/api/service while all other API documentation links in this file use the {{apiDocsUrl}} mustache variable. This inconsistency means these links won't adapt if the docs URL changes.
Proposed fix
Line 362:
-[API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/BatchCheck)
+[API Documentation]({{apiDocsUrl}}#/Relationship%20Queries/BatchCheck)Line 473:
-[API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/ListUsers)
+[API Documentation]({{apiDocsUrl}}#/Relationship%20Queries/ListUsers)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| [API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/BatchCheck) | |
| [API Documentation]({{apiDocsUrl}}#/Relationship%20Queries/BatchCheck) |
| [API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/BatchCheck) | |
| [API Documentation]({{apiDocsUrl}}#/Relationship%20Queries/ListUsers) |
🤖 Prompt for AI Agents
In `@config/clients/ruby/template/README_calling_api.mustache` at line 362,
Replace the two hardcoded API doc URLs "https://openfga.dev/api/service" in the
README_calling_api.mustache template (the links that render as "[API
Documentation](https://openfga.dev/api/service#/Relationship%20Queries/BatchCheck)"
and the other occurrence) with the mustache variable {{apiDocsUrl}} so the links
become dynamic; locate the literal string "https://openfga.dev/api/service" in
the file and swap it for {{apiDocsUrl}} while keeping the fragment/path (e.g.,
`#/Relationship`%20Queries/BatchCheck) intact.
| To install: | ||
|
|
||
| ``` | ||
| gem install openfga | ||
| ``` | ||
|
|
||
| Alternatively, you can add it to your `Gemfile`: | ||
|
|
||
| ``` | ||
| gem 'openfga' | ||
| ``` | ||
|
|
||
| Then run `bundle install` to install the gem. | ||
|
|
||
| To use in your code, require the gem and create the configuration: | ||
|
|
||
| ``` | ||
| require 'openfga' | ||
|
|
||
| sdk_config = { | ||
| api_url: 'http://localhost:8080' | ||
| } | ||
| ``` |
There was a problem hiding this comment.
Hardcoded gem name — use {{{gemName}}} for consistency with other templates.
Lines 4, 10, and 18 hardcode openfga instead of using the {{{gemName}}} mustache variable. Other templates in this PR (e.g., partial_oneof_module_doc.mustache) use {{{gemName}}} so the gem name stays in sync with the generator configuration.
Proposed fix
To install:
-gem install openfga
+gem install {{{gemName}}}
Alternatively, you can add it to your `Gemfile`:
-gem 'openfga'
+gem '{{{gemName}}}'
Then run `bundle install` to install the gem.
To use in your code, require the gem and create the configuration:
-require 'openfga'
+require '{{{gemName}}}'
sdk_config = {
api_url: 'http://localhost:8080'
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| To install: | |
| ``` | |
| gem install openfga | |
| ``` | |
| Alternatively, you can add it to your `Gemfile`: | |
| ``` | |
| gem 'openfga' | |
| ``` | |
| Then run `bundle install` to install the gem. | |
| To use in your code, require the gem and create the configuration: | |
| ``` | |
| require 'openfga' | |
| sdk_config = { | |
| api_url: 'http://localhost:8080' | |
| } | |
| ``` | |
| To install: | |
🤖 Prompt for AI Agents
In `@config/clients/ruby/template/README_installation.mustache` around lines 1 -
23, Replace the hardcoded gem name "openfga" in README_installation.mustache
with the mustache variable {{{gemName}}}; specifically update the three
occurrences (the `gem install ...` line, the `gem '...'` entry in the Gemfile
example, and the `require '...'` line) to use {{{gemName}}} so the generated
README stays in sync with the generator configuration.
There was a problem hiding this comment.
Pull request overview
This PR adds the Ruby client generation scaffolding to the OpenFGA SDK Generator, including Ruby-specific OpenAPI Generator templates, configuration overrides, and Makefile targets to build/test the Ruby SDK output.
Changes:
- Introduces a full set of Ruby OpenAPI Generator templates (models, APIs, client/config, docs).
- Adds Ruby client configuration overrides and generator metadata for the build system.
- Adds Makefile targets to build/test the Ruby client.
Reviewed changes
Copilot reviewed 39 out of 42 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
Makefile |
Adds build-client-ruby / test-client-ruby targets. |
config/clients/ruby/.openapi-generator-ignore |
Adds Ruby-specific ignore patterns for generated output. |
config/clients/ruby/config.overrides.json |
Defines Ruby SDK metadata (gem/package/module naming, versions, library choice, custom supporting files). |
config/clients/ruby/template-source.json |
Declares the upstream generator/template source reference for Ruby. |
config/clients/ruby/template/api.mustache |
Ruby API class template for operations. |
config/clients/ruby/template/api_client.mustache |
Ruby API client entry template and shared helpers (deserialize/auth/header selection). |
config/clients/ruby/template/api_client_faraday_partial.mustache |
Faraday transport implementation for API calls and file handling. |
config/clients/ruby/template/api_client_httpx_partial.mustache |
HTTPX transport implementation for API calls and file handling. |
config/clients/ruby/template/api_client_typhoeus_partial.mustache |
Typhoeus transport implementation for API calls and file handling. |
config/clients/ruby/template/api_doc.mustache |
Markdown API docs template. |
config/clients/ruby/template/api_error.mustache |
Ruby exception type template for API errors. |
config/clients/ruby/template/api_info.mustache |
Shared API info banner included into generated files. |
config/clients/ruby/template/api_model_base.mustache |
Base model helpers (deserialize/to_hash helpers) for generated models. |
config/clients/ruby/template/api_test.mustache |
RSpec API test template (generated scaffolding). |
config/clients/ruby/template/base_object.mustache |
Shared model build/to_hash logic inserted into model classes. |
config/clients/ruby/template/configuration.mustache |
SDK configuration object template (auth, servers, transport-specific settings). |
config/clients/ruby/template/configuration_faraday_partial.mustache |
Faraday-specific configuration attributes. |
config/clients/ruby/template/configuration_httpx_partial.mustache |
HTTPX-specific configuration attributes. |
config/clients/ruby/template/configuration_typhoeus_partial.mustache |
Typhoeus-specific configuration attributes. |
config/clients/ruby/template/constants.mustache |
OpenFGA Ruby SDK constants (SDK_VERSION, USER_AGENT, defaults, retry/timeouts). |
config/clients/ruby/template/gem.mustache |
Gem entrypoint requiring generated components and providing .configure. |
config/clients/ruby/template/gemspec.mustache |
Gem specification template (deps, metadata, required Ruby version). |
config/clients/ruby/template/gitignore_custom.mustache |
Custom gitignore hook (currently empty). |
config/clients/ruby/template/model.mustache |
Ruby model file template wiring enums/oneOf/anyOf/generic models. |
config/clients/ruby/template/model_doc.mustache |
Model documentation dispatch template (oneOf vs generic). |
config/clients/ruby/template/model_test.mustache |
RSpec model test template (generated scaffolding). |
config/clients/ruby/template/partial_anyof_module.mustache |
anyOf helper module template (type matching/casting). |
config/clients/ruby/template/partial_header.mustache |
Header banner template for generated Ruby files. |
config/clients/ruby/template/partial_model_enum_class.mustache |
Enum class template. |
config/clients/ruby/template/partial_model_generic.mustache |
Generic model class template (attrs, validation, serialization hooks). |
config/clients/ruby/template/partial_model_generic_doc.mustache |
Generic model markdown doc template. |
config/clients/ruby/template/partial_oneof_module.mustache |
oneOf helper module template (discriminator + type matching/casting). |
config/clients/ruby/template/partial_oneof_module_doc.mustache |
oneOf module markdown doc template. |
config/clients/ruby/template/README_api_endpoints.mustache |
README section template listing endpoints. |
config/clients/ruby/template/README_calling_api.mustache |
README content template with Ruby examples for calling APIs. |
config/clients/ruby/template/README_custom_badges.mustache |
README badges hook (currently empty). |
config/clients/ruby/template/README_initializing.mustache |
README content template for SDK initialization patterns. |
config/clients/ruby/template/README_installation.mustache |
README content template for gem installation. |
config/clients/ruby/template/README_license_disclaimer.mustache |
README license disclaimer hook (currently empty). |
config/clients/ruby/template/README_models.mustache |
README section template listing models. |
config/clients/ruby/template/Rakefile.mustache |
Rake tasks template for running specs. |
config/clients/ruby/template/version.mustache |
Version file template exposing {{moduleName}}::VERSION. |
| # Attribute type mapping. | ||
| def self.openapi_types | ||
| { | ||
| {{#vars}} | ||
| :'{{{name}}}' => :'{{{dataType}}}'{{^-last}},{{/-last}} | ||
| {{/vars}} | ||
| } | ||
| end |
There was a problem hiding this comment.
For models with a parent, openapi_types only includes the current class' fields, but build_from_hash iterates openapi_types. This will prevent parent properties from being deserialized into subclasses. Consider merging superclass.openapi_types when parent is present.
| "gemName": "openfga", | ||
| "gemRequiredRubyVersion": ">=3.2", | ||
| "gemSummary": "This is an autogenerated ruby SDK for OpenFGA. It provides a wrapper around the [OpenFGA API definition](https://openfga.dev/api).", | ||
| "gemVersion": "0.0.1", |
There was a problem hiding this comment.
Version is defined in two separate fields (packageVersion and gemVersion). Because they must be kept in sync manually, it's easy to accidentally publish a gem whose VERSION differs from the SDK version constant. Prefer deriving one from the other (or using a single version field consistently in templates).
| "gemVersion": "0.0.1", |
| .github/ISSUE_TEMPLATE/bug_report.yaml | ||
| .github/ISSUE_TEMPLATE/feature_request.yaml | ||
| .github/ISSUE_TEMPLATE/config.yaml | ||
| Rakefile |
There was a problem hiding this comment.
The Rakefile pattern has a trailing space, so it won't match Rakefile and will fail to ignore it. Remove the trailing whitespace.
| Rakefile | |
| Rakefile |
| header_params = @default_headers.merge(opts[:header_params] || {}) | ||
| query_params = opts[:query_params] || {} | ||
| form_params = opts[:form_params] || {} | ||
| follow_location = opts[:follow_location] || true |
There was a problem hiding this comment.
follow_location = opts[:follow_location] || true will always evaluate to true, so callers cannot disable redirects. Use an explicit key check (or nil-coalescing) so passing false is honored.
| follow_location = opts[:follow_location] || true | |
| follow_location = opts.key?(:follow_location) ? opts[:follow_location] : true |
| if %w[POST PATCH PUT DELETE].include?(http_method) | ||
| body_params = build_request_body(header_params, form_params, opts[:body]) | ||
| if config.debugging | ||
| config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n" |
There was a problem hiding this comment.
req_body is referenced in the debug log but is never defined in this method; enabling debugging for POST/PATCH/PUT/DELETE will raise a NameError. Log the actual request body (or the computed body params) using the correct variable name.
| config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n" | |
| config.logger.debug "HTTP request body param ~BEGIN~\n#{body_params}\n~END~\n" |
| return value if {{classname}}.all_vars.include?(value) | ||
| raise "Invalid ENUM value #{value} for class #{{{classname}}}" | ||
| end |
There was a problem hiding this comment.
The error string uses #{{{classname}}}, which will render as a literal like #Pet instead of interpolating the class name. Update the message to include the class name correctly (without the stray #, or via Ruby interpolation).
| # Attribute mapping from ruby-style variable name to JSON key. | ||
| def self.attribute_map | ||
| { | ||
| {{#vars}} | ||
| :'{{{name}}}' => :'{{{baseName}}}'{{^-last}},{{/-last}} | ||
| {{/vars}} | ||
| } | ||
| end |
There was a problem hiding this comment.
For models with a parent, attribute_map only includes the current class' fields, but build_from_hash/to_hash rely on attribute_map. This will drop parent properties during serialization/deserialization. Consider merging superclass.attribute_map when parent is present (similar to acceptable_attribute_map).
| # ... any other custom build steps ... | ||
|
|
||
| .PHONY: test-client-ruby | ||
| test-client-ruby: build-client-ruby | ||
| # ... any custom test code ... |
There was a problem hiding this comment.
The Makefile target still contains placeholder comments (# ... any other custom build steps ... / # ... any custom test code ...). If no extra steps are needed, remove these; if they are intended TODOs, consider adding concrete steps or a tracked issue reference so the target doesn't look incomplete.
| # ... any other custom build steps ... | |
| .PHONY: test-client-ruby | |
| test-client-ruby: build-client-ruby | |
| # ... any custom test code ... | |
| .PHONY: test-client-ruby | |
| test-client-ruby: build-client-ruby |
| .rspec | ||
| .rubocop.yml | ||
| .travis.yml | ||
| .gitlab-ci.yml | ||
| git_push.sh | ||
| .github/CODEOWNERS | ||
| .github/ISSUE_TEMPLATE/bug_report.yaml | ||
| .github/ISSUE_TEMPLATE/feature_request.yaml | ||
| .github/ISSUE_TEMPLATE/config.yaml | ||
| Rakefile |
There was a problem hiding this comment.
Lines contain trailing spaces (e.g., ".rspec ", ".travis.yml "), which become part of the ignore pattern and will prevent openapi-generator from ignoring the intended files. Remove the trailing whitespace so the patterns match the actual filenames.
| .rspec | |
| .rubocop.yml | |
| .travis.yml | |
| .gitlab-ci.yml | |
| git_push.sh | |
| .github/CODEOWNERS | |
| .github/ISSUE_TEMPLATE/bug_report.yaml | |
| .github/ISSUE_TEMPLATE/feature_request.yaml | |
| .github/ISSUE_TEMPLATE/config.yaml | |
| Rakefile | |
| .rspec | |
| .rubocop.yml | |
| .travis.yml | |
| .gitlab-ci.yml | |
| git_push.sh | |
| .github/CODEOWNERS | |
| .github/ISSUE_TEMPLATE/bug_report.yaml | |
| .github/ISSUE_TEMPLATE/feature_request.yaml | |
| .github/ISSUE_TEMPLATE/config.yaml | |
| Rakefile |
Description
What problem is being solved?
This is the required Ruby SDK client generation setup, including:
Everything else to be produced and managed inside the SDK repo itself: https://github.com/carlastabile/openfga-ruby-sdk
References
Review Checklist
mainSummary by CodeRabbit
Release Notes