Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new PathPrefix attribute #1685

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JesseKlaasse
Copy link

What kind of change does this PR introduce?
When a group of methods share the same relative URL path prefix, you can use the PathPrefix annotation. When given, the path prefix will be concatenated after the base URL and before the relative path as specified in the method's annotation.

What is the current behavior?
This is an added feature, so the current behavior is that this is not possible. At the moment, the constructed URL is always a concatenation of the base URL and the method specific relative path.

What is the new behavior?
You now have the possibility to define a PathPrefix on interface level.

What might this PR break?
URL construction in RestMethodInfoInternal.RelativePath, although it should and does not break. When a PathPrefix is omitted, it simply will not be used.

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

When a group of methods share the same relative URL path prefix, you can use the PathPrefix annotation. When given, the path prefix will be concatenated after the base URL and before the relative path as specified in the method's annotation.
@@ -68,7 +68,7 @@ internal class RestMethodInfoInternal
var hma = methodInfo.GetCustomAttributes(true).OfType<HttpMethodAttribute>().First();

HttpMethod = hma.Method;
RelativePath = hma.Path;
RelativePath = ReflectionHelpers.GetPathPrefixFor(targetInterface) + hma.Path;

Choose a reason for hiding this comment

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

Is concatenation enough? I think it should also add a / separator if necessary.

Copy link

codecov bot commented May 9, 2024

Codecov Report

Attention: Patch coverage is 86.66667% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 87.72%. Comparing base (6ebeda5) to head (2e87757).
Report is 20 commits behind head on main.

Files Patch % Lines
Refit/ReflectionHelpers.cs 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1685      +/-   ##
==========================================
- Coverage   87.73%   87.72%   -0.02%     
==========================================
  Files          33       34       +1     
  Lines        2348     2362      +14     
  Branches      294      297       +3     
==========================================
+ Hits         2060     2072      +12     
- Misses        208      209       +1     
- Partials       80       81       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

None yet

3 participants