swagger-api / swagger-api/swagger-core
@Schema example overrides previous one when using same model on two request fields
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.5k
- Forks
- 2.3k
- Avg merge
- 18h 1m
- Merged PRs (30d)
- 10
Description
Given a request body like so:
data class SampleRequest(
@Schema(example = """{"name": "John", "lastname": "Doe"}""")
val personOne: PersonDto?,
@Schema(example = """{"name": "Jane", "lastname": "Smith"}""")
val personTwo: PersonDto?,
)
with the following PersonDto
data class PersonDto (
private val name: String?,
private val lastname: String?,
)
doesn't work as expected. example defined on the second field personTwo overrides the first one.
Actual output
{
"personOne": {
"name": "Jane",
"lastname": "Smith"
},
"personTwo": {
"name": "Jane",
"lastname": "Smith"
}
}
Expected output
{
"personOne": {
"name": "John",
"lastname": "Doe"
},
"personTwo": {
"name": "Jane",
"lastname": "Smith"
}
}
Versions
Spring Boot 2.7.7
Kotlin 1.7.10
Spring DOC OpenAPI 1.6.11
Swagger UI 4.14.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are identified in the issue. Start by reproducing the Kotlin request-body example through Swagger Core's OpenAPI schema generation and compare the generated examples for personOne and personTwo. Done means each field retains its own example rather than sharing the second field's value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin, openapi
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100