Property type "null" is missing if Kotlin property name does not equal OpenAPI property name
Maintainer thường phản hồi trong vòng 9 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 66/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- java, kotlin, spring-boot
- Lĩnh vực
- api
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Java
- Star
- 3.7k
- Fork
- 605
- Merge trung bình
- 9 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 14
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của springdoc/springdoc-openapi
-
Add support for OpenAPI spec 3.2Đang mởenhancement upstream
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
springdoc/springdoc-openapi#3324 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 9 ngày
-
enhancement upstream
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
springdoc/springdoc-openapi#3309 · 4 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 9 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
springdoc/springdoc-openapi#3404 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 9 ngày
Tất cả issue của springdoc/springdoc-openapi
Issue tương tự
-
vaadin-map
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
vaadin/flow-components#10586 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
wpilibsuite/SystemcoreTesting#446 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
frontend quality-assurance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Paul-Austin-Oswego-CSC480-HCI521/gift-app#212 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
kuboard 在 PostgreSQL 上的迁移幂等 bugĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
eip-work/kuboard-press#700 ·
-
Mend: dependency security vulnerability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày