Skip to content

fix: camelCase path params, double path-prefix, nested body exclusion#230

Open
george-oakling wants to merge 1 commit intosudorandom:mainfrom
george-oakling:fix/googleapi-camelcase-path-params-and-double-prefix
Open

fix: camelCase path params, double path-prefix, nested body exclusion#230
george-oakling wants to merge 1 commit intosudorandom:mainfrom
george-oakling:fix/googleapi-camelcase-path-params-and-double-prefix

Conversation

@george-oakling
Copy link
Copy Markdown
Contributor

@george-oakling george-oakling commented Feb 26, 2026

Summary

Three fixes for google.api.http OpenAPI generation:

  • Path parameters now use camelCase (JSON names) by default instead of snake_case proto field names. For example, {account_id} becomes {accountId} in both the path template and parameter name. The with-proto-names option is respected to keep snake_case when needed.
  • Fix double path-prefix for additional_bindings. The prefix was applied both inside httpRuleToPathMap (for additional bindings only) and in the central addPathItem handler, resulting in doubled prefixes like /api/node/api/node/....
  • Fix nested path params not excluding the top-level field from request body. When a path parameter references a nested field (e.g., source_public_id.value), the top-level field (source_public_id) was not tracked, so it was not excluded from the body: "*" request body schema.

Changes

  • googleapi/paths.go: Build a paramRenames map (proto name → camelCase display name) during path parameter resolution; pass it to partsToOpenAPIPath so URL templates also use camelCase; track top-level fields for nested path params; remove redundant util.MakePath() call on additional bindings (fixes double prefix).
  • googleapi/paths_test.go: 4 new unit tests for partsToOpenAPIPath with rename map.
  • New test protos: googleapi_camelcase_params.proto, googleapi_nested_body.proto, additional_bindings_prefix.proto.
  • Updated golden files to reflect camelCase path params and nested field exclusion.

Rebased on current main (includes #233, #234, #239). Updated path_params golden files from #234 to reflect camelCase conversion.

Test plan

  • New unit tests for partsToOpenAPIPath with rename map (4 tests)
  • New integration test googleapi_camelcase_params.proto — camelCase path and query params
  • New integration test googleapi_nested_body.proto — nested path param body exclusion
  • New integration test scenario additional_bindings_prefix with path-prefix=/api/v1 — no double prefix
  • Existing proto_names scenario confirms with-proto-names still produces snake_case
  • All existing tests pass with updated snapshots

🤖 Generated with Claude Code

… 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>
@george-oakling george-oakling force-pushed the fix/googleapi-camelcase-path-params-and-double-prefix branch from 104efbd to 9171f1c Compare March 31, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant