Spring-framework: Support Kotlin parameter default values in HTTP handler methods [SPR-16598]

Created on 15 Mar 2018  路  3Comments  路  Source: spring-projects/spring-framework

Take Weiland opened SPR-16598 and commented

Support specifying defaults for e.g. @RequestMapping via Kotlin parameter default values like so:

@GetMapping
fun get(@RequestParam limit: Int = 20)

Such a method should behave equivalent to @RequestMapping with defaultValue, except that the value does not need to be processed by converters, etc.

This can be implemented in org.springframework.web.method.support.InvocableHandlerMethod using Kotlin Reflection (KCallable#callBy), which allows omitting parameters with default values.


Affects: 5.0.4

Referenced from: pull request https://github.com/spring-projects/spring-framework/pull/1741

2 votes, 5 watchers

web enhancement

Most helpful comment

Is there any updates on this issue?

All 3 comments

Alex Rader commented

In Kotlin @RequestBody required=false when use default arguments
https://github.com/spring-projects/spring-boot/issues/12691

S茅bastien Deleuze commented

As discussed in the PR, current Kotlin API force us to integrate that as a rather involved and not very elegant way, I will raise and discuss that point with Kotlin team. As a consequence, I think it is more reasonable to target 5.2 for that one.

Is there any updates on this issue?

Was this page helpful?
0 / 5 - 0 ratings