Description
With a simple application like
package com.example.demo
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
@SpringBootApplication
class DemoApplication
fun main(args: Array<String>) {
runApplication<DemoApplication>(*args)
}
@RestController
@RequestMapping("/test")
class TestController {
@GetMapping
fun test(@RequestParam(defaultValue = "#{{}}") list: List<String>) =
list
}
and a build.gradle.kts
file autogenerated from Spring Initializr plus springdoc
addition as follow
implementation("org.springdoc:springdoc-openapi-ui:1.5.12")
implementation("org.springdoc:springdoc-openapi-kotlin:1.5.12")
implementation("org.springdoc:springdoc-openapi-hateoas:1.5.12")
I get the following OpenAPI definition:
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost:8080",
"description": "Generated server url"
}
],
"paths": {
"/test": {
"get": {
"tags": [
"test-controller"
],
"operationId": "test",
"parameters": [
{
"name": "list",
"in": "query",
"required": false,
"schema": {
"type": "array",
"items": {
"type": "string"
},
"default": [
"#{{}}"
]
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {}
}
}
In particular, "default": ["#{{}}"]
struck me as wrong, since fun test(@RequestParam(defaultValue = "#{{}}") list: List<String>)
actually uses a SpEL expression which should convert to an empty list. Should this work out of the box or am I missing some enabler configuration?
Changing to fun test(@RequestParam(defaultValue = "#{{}}") list: List<Int>)
gets even worse, as now the conversion service throws an exception that translates into org.springdoc.core.ParameterInfo : Using the following default value : #{{}}, without spring conversionService
Sample project: https://github.com/ThanksForAllTheFish/springdocspel