Skip to content

Commit

Permalink
#285 BigInteger support for path parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-bygrave committed Sep 13, 2023
1 parent 29e8f15 commit 597bc6e
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static void add(TypeHandler h) {

add(new UuidHandler());
add(new BigDecimalHandler());
add(new BigDecimalHandler());
add(new BigIntegerHandler());
add(new LocalDateHandler());
add(new LocalTimeHandler());
add(new LocalDateTimeHandler());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,20 @@ void get_Float() {
assertThat(handler.asMethod()).isEqualTo("asFloat(");
assertFalse(handler.isPrimitive());
}

@Test
void get_BigDecimal() {
TypeHandler handler = TypeMap.get("java.math.BigDecimal");
assertThat(handler).isInstanceOf(TypeMap.BigDecimalHandler.class);
assertThat(handler.asMethod()).isEqualTo("asBigDecimal(");
assertFalse(handler.isPrimitive());
}

@Test
void get_BigInt() {
TypeHandler handler = TypeMap.get("java.math.BigInteger");
assertThat(handler).isInstanceOf(TypeMap.BigIntegerHandler.class);
assertThat(handler.asMethod()).isEqualTo("asBigInteger(");
assertFalse(handler.isPrimitive());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"openapi" : "3.0.1",
"info" : {
"title" : "Example service showing off the Path extension method of controller",
"title" : "Example service",
"description" : "Example Javalin controllers with Java and Maven",
"version" : ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import io.avaje.http.api.Valid;
import io.avaje.jex.Context;

import java.math.BigInteger;

// @Roles(AppRoles.BASIC_USER)
@Controller
@Path("/")
Expand Down Expand Up @@ -58,4 +60,9 @@ String splat2(String name, String nam0, String nam1) {
void put(HelloDto dto) {
dto.hashCode();
}

@Get("/bigInt/{val}")
String testBigInt(BigInteger val) {
return "hi|" + val;
}
}
31 changes: 31 additions & 0 deletions tests/test-jex/src/main/resources/public/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,37 @@
}
}
},
"/bigInt/{val}" : {
"get" : {
"tags" : [

],
"summary" : "",
"description" : "",
"parameters" : [
{
"name" : "val",
"in" : "path",
"required" : true,
"schema" : {
"type" : "number"
}
}
],
"responses" : {
"200" : {
"description" : "",
"content" : {
"application/json" : {
"schema" : {
"type" : "string"
}
}
}
}
}
}
},
"/other/{name}" : {
"get" : {
"tags" : [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,9 @@ String form(String name, String email, String url) {
String formBean(MyForm form) {
return form.name + "|" + form.email + "|" + form.url;
}

// @Get("/bigInt/{val}")
// String testBigInt(BigInteger val) {
// return "hi|" + val;
// }
}

0 comments on commit 597bc6e

Please sign in to comment.