Bug Report Checklist
Description
When a property uses allOf with a single $ref and has a sibling example, the generated code loses the example value. The @Schema annotation emits example = "null" (the literal string) instead of the actual example value from the spec.
This worked correctly in 6.x.
Actual output:
@Schema(example = "null", description = "Current status of the item.")
@get:JsonProperty("status") val status: StatusEnum? = null
The example becomes the literal string "null" instead of "ACTIVE".
Expected output:
@Schema(example = "ACTIVE", description = "Current status of the item.")
@get:JsonProperty("status") val status: StatusEnum? = null
openapi-generator version
Tested on 7.12.0 and 7.18.0. Worked correctly on 6.3.0.
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: Test API
version: 1.0.0
paths:
/test:
get:
operationId: getTest
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/TestDTO'
components:
schemas:
TestDTO:
type: object
properties:
status:
description: Current status of the item.
allOf:
- $ref: '#/components/schemas/StatusEnum'
example: ACTIVE
StatusEnum:
type: string
enum: [ACTIVE, INACTIVE, PENDING]
description: Status type.
example: ACTIVE
Generation Details
openapi-generator-cli generate -i spec.yaml -g kotlin-spring -o output
Using kotlin-spring generator with interfaceOnly: true, useSpringBoot3: true.
Steps to reproduce
- Generate code with the spec above using openapi-generator 7.12.0+
- Check the generated
TestDTO.kt
Related issues/PRs
Suggest a fix
Bug Report Checklist
Description
When a property uses
allOfwith a single$refand has a siblingexample, the generated code loses the example value. The@Schemaannotation emitsexample = "null"(the literal string) instead of the actual example value from the spec.This worked correctly in 6.x.
Actual output:
The
examplebecomes the literal string"null"instead of"ACTIVE".Expected output:
openapi-generator version
Tested on 7.12.0 and 7.18.0. Worked correctly on 6.3.0.
OpenAPI declaration file content or url
Generation Details
Using
kotlin-springgenerator withinterfaceOnly: true,useSpringBoot3: true.Steps to reproduce
TestDTO.ktRelated issues/PRs
allOfwith single$refelement implementation doesn't respect sibling properties likedeprecatedetc. #17048 - same root cause, but onlydeprecatedwas fixed (PR Retain deprecated in allOf schema handling #17056)Suggest a fix