Property type "null" is missing if Kotlin property name does not equal OpenAPI property name
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 66/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- java, kotlin, spring-boot
- Bereich
- api
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Java
- Sterne
- 3.7k
- Forks
- 605
- Ø Merge
- 4 T. 18 Std.
- Gemergte PRs (30 T.)
- 21
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus springdoc/springdoc-openapi
-
enhancement upstream
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
springdoc/springdoc-openapi#3324 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement upstream
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
springdoc/springdoc-openapi#3309 · 4 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in springdoc/springdoc-openapi
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
Julow/Unexpected-Keyboard#1490 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
Vakore/ZappierGames#275 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
unitycatalog/unitycatalog#2148 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
enhancement priority: low
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
Riptide-Labs/riptide#1060 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug key bindings source editor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 1 Tag