-
Notifications
You must be signed in to change notification settings - Fork 335
feat(ruby): let the caller omit an optional request body #17379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
willkendall01
merged 8 commits into
main
from
devin/1786483082-ruby-respect-optional-request-body
Aug 13, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7a828c1
feat(ruby): let the caller omit an optional request body
devin-ai-integration[bot] 805e8e1
fix(ruby): keep form-encoded bodies out of the optional-body handling
devin-ai-integration[bot] c3f666a
chore(ruby): pin the IR SDKs to the version carrying request-body omi…
devin-ai-integration[bot] bb38d5b
chore: update the lockfile for the published IR packages
devin-ai-integration[bot] cbcc541
chore(ruby): keep dynamic snippet and wire test types compatible with…
willkendall01 6414631
chore: retrigger CI
willkendall01 f1961d4
fix(ruby): exclude path parameters when checking for an empty referen…
willkendall01 c75ae46
chore(ruby): drop the trailing blank line biome flags
willkendall01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
58 changes: 58 additions & 0 deletions
58
generators/ruby-v2/dynamic-snippets/src/__test__/OptionalRequestBody.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { FernIr } from "@fern-api/dynamic-ir-sdk"; | ||
| import { AbsoluteFilePath, join } from "@fern-api/path-utils"; | ||
|
|
||
| import { buildDynamicSnippetsGenerator } from "./utils/buildDynamicSnippetsGenerator.js"; | ||
| import { buildGeneratorConfig } from "./utils/buildGeneratorConfig.js"; | ||
|
|
||
| const DYNAMIC_IR_TEST_DEFINITIONS_DIRECTORY = AbsoluteFilePath.of( | ||
| `${__dirname}/../../../../../packages/cli/generation/ir-generator-tests/src/dynamic-snippets/__test__/test-definitions` | ||
| ); | ||
|
|
||
| const IR_FILEPATH = AbsoluteFilePath.of( | ||
| join(DYNAMIC_IR_TEST_DEFINITIONS_DIRECTORY, "respect-optional-request-body.json") | ||
| ); | ||
|
|
||
| // `bulkRefund` takes a body the API does not require, so an example that supplies nothing for it | ||
| // reaches the snippet generator either as no body at all or as an empty one. | ||
| const bulkRefundWithoutBody: FernIr.dynamic.EndpointSnippetRequest = { | ||
| endpoint: { | ||
| method: "POST", | ||
| path: "/refunds" | ||
| }, | ||
| baseURL: undefined, | ||
| environment: undefined, | ||
| auth: undefined, | ||
| pathParameters: undefined, | ||
| queryParameters: undefined, | ||
| headers: undefined, | ||
| requestBody: undefined | ||
| }; | ||
|
|
||
| describe("optional request body", () => { | ||
| it("omits the body arguments once the generator opts in", async () => { | ||
| const generator = buildDynamicSnippetsGenerator({ | ||
| irFilepath: IR_FILEPATH, | ||
| config: buildGeneratorConfig({ customConfig: { respectOptionalRequestBody: true } }) | ||
| }); | ||
|
|
||
| for (const requestBody of [undefined, {}]) { | ||
| const response = await generator.generate({ ...bulkRefundWithoutBody, requestBody }); | ||
|
|
||
| expect(response.errors).toBeUndefined(); | ||
| expect(response.snippet).toContain("client.bulk_refund"); | ||
| expect(response.snippet).not.toContain("amount"); | ||
| } | ||
| }); | ||
|
|
||
| it("keeps passing a supplied body", async () => { | ||
| const generator = buildDynamicSnippetsGenerator({ | ||
| irFilepath: IR_FILEPATH, | ||
| config: buildGeneratorConfig({ customConfig: { respectOptionalRequestBody: true } }) | ||
| }); | ||
|
|
||
| const response = await generator.generate({ ...bulkRefundWithoutBody, requestBody: { amount: 60 } }); | ||
|
|
||
| expect(response.errors).toBeUndefined(); | ||
| expect(response.snippet).toContain("amount: 60"); | ||
| }); | ||
| }); |
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
5 changes: 5 additions & 0 deletions
5
generators/ruby-v2/sdk/changes/unreleased/exclude-path-params-from-referenced-body.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| - summary: | | ||
| Endpoints whose request body is a referenced type no longer serialize path parameters into | ||
| the JSON body. With `respectOptionalRequestBody`, an omitted optional body on such an endpoint | ||
| now sends no body and no `Content-Type` instead of a body containing the path parameters. | ||
| type: fix |
6 changes: 6 additions & 0 deletions
6
generators/ruby-v2/sdk/changes/unreleased/respect-optional-request-body.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| - summary: | | ||
| Add the `respectOptionalRequestBody` configuration option. When enabled, an endpoint whose | ||
| request body the API does not require lets callers omit the body: the request then carries | ||
| neither a body nor a `Content-Type` header, instead of sending `{}` as `application/json`. | ||
| Disabled by default. | ||
| type: feat |
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.