Skip to content

feat(generator): harden opaque imports and fix snake case to go casing#6279

Merged
johanbrandhorst merged 8 commits intogrpc-ecosystem:mainfrom
kellen-miller:fix-opaque-missing-imports-casing
Jan 26, 2026
Merged

feat(generator): harden opaque imports and fix snake case to go casing#6279
johanbrandhorst merged 8 commits intogrpc-ecosystem:mainfrom
kellen-miller:fix-opaque-missing-imports-casing

Conversation

@kellen-miller
Copy link
Copy Markdown
Contributor

References to other Issues or PRs

Have you read the Contributing Guidelines?

Yes

Brief description of what is fixed or changed

  • Register the Go packages that define nested body messages so opaque handlers (--use_opaque_api) import the modules
    they instantiate.
  • Camel-case every identifier produced by descriptor.Message.GoType / Enum.GoType, ensuring proto names such as
    Create_book resolve to valid Go identifiers.
  • Add exercised examples under examples/internal/proto/examplepb (opaque import with snake_case service/RPC names) and
    examples/internal/proto/sub (snake-case messages) so go test ./... guards both regressions without generator-only
    unit tests.

Other comments

  • go build ./...
  • go test ./...

[WHY] Opaque handlers were missing imports for nested body types and
snake_case messages/enums produced invalid Go identifiers, causing
broken builds when `--use_opaque_api` was enabled.

[WHAT] Camel-case message/enum GoType helpers, register body-field
packages during generation, and add example protos under
`examples/internal/proto/examplepb` (opaque import + snake-case
service/RPC names) and `examples/internal/proto/sub` (snake-case type) so
`go test ./...` guards the regressions without extra generator-only
tests.

[HOW] Relocated the opaque example, regenerated it against the opaque
API, extended the gateway generator to track external body packages, and
leaned on the compiled examples instead of bespoke generator tests.

[TEST] go test ./...
[RISK] Low; scoped to generators/examples.

Fixes grpc-ecosystem#6276, grpc-ecosystem#6277
Copy link
Copy Markdown
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

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

This looks great, just looks like some of the Bazel files need a small fix, thank you!

…update message references

- Introduced `OpaquePatchProductNameRequest` and `OpaquePatchProductNameResponse` types to the example proto.
- Registered new request/response types in the services and updated references to message indices accordingly.
This commit deletes the outdated `examplepb/BUILD.bazel` file and eliminates unused proto and Bazel rule definitions. It also updates dependencies in `examplepb_opaque_proto` and `examplepb_opaque_go_proto` to include a missing reference to `sub_proto`, improving build correctness and simplifying the overall setup.
@kellen-miller
Copy link
Copy Markdown
Contributor Author

kellen-miller commented Jan 26, 2026

This looks great, just looks like some of the Bazel files need a small fix, thank you!

Thanks! Sorry for all the pushes, I am not a Bazel expert by any means. Hopefully should be fixed now.

Copy link
Copy Markdown
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

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

Thanks!

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.

Opaque API handlers miss imports for nested request bodies Snake_case proto names not changed into generated Go identifiers

2 participants