Property type "null" is missing if Kotlin property name does not equal OpenAPI property name
I maintainer di solito rispondono entro 9 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 66/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- java, kotlin, spring-boot
- Ambito
- api
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Java
- Stelle
- 3.7k
- Fork
- 605
- Merge medio
- 9g 11h
- PR unite (30g)
- 14
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di springdoc/springdoc-openapi
-
enhancement upstream
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
springdoc/springdoc-openapi#3324 · 2 commenti ·
I maintainer di solito rispondono entro 9 giorni
-
enhancement upstream
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
springdoc/springdoc-openapi#3309 · 4 commenti · 1 reazione ·
I maintainer di solito rispondono entro 9 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
springdoc/springdoc-openapi#3404 · 1 commento ·
I maintainer di solito rispondono entro 9 giorni
Tutte le issue di springdoc/springdoc-openapi
Issue simili
-
Type: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
MCP add-on: JSON responses with non-ASCII characters are truncated (wrong Content-Length)Forse già presa @dhanushbs10 l’ha presa oggi. Apertaadd-on bug in:mcp
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Map.Coordinate does not implement proper equalsForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertavaadin-map
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
vaadin/flow-components#10586 ·
I maintainer di solito rispondono entro 1 giorno
-
WeReadInstaller writes the launcher database on the main thread at handover (Activity pause timeout)Apertabug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
wpilibsuite/SystemcoreTesting#446 ·
I maintainer di solito rispondono entro 1 giorno