fix: camelCase path params, double path-prefix, nested body exclusion#230
Open
george-oakling wants to merge 1 commit intosudorandom:mainfrom
Open
Conversation
… path-prefix
Three fixes for google.api.http OpenAPI generation:
1. Path parameters now use camelCase (JSON names) by default instead of
snake_case proto field names. E.g., {account_id} becomes {accountId}.
Respects the with-proto-names option to keep snake_case when needed.
2. Fix double path-prefix application for additional_bindings. The prefix
was applied both in httpRuleToPathMap and in the central addPathItem
handler, causing paths like /api/node/api/node/....
3. Fix nested path params (e.g., source_public_id.value) not tracking the
top-level field, which caused the parent field to not be excluded from
the request body when body: "*" was used.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
104efbd to
9171f1c
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Three fixes for
google.api.httpOpenAPI generation:{account_id}becomes{accountId}in both the path template and parameter name. Thewith-proto-namesoption is respected to keep snake_case when needed.additional_bindings. The prefix was applied both insidehttpRuleToPathMap(for additional bindings only) and in the centraladdPathItemhandler, resulting in doubled prefixes like/api/node/api/node/....source_public_id.value), the top-level field (source_public_id) was not tracked, so it was not excluded from thebody: "*"request body schema.Changes
googleapi/paths.go: Build aparamRenamesmap (proto name → camelCase display name) during path parameter resolution; pass it topartsToOpenAPIPathso URL templates also use camelCase; track top-level fields for nested path params; remove redundantutil.MakePath()call on additional bindings (fixes double prefix).googleapi/paths_test.go: 4 new unit tests forpartsToOpenAPIPathwith rename map.googleapi_camelcase_params.proto,googleapi_nested_body.proto,additional_bindings_prefix.proto.Rebased on current
main(includes #233, #234, #239). Updatedpath_paramsgolden files from #234 to reflect camelCase conversion.Test plan
partsToOpenAPIPathwith rename map (4 tests)googleapi_camelcase_params.proto— camelCase path and query paramsgoogleapi_nested_body.proto— nested path param body exclusionadditional_bindings_prefixwithpath-prefix=/api/v1— no double prefixproto_namesscenario confirmswith-proto-namesstill produces snake_case🤖 Generated with Claude Code