[ruby-nextgen] Expose nested resources through clients - #25002
axelray-dev wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
1 issue found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/test/java/org/openapitools/codegen/rubynextgen/RubyNextgenClientCodegenTest.java">
<violation number="1" location="modules/openapi-generator/src/test/java/org/openapitools/codegen/rubynextgen/RubyNextgenClientCodegenTest.java:416">
P3: The test's stated purpose is verifying nested resources are reachable from the client, but for the namespace-only case it only checks the generated namespace file (api/only.rb) and never asserts that client.rb exposes the namespace (e.g. "def only"). Add an assertFileContains(client.rb, "def only") so the end-to-end client accessor for the namespace-only namespace is actually covered.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| .toClientOptInput(); | ||
| new org.openapitools.codegen.DefaultGenerator(false).opts(input).generate(); | ||
|
|
||
| org.openapitools.codegen.TestUtils.assertFileContains( |
There was a problem hiding this comment.
P3: The test's stated purpose is verifying nested resources are reachable from the client, but for the namespace-only case it only checks the generated namespace file (api/only.rb) and never asserts that client.rb exposes the namespace (e.g. "def only"). Add an assertFileContains(client.rb, "def only") so the end-to-end client accessor for the namespace-only namespace is actually covered.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/test/java/org/openapitools/codegen/rubynextgen/RubyNextgenClientCodegenTest.java, line 416:
<comment>The test's stated purpose is verifying nested resources are reachable from the client, but for the namespace-only case it only checks the generated namespace file (api/only.rb) and never asserts that client.rb exposes the namespace (e.g. "def only"). Add an assertFileContains(client.rb, "def only") so the end-to-end client accessor for the namespace-only namespace is actually covered.</comment>
<file context>
@@ -398,4 +398,36 @@ public void testAcronymModelsGetZeitwerkInflections() throws Exception {
+ .toClientOptInput();
+ new org.openapitools.codegen.DefaultGenerator(false).opts(input).generate();
+
+ org.openapitools.codegen.TestUtils.assertFileContains(
+ target.resolve("lib/petstore/client.rb"), "def stables", "Petstore::Api::Stables.new");
+ org.openapitools.codegen.TestUtils.assertFileContains(
</file context>
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyNextgenClientCodegen.java">
<violation number="1" location="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyNextgenClientCodegen.java:774">
P1: Renaming a resource accessor here also changes the value later used as its Zeitwerk inflection key, but the resource file keeps the raw route basename. Keep the resource filename separate from its client method name and generate inflections from the raw basename, otherwise acronym resources can fail to autoload after a collision rename.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| Map<String, Object> rm = new HashMap<>(); | ||
| rm.put("accessor", underscore(sanitizeName(res.replace('-', '_')))); | ||
| String resourceAccessor = underscore(sanitizeName(res.replace('-', '_'))); | ||
| rm.put("accessor", safeResourceAccessorName(resourceAccessor, reservedNames)); |
There was a problem hiding this comment.
P1: Renaming a resource accessor here also changes the value later used as its Zeitwerk inflection key, but the resource file keeps the raw route basename. Keep the resource filename separate from its client method name and generate inflections from the raw basename, otherwise acronym resources can fail to autoload after a collision rename.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyNextgenClientCodegen.java, line 774:
<comment>Renaming a resource accessor here also changes the value later used as its Zeitwerk inflection key, but the resource file keeps the raw route basename. Keep the resource filename separate from its client method name and generate inflections from the raw basename, otherwise acronym resources can fail to autoload after a collision rename.</comment>
<file context>
@@ -753,9 +766,12 @@ public Map<String, Object> postProcessSupportingFileData(Map<String, Object> obj
Map<String, Object> rm = new HashMap<>();
- rm.put("accessor", underscore(sanitizeName(res.replace('-', '_'))));
+ String resourceAccessor = underscore(sanitizeName(res.replace('-', '_')));
+ rm.put("accessor", safeResourceAccessorName(resourceAccessor, reservedNames));
rm.put("className", toApiName(e.getKey() + "/" + res));
resources.add(rm);
</file context>
|
Addressed the current review findings in a445f4a. Namespace-only output now follows the first actually generated nested resource, resource accessors avoid initialize and direct-operation collisions, and generated metadata continues to derive from the processed operation set. git diff --check passed on the VPS; Java and Maven are not installed there, so CI is the authoritative generator test. Please re-review the new head. |
|
thanks for the PR. please review the build failure when you've time. cc @n-rodriguez (author of ruby-nextgen) |
Fixes #24999
Summary
Expose nested Ruby-nextgen resource clients through their namespace clients. This makes paths such as
client.store.orderavailable to callers and also generates a concrete namespace class when a namespace only contains nested resources, so Zeitwerk can load the generated files correctly.The change adds regression coverage for direct and namespace-only nested resources, including multiple child resources, and updates the Petstore sample to expose
client.store.order.Validation
node0throughnode3passed.git diff --checkpassed.