Property type "null" is missing if Kotlin property name does not equal OpenAPI property name
维护者通常 9 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 66/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- java, kotlin, spring-boot
- 领域
- api
调研方向
Start by reproducing the issue with the supplied Kotlin Request model and inspect the generated OpenAPI schema for its three properties. Trace how schema generation handles Kotlin nullability and the @JsonProperty name. Done means the type: "null" output is consistent for properties whether or not their JSON names match their Kotlin names.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
- A nullable Kotlin property gets
type: "null"when the@JsonPropertyname equals the Kotlin property name, but not if the names are different.
To Reproduce
- springdoc-openapi-starter-webmvc-ui 3.2.0
- Spring Boot 4.1.2
- Kotlin 2.3.21 with JDK 21
- com.fasterxml.jackson.core:jackson-core:2.21.7
- tools.jackson.core:jackson-core:3.1.7
import com.fasterxml.jackson.annotation.JsonProperty
import io.swagger.v3.oas.annotations.media.Schema
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RestController
@SpringBootApplication
class SpringdocBugApplication
fun main(args: Array<String>) {
runApplication<SpringdocBugApplication>(*args)
}
data class Request(
@get:Schema(description = "JSON name == property name -> schema contains type \"null\"")
val myproperty1: String? = null,
@get:JsonProperty("myproperty2_suffix")
@get:Schema(description = "JSON name != property name -> no \"null\" type in schema")
val myproperty2: String? = null,
@get:Schema(
nullable = false,
description = "JSON name == property name and \"nullable = false\" -> schema contains type \"null\""
)
val myproperty3: String? = null,
)
@RestController
class Controller {
@PostMapping("/test")
fun test(@RequestBody r: Request) = Unit
}
Resulting OpenAPI spec:
openapi: 3.1.0
# ...
components:
schemas:
Request:
type: object
properties:
myproperty1:
type:
- string
- "null"
description: JSON name == property name -> schema contains type "null"
myproperty3:
type:
- string
- "null"
description: JSON name == property name and "nullable = false" -> schema
contains type "null"
myproperty2_suffix:
type: string
description: JSON name != property name -> no "null" type in schema
Expected behavior
- Type "null" should be assigned consistently for all properties, not depending on Kotlin property name
- 主要语言
- Java
- 星标
- 3.7k
- 派生
- 605
- 平均合并
- 9 天 11 小时
- 30 天内合并 PR
- 14
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
springdoc/springdoc-openapi 的其他 Issue
-
enhancement upstream
难度 4/5 3-5 天 新手友好度 48/100
springdoc/springdoc-openapi#3324 · 2 条评论 ·
维护者通常 9 天内回复
-
enhancement upstream
难度 3/5 1-2 天 新手友好度 55/100
springdoc/springdoc-openapi#3309 · 4 条评论 · 1 个 reaction ·
维护者通常 9 天内回复
-
难度 3/5 1-2 天 新手友好度 45/100
springdoc/springdoc-openapi#3404 · 1 条评论 ·
维护者通常 9 天内回复
查看 springdoc/springdoc-openapi 的全部 Issue
相似的 Issue
-
Type: Bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
MCP add-on: JSON responses with non-ASCII characters are truncated (wrong Content-Length)可能已有人在做 @dhanushbs10 今天认领。 未关闭add-on bug in:mcp
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
vaadin-map
难度 2/5 1-3 小时 新手友好度 70/100
vaadin/flow-components#10586 ·
维护者通常 1 天内回复
-
WeReadInstaller writes the launcher database on the main thread at handover (Activity pause timeout)未关闭bug good first issue
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 63/100
wpilibsuite/SystemcoreTesting#446 ·
维护者通常 1 天内回复