File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ public MethodMetadata parseAndValidatateMetadata(Method method) {
5454 if (!pathValue .startsWith ("/" )) {
5555 pathValue = "/" + pathValue ;
5656 }
57+ if (pathValue .endsWith ("/" )) {
58+ // Strip off any trailing slashes, since the template has already had slashes appropriately added
59+ pathValue = pathValue .substring (0 , pathValue .length ()-1 );
60+ }
5761 md .template ().insert (0 , pathValue );
5862 }
5963 return md ;
Original file line number Diff line number Diff line change @@ -374,6 +374,22 @@ public void pathsWithSomeOtherSlashesParseCorrectly() throws Exception {
374374
375375 }
376376
377+ @ Test
378+ public void classWithRootPathParsesCorrectly () throws Exception {
379+ assertThat (
380+ contract .parseAndValidatateMetadata (ClassRootPath .class .getDeclaredMethod ("get" ))
381+ .template ())
382+ .hasUrl ("/specific" );
383+ }
384+
385+ @ Test
386+ public void classPathWithTrailingSlashParsesCorrectly () throws Exception {
387+ assertThat (
388+ contract .parseAndValidatateMetadata (ClassPathWithTrailingSlash .class .getDeclaredMethod ("get" ))
389+ .template ())
390+ .hasUrl ("/base/specific" );
391+ }
392+
377393 interface Methods {
378394
379395 @ POST
@@ -549,4 +565,18 @@ interface PathsWithSomeOtherSlashes {
549565 @ Path ("/specific" )
550566 Response get ();
551567 }
568+
569+ @ Path ("/" )
570+ interface ClassRootPath {
571+ @ GET
572+ @ Path ("/specific" )
573+ Response get ();
574+ }
575+
576+ @ Path ("/base/" )
577+ interface ClassPathWithTrailingSlash {
578+ @ GET
579+ @ Path ("/specific" )
580+ Response get ();
581+ }
552582}
You can’t perform that action at this time.
0 commit comments