Skip to content

feat(client):add many path register for spring mvc client.#6348

Merged
Aias00 merged 22 commits into
apache:masterfrom
wy471x:feat_addMultiPathController#6327
Jul 15, 2026
Merged

feat(client):add many path register for spring mvc client.#6348
Aias00 merged 22 commits into
apache:masterfrom
wy471x:feat_addMultiPathController#6327

Conversation

@wy471x

@wy471x wy471x commented May 22, 2026

Copy link
Copy Markdown
Contributor

Feat(#6327): Support many path register into same controller.

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

All changes:

  1. SpringMvcClientEventListener

Unit Tests:
1.testBuildApiDocSextetDefaultProducesConsumes
2.testBuildApiDocSextetExplicitProducesConsumesAndMethod
3.testBuildApiDocSextetMultipleMethodsProducesConsumes

close #6327

@wy471x

wy471x commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

Hi, @Aias00, when you have time, could you please help review this PR? Thank you.

@Aias00
Aias00 requested a review from Copilot May 24, 2026 13:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

@Aias00

Aias00 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

@wy471x hi, pls fix the review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Previously buildApiDocDTO called buildApiSuperPath (singular), so only the
first class-level prefix was used in generated API docs. Now iterates over
buildApiSuperPaths to produce ApiDocRegisterDTO for every prefix. Also fixes
a potential NPE in buildApiPath when a method annotation has an empty path
array.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR. The main route registration path looks like the right direction, but I think we should add one regression test before merging.

The new logic expands class-level paths in SpringMvcClientEventListener#handle() and also changes API doc generation to iterate buildApiSuperPaths(). However, the current unit tests only assert buildApiSuperPaths() and buildApiDocSextet(), while the integration test verifies gateway routing only.

Please add a publisher-level/unit test that captures the emitted MetaDataRegisterDTO and ApiDocRegisterDTO for a controller with multiple class-level paths, and assert the exact count and paths, for example both:

  • /mvc/multipath/v1/greet
  • /mvc/multipath/v2/greet

This is important because the registration contract is now "one Java method can produce multiple registered paths", while metaDataMap is still keyed by Method and API doc generation depends on that registration flow. Even if ApiExt is path-independent today, this behavior should be locked by tests.

Also, please consider avoiding the suffix-based fallback heuristic in buildApiPath() (superPath.endsWith(formatPath(p))) or at least cover it with tests. It is hard to reason about method-vs-class annotation provenance from string shape alone.

Replace the superPath.endsWith(formatPath(p)) deduplication check with
explicit annotation-provenance routing in handleMethod. When the method
has its own @ShenyuSpringMvcClient, the annotation path is used directly.
When falling back to the class-level annotation, @RequestMapping path is
used instead — avoiding both path duplication and false-positive suffix
matches. Also adds buildApiPathFromRequestMapping for the fallback path
and 5 new unit tests covering buildApiPath edge cases.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@wy471x

wy471x commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the PR. The main route registration path looks like the right direction, but I think we should add one regression test before merging.

The new logic expands class-level paths in SpringMvcClientEventListener#handle() and also changes API doc generation to iterate buildApiSuperPaths(). However, the current unit tests only assert buildApiSuperPaths() and buildApiDocSextet(), while the integration test verifies gateway routing only.

Please add a publisher-level/unit test that captures the emitted MetaDataRegisterDTO and ApiDocRegisterDTO for a controller with multiple class-level paths, and assert the exact count and paths, for example both:

  • /mvc/multipath/v1/greet
  • /mvc/multipath/v2/greet

This is important because the registration contract is now "one Java method can produce multiple registered paths", while metaDataMap is still keyed by Method and API doc generation depends on that registration flow. Even if ApiExt is path-independent today, this behavior should be locked by tests.

Also, please consider avoiding the suffix-based fallback heuristic in buildApiPath() (superPath.endsWith(formatPath(p))) or at least cover it with tests. It is hard to reason about method-vs-class annotation provenance from string shape alone.

I have made the corresponding fixes and added relevant test cases for coverage. Please review them, thank you.

@wy471x
wy471x requested a review from Aias00 July 14, 2026 23:07

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM,thx

@Aias00

Aias00 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

thx for pr, have my wechat? aias00

@Aias00
Aias00 merged commit d39e623 into apache:master Jul 15, 2026
39 checks passed
@wy471x
wy471x deleted the feat_addMultiPathController#6327 branch July 15, 2026 12:46
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.

[Question] 是否支持多前缀注册到同一个controller

3 participants