fix(php,csharp): order parameters with default values after required parameters#16005
fix(php,csharp): order parameters with default values after required parameters#16005davidkonigsberg wants to merge 6 commits into
Conversation
Co-Authored-By: David Konigsberg <davidakonigsberg@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
Root-level path parameters (e.g. from x-fern-base-path) may have default values, making them optional in the generated method signature. The dynamic snippets generator now places these args after the body argument to match the Method.ts parameter reordering (required before defaulted). Co-Authored-By: David Konigsberg <davidakonigsberg@gmail.com>
Apply the same fix as PHP to C# dynamic snippets: root-level path parameters (from x-fern-base-path with defaults) are placed after the body argument to match AbstractEndpointGenerator parameter ordering. Also fixes biome formatting in PHP dynamic snippets. Co-Authored-By: David Konigsberg <davidakonigsberg@gmail.com>
Co-Authored-By: David Konigsberg <davidakonigsberg@gmail.com>
…rrors Co-Authored-By: David Konigsberg <davidakonigsberg@gmail.com>
Co-Authored-By: David Konigsberg <davidakonigsberg@gmail.com>
Description
Refs #15998
PR #15998 (
feat(openapi): Add better support for x-fern-base-path) introduced path parameters withclientDefaultvalues (e.g.apiVersion = 'v1beta'). This caused two issues:Required parameter $request follows optional parameter $apiVersionChanges Made
generators/php/codegen/src/ast/Method.ts: Updated parameter ordering logic to also treat parameters with aninitializer(default value) as optional, placing them after required parameters in the generated method signaturegenerators/php/dynamic-snippets/src/EndpointSnippetGenerator.ts: Separated root-level path parameters (which may have defaults fromx-fern-base-path) from endpoint-specific path parameters, placing root-level params after the body argument to match the corrected method signature orderinggenerators/csharp/dynamic-snippets/src/EndpointSnippetGenerator.ts: Applied the same root/endpoint path parameter separation for bothgetMethodArgsForBodyRequestandgetMethodArgsForInlinedRequest, matchingAbstractEndpointGenerator's ordering of[...requiredPathParams, requestParam, ...optionalPathParams]php-sdkandcsharp-sdkapi-wide-base-path-with-defaultfixturesTesting
php-sdk --fixture api-wide-base-path-with-defaultpassescsharp-sdk --fixture api-wide-base-path-with-defaultpassescreate(Widget $request, string $apiVersion = 'v1beta', ?array $options = null)CreateAsync(new Widget { Name = "name" }, "v1beta")create(new Widget([...]), 'v1beta')Link to Devin session: https://app.devin.ai/sessions/8c891e927684448ea73ec4c26f9cd87a
Requested by: @davidkonigsberg