Skip to content

Conversation

@xerial
Copy link
Member

@xerial xerial commented Jan 12, 2026

For REST endpoints (non-RPC) with a single non-primitive body parameter (unary endpoint calls),
the OpenAPI request body schema now directly references the parameter type instead of wrapping
it in an object with properties. This makes the OpenAPI spec consistent with how the server
actually handles requests - the request body is mapped directly to the parameter.

This fix aligns the OpenAPI generator behavior with:

  • HttpRequestMapper which maps the entire request body to a single parameter for REST endpoints
  • HttpClientIR which generates client code that passes the parameter directly for unary calls

@github-actions github-actions bot added the bug label Jan 12, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @xerial, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an inconsistency in the OpenAPI generator where REST endpoints with a single complex body parameter were incorrectly represented. The fix ensures that the generated OpenAPI schema accurately reflects the expected request body structure, improving the fidelity of the API documentation and client code generation.

Highlights

  • OpenAPI Schema Generation Fix: The OpenAPI generator now correctly handles REST endpoints that accept a single, non-primitive body parameter. Previously, the schema for such endpoints would incorrectly wrap the parameter type within an object.
  • Direct Parameter Type Referencing: For these 'unary endpoint calls' (REST, single non-primitive parameter), the OpenAPI request body schema now directly references the parameter's type, aligning with how the server processes requests.
  • Consistency with Server and Client: This change ensures the generated OpenAPI specification is consistent with HttpRequestMapper (server-side request handling) and HttpClientIR (client-side code generation), which both expect the parameter directly.
  • Updated Test Cases: Test cases for OpenAPI generation have been updated to reflect the new, correct schema output for unary endpoint calls, specifically for the /v1/post5 endpoint.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly adjusts the OpenAPI generator to handle REST endpoints with a single complex parameter. Instead of wrapping the parameter in an object, the schema now directly references the parameter's type, which aligns with the server's behavior. The logic change is sound and is supported by corresponding test updates. I've added one suggestion to refactor the logic for detecting this specific case to be more concise and idiomatic using Scala's pattern matching.

Comment on lines 268 to 273
val primitiveOnlyInputs =
routeAnalysis.httpClientCallInputs.nonEmpty && routeAnalysis.httpClientCallInputs.forall(x =>
isPrimitive(x.surface)
)
val isUnaryEndpointCall =
!route.isRPC && routeAnalysis.httpClientCallInputs.size == 1 && !primitiveOnlyInputs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic to determine isUnaryEndpointCall can be simplified and made more idiomatic using pattern matching on httpClientCallInputs. This would make the intent clearer by directly checking for a single, non-primitive parameter, and removes the need for the intermediate primitiveOnlyInputs variable.

Suggested change
val primitiveOnlyInputs =
routeAnalysis.httpClientCallInputs.nonEmpty && routeAnalysis.httpClientCallInputs.forall(x =>
isPrimitive(x.surface)
)
val isUnaryEndpointCall =
!route.isRPC && routeAnalysis.httpClientCallInputs.size == 1 && !primitiveOnlyInputs
val isUnaryEndpointCall = !route.isRPC && (routeAnalysis.httpClientCallInputs match {
case Seq(p) => !isPrimitive(p.surface)
case _ => false
})

@xerial xerial force-pushed the claude/fix-openapi-rest-bug-bkAV0 branch from f47f9b9 to 18ea6ee Compare January 12, 2026 17:43
…le complex parameter

For REST endpoints (non-RPC) with a single non-primitive body parameter (unary endpoint calls),
the OpenAPI request body schema now directly references the parameter type instead of wrapping
it in an object with properties. This makes the OpenAPI spec consistent with how the server
actually handles requests - the request body is mapped directly to the parameter.

This fix aligns the OpenAPI generator behavior with:
- HttpRequestMapper which maps the entire request body to a single parameter for REST endpoints
- HttpClientIR which generates client code that passes the parameter directly for unary calls
@xerial xerial force-pushed the claude/fix-openapi-rest-bug-bkAV0 branch from 18ea6ee to e56860e Compare January 12, 2026 17:48
@xerial xerial merged commit c08eb81 into main Jan 12, 2026
23 checks passed
@xerial xerial deleted the claude/fix-openapi-rest-bug-bkAV0 branch January 12, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants