Commit 515b70a
feat: add gRPC-protoc framework support (#14)
* feat(grpc): create grpcprotoc package structure
Add package constants and Info type for gRPC-protoc extractor.
Signed-off-by: Claude <claude@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* feat(grpc): implement grpcprotoc detector
Add detector that:
- Rejects buf-managed projects with clear error
- Finds all .proto files
- Detects import paths
- Identifies google.api.http annotations
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* feat(grpc): implement grpcprotoc patcher
Add patcher that verifies:
- protoc is installed
- protoc-gen-connect-openapi is installed
- Returns clear installation hints if missing
Signed-off-by: Claude <claude@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* feat(grpc): implement grpcprotoc generator
Add generator that:
- Builds protoc command with import paths
- Executes protoc-gen-connect-openapi
- Returns path to generated OpenAPI file
Signed-off-by: Claude <claude@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* feat(grpc): register grpcprotoc extractor in builtin registry
Add grpcprotoc to builtin extractor registry.
Implements full Extractor interface.
Signed-off-by: Claude <claude@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* feat(grpc): add --proto-import-path CLI flag
Add flag for specifying additional protoc import paths.
Co-Authored-By: Claude <claude@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* docs: add gRPC-protoc support to README
Document gRPC-protoc extractor usage, requirements, and CLI flags.
Signed-off-by: Claude <claude@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* feat(grpcprotoc): improve proto file handling and add demo project
- Add ServiceProtoFiles field to Info struct to identify main entry points
- Update Detector to find proto files with service definitions
- Update Generator to:
- Only compile service proto files (avoids duplicate definition errors)
- Handle relative output directories correctly by converting to absolute paths
- Search recursively for generated OpenAPI files
- Add integration-tests/grpc-protoc-demo with sample UserService proto
- Include generated OpenAPI spec for demo project
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* feat(grpcprotoc): add HTTP annotations support for REST endpoints
- Add google/api/annotations.proto and http.proto to demo project
- Update user.proto with google.api.http annotations for all RPC methods
- Generator now conditionally adds --connect-openapi_opt=features=google.api.http
when HasGoogleAPI is detected, generating REST endpoints alongside gRPC
The generated OpenAPI spec now includes both gRPC-style paths and REST endpoints:
- GET /v1/users - ListUsers
- POST /v1/users - CreateUser
- GET /v1/users/{id} - GetUser
- PUT /v1/users/{id} - UpdateProfile
- POST /v1/users/{user_id}/files - UploadFile
Signed-off-by: Claude <noreply@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* test(e2e): add gRPC-protoc integration test
- Add TestE2E_GrpcProtoc_Generate to verify gRPC-protoc detection and generation
- Verify HTTP annotations detection (HasGoogleAPI)
- Verify generated spec contains REST paths from google.api.http annotations
- Fix existing tests to properly extract FrameworkData for spring.Info
Signed-off-by: Claude <noreply@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* docs: update grpc-protoc documentation and tests
- Add grpc_protoc_test.go with dedicated e2e test for gRPC-protoc
- Update integration-tests/README.md with grpc-protoc-demo project
- Update grpc-protoc-demo/README.md with:
- third_party directory structure
- HTTP annotations usage
- spec-forge integration notes
- Update CLAUDE.md with:
- grpcprotoc package in architecture
- publisher package
- Remove duplicate tests from spring_maven_test.go (now in separate files)
Signed-off-by: Claude <noreply@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* docs(grpc): update design and implementation plan to reflect actual implementation
- Add ServiceProtoFiles field to Info struct documentation
- Document conditional HTTP annotations support (only when HasGoogleAPI is true)
- Update demo project structure to include third_party/google/api
- Mark both documents as completed
- Add implementation summary with key design decisions
Signed-off-by: spencercjh <spencercjh@gmail.com>
* ci: add Protoc installation step in CI configuration
Signed-off-by: spencercjh <spencercjh@gmail.com>
* ci: add setup step for protoc-gen-connect-openapi
Signed-off-by: spencercjh <spencercjh@gmail.com>
* fix(grpcprotoc): remove duplicate google/api/annotations.proto check
The hasGoogleAPIImport method had two identical conditions
checking for 'google/api/annotations.proto'. Since protobuf
only uses double quotes for imports, the single-quote
check is unnecessary and has been removed.
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* refactor(grpcprotoc): simplify findOutputFile logic
Remove redundant fallback check that could match files with unexpected
format. Now the method only looks for files with the expected extension
based on the requested format.
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* refactor(grpcprotoc): remove duplicate FrameworkName constant
Keep only ExtractorName to extractor.go to follow the existing
convention (spring, gozero). Remove FrameworkName from
grpcprotoc.go and update all references.
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* refactor(grpcprotoc): use strings.Contains instead of custom helper
Replace custom contains function with standard library strings.Contains
for consistency and clarity.
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* fix(grpcprotoc): add service definition requirement in detector
The detector now rejects projects that have .proto files but no service definitions. This prevents the grpc-protoc extractor from being selected for non-gRPC projects that leading to confusing errors during generation.
- Update detector to return ErrNotProtocProject when no service definitions found
- Update test cases to include service definitions in proto files
- Use proper proto file formatting with newlines for service definitions
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
* fix(grpcprotoc): pass OutputFile to protoc plugin and simplify findOutputFile
- Add output_name option to protoc-gen-connect-openapi when OutputFile is specified
- Remove recursive search fallback in findOutputFile to avoid finding unrelated files
- Only search output directory and service proto file directories
Signed-off-by: spencercjh <spencercjh@gmail.com>
* fix(e2e): update grpc_protoc_test to use ExtractorName
Signed-off-by: spencercjh <spencercjh@gmail.com>
* fix(grpcprotoc): handle comments in hasServiceDefinition and avoid redundant search in findOutputFile
- Add proper comment handling (// and /* */) in hasServiceDefinition
- Use set to skip already-searched directories in findOutputFile
- Address code review feedback from PR #14
Signed-off-by: spencercjh <spencercjh@gmail.com>
---------
Signed-off-by: Claude <claude@anthropic.com>
Signed-off-by: spencercjh <spencercjh@gmail.com>
Signed-off-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <claude@anthropic.com>1 parent 8554511 commit 515b70a
28 files changed
Lines changed: 5519 additions & 26 deletions
File tree
- .github/workflows
- cmd
- docs/plans
- integration-tests
- grpc-protoc-demo
- proto
- third_party/google/api
- internal/extractor
- builtin
- grpcprotoc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
102 | 108 | | |
103 | 109 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
59 | 69 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
67 | 81 | | |
68 | 82 | | |
69 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
102 | 103 | | |
103 | 104 | | |
104 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
105 | 129 | | |
106 | 130 | | |
107 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
130 | 133 | | |
131 | 134 | | |
132 | 135 | | |
| |||
262 | 265 | | |
263 | 266 | | |
264 | 267 | | |
| 268 | + | |
| 269 | + | |
265 | 270 | | |
266 | 271 | | |
267 | 272 | | |
| |||
0 commit comments