-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Is your feature request related to one or multiple existing converters?
SpringConverter
Describe the solution you'd like
Spring allows query parameter definitions by simply passing an object.
On extracting query parameters every controller method should be check for parameters (objects, not interfaces) without any spring annotation. The limitation to the usual spring controller method annotations is important, because the parameter could have a JSR-303 annotation or the like.
Easiest way to to get on all properties without having to do the reflection manually might be to serialize the type as json and and then extract the paths from the json. Suggestion for seriallization lib could be klaxon or moshi
Unchecked:
- How do primitives such as String, Int, Long etc behave?
Additional context
Simple objects
data class Params1 (
var a: String
var b: String
)
data class Params2 (
var a: String
var c: String
)
@GetMapping("/todos")
fun getAllTodos(params1: Params1, params2 Params2) {
/*
calling: /todos?a=val1&b=val2&c=val3
will result in :
Params1(a = val1, b = val2)
Params2(a = val1, c = val3)
*/
}
Nested object
data class Params1 (
var a: String
var b: Params2
)
data class Params2 (
var a: String
var c: String
)
@GetMapping("/todos")
fun getAllTodos(params1: Params1) {
/*
calling: /todos?a=val1&b.c=nestedvalue&c=othervalue
will result in:
Params1(a = val1, b = null)
Params2(a = null, c = nestedvalue)
*/
}
Extract query parameter names from json:
{
"a": null,
"b": {
"a": null,
"c": null
}
}
Must result in three query parameters:
a
b.a
b.c