Skip to content

Commit da0faf6

Browse files
committed
#71 - Support Javalin 4.x slash accepting named paths (rather than splat)
1 parent 0dd4eb2 commit da0faf6

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

tests/test-javalin/src/main/java/org/example/myapp/web/HelloController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,10 @@ void deleteById(int id) {
141141
String getWithMatrixParam(int year, String author, String country, String other, String extra) {
142142
return "yr:" + year + " au:" + author + " co:" + country + " other:" + other + " extra:" + extra;
143143
}
144+
145+
@Produces("text/plain")
146+
@Get("slash/{name}/<nam0>/other/<nam1>")
147+
String slashAccepting(String name, String nam0, String nam1) {
148+
return "got name:" + name + " splat0:" + nam0 + " splat1:" + nam1;
149+
}
144150
}

tests/test-javalin/src/main/resources/public/openapi.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,47 @@
426426
}
427427
}
428428
},
429+
"/hello/slash/{name}/<nam0>/other/<nam1>" : {
430+
"get" : {
431+
"tags" : [ ],
432+
"summary" : "",
433+
"description" : "",
434+
"parameters" : [ {
435+
"name" : "name",
436+
"in" : "path",
437+
"required" : true,
438+
"schema" : {
439+
"type" : "string"
440+
}
441+
}, {
442+
"name" : "nam0",
443+
"in" : "path",
444+
"required" : true,
445+
"schema" : {
446+
"type" : "string"
447+
}
448+
}, {
449+
"name" : "nam1",
450+
"in" : "path",
451+
"required" : true,
452+
"schema" : {
453+
"type" : "string"
454+
}
455+
} ],
456+
"responses" : {
457+
"200" : {
458+
"description" : "",
459+
"content" : {
460+
"text/plain" : {
461+
"schema" : {
462+
"type" : "string"
463+
}
464+
}
465+
}
466+
}
467+
}
468+
}
469+
},
429470
"/hello/withMatrix/{year_segment}/{other}" : {
430471
"get" : {
431472
"tags" : [ ],

tests/test-javalin/src/test/java/org/example/myapp/HelloControllerTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,16 @@ void getWithMatrixParam() {
298298
assertEquals(200, httpRes.statusCode());
299299
assertEquals("yr:2011 au:rob co:nz other:foo extra:banana", httpRes.body());
300300
}
301+
302+
303+
@Test
304+
void get_slashAcceptingPath_expect200() {
305+
final HttpResponse<String> hres = clientContext.request()
306+
.path("hello/slash/one/a/b/other/x/y/z")
307+
.GET()
308+
.asString();
309+
310+
assertThat(hres.statusCode()).isEqualTo(200);
311+
assertEquals("got name:one splat0:a/b splat1:x/y/z", hres.body());
312+
}
301313
}

0 commit comments

Comments
 (0)