feat(api-doc): support request parameter parsing for RPC types (Dubbo/SOFA/TARS/gRPC)#6339
Open
eye-gu wants to merge 9 commits into
Open
feat(api-doc): support request parameter parsing for RPC types (Dubbo/SOFA/TARS/gRPC)#6339eye-gu wants to merge 9 commits into
eye-gu wants to merge 9 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends ShenYu’s API document generation so RPC-style services (Dubbo/SOFA/TARS/gRPC, including Dubbo protobuf) can produce request parameter schemas in generated API docs, and it aligns document field naming across protocols.
Changes:
- Add RPC-aware document generation in
OpenApiUtils(RPC + gRPC request parsing, RPC-specific response generation, protobuf message field reflection). - Route API doc registrars/listeners to the new unified
requestParameters/responseParametersdocument structure. - Add/adjust tests and example annotations; update build/checkstyle config to support generated protobuf test sources.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java | Adds RPC/gRPC/protobuf-aware doc building and unifies document fields |
| shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImpl.java | Switches document generation to RPC-type dispatch via OpenApiUtils.buildDocumentJson |
| shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/registrar/AbstractApiDocRegistrar.java | Uses new unified document builder for generated docs |
| shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/client/AbstractContextRefreshedEventListener.java | Threads RPC type into doc generation for annotation-based docs |
| shenyu-client/shenyu-client-sofa/src/main/java/org/apache/shenyu/client/sofa/SofaServiceEventListener.java | Refactors SOFA listener into the shared refreshed-event flow to enable API doc pipeline |
| shenyu-client/shenyu-client-sofa/src/test/java/org/apache/shenyu/client/sofa/SofaServiceEventListenerTest.java | Updates test to align with the new path-building flow |
| shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/utils/OpenApiUtilsTest.java | Adds extensive unit coverage for RPC/gRPC/protobuf parsing and dispatch |
| shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/NoHttpApiDocRegistrarTest.java | Adds coverage that RPC/gRPC docs include request/response parameter fields |
| shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/register/registrar/ApiDocRegistrarImplTest.java | Validates registrar document output uses unified field names across RPC types |
| shenyu-client/shenyu-client-core/src/test/proto/test.proto | Adds proto used by protobuf reflection tests |
| shenyu-client/shenyu-client-core/pom.xml | Adds test-only protobuf/grpc deps and proto generation for tests |
| shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ApiServiceImpl.java | Parses doc JSON when present (not only SWAGGER source) to populate request/response parameter lists |
| shenyu-admin/src/test/java/org/apache/shenyu/admin/service/ApiServiceTest.java | Adds coverage for findById behavior with blank/non-blank document |
| shenyu-examples/.../DubboProtobufServiceImpl.java (3 files) | Adds @ApiModule/@ApiDoc annotations to protobuf Dubbo examples |
| pom.xml | Excludes generated sources from checkstyle to accommodate generated protobuf test code |
Comments suppressed due to low confidence (1)
shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java:135
generateRequestDocParameterscurrently parses either query parameters (when any@RequestParam/@RequestPartis present) or path template variables, but not both due to theif (...) { ... } else { ... }structure. This will drop{var}path parameters for endpoints that also have query params. Consider always parsing path segments and then merging/deduplicating with any query-derived parameters.
List<Parameter> list = new ArrayList<>();
Pair<Boolean, Annotation[][]> query = isQuery(method);
if (query.getLeft()) {
for (Annotation[] annotations : query.getRight()) {
if (annotations.length > 0 && isQueryName(annotations[0].annotationType().getName(), QUERY_CLASSES)) {
for (Annotation annotation : annotations) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
moremind
requested changes
May 16, 2026
moremind
requested changes
Jun 5, 2026
| <plugin> | ||
| <groupId>org.xolstice.maven.plugins</groupId> | ||
| <artifactId>protobuf-maven-plugin</artifactId> | ||
| <version>0.6.1</version> |
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.
close #6338 #5940
Previously, API document generation only supported Spring Web annotation-based parameter parsing (
@RequestParam,@RequestPart, path variables), which only works for HTTP/WebSocket/Spring Cloud. RPC types (Dubbo, SOFA, TARS, gRPC) had no request parameter information in generated documents.Changes
OpenApiUtils - RPC-aware document generation
buildDocumentJson()that dispatches by RPC type:StreamObservermethod patternrequestParameters/responseParametersSOFA - enable API document support
SofaServiceEventListenerto extendAbstractContextRefreshedEventListenercommon flowhandler()/onApplicationEvent()with standardgetCorrectedClass()+buildApiPath()hooksExamples
@ApiModule/@ApiDocannotations to Dubbo protobuf example servicesImpact
Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.