Skip to content

Spring boot 4 openapi yml generates empty strings for object schema's #3302

Description

@DriesVanbilloen

Describe the bug
We upgraded our Spring boot application to Spring boot 4 with Jackson 3. We have an api.yml from which we generate our API code and doc annotations.

When requesting the openapi.yml definition, all schema objects are generated as empty strings. (schema objects are referenced inside the requestBody or responseBody)

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    Spring boot 4 (4.0.6)
  • What modules and versions of springdoc-openapi are you using?
             <dependency>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi-bom</artifactId>
                <version>3.0.3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
  • What is the actual and the expected result using OpenAPI Description (yml or json)?
    Expected:
{
    "openapi": "3.1.0",
    "info": {
        "title": "Messages API",
        "description": "This app provides REST APIs for asset management messages requests",
        "version": "v1"
    },
    "servers": [
        {
            "url": "https://x9y-i.dev.intapp.eu/X9Y-I/messages-search-service",
            "description": "Generated server url"
        }
    ],
    "tags": [
        {
            "name": "Messages",
            "description": "the Messages API"
        }
    ],
    "paths": {
        "/messages/v1/search": {
            "post": {
                "tags": [
                    "Messages"
                ],
                "operationId": "getMessagesForIsin",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/MessageQueryDTO"
                            }
                        }
                    },
                    "required": true
                },
                "responses": {
                    "400": {
                        "description": "Bad request"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "413": {
                        "description": "Payload Too Large"
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MessageSearchResponse"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Internal server error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MessageSearchResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/messages/v1/search/latest": {
            "post": {
                "tags": [
                    "Messages"
                ],
                "operationId": "getLatestMessagesForIsin",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/LatestMessageDTO"
                            }
                        }
                    },
                    "required": true
                },
                "responses": {
                    "400": {
                        "description": "Bad request"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "413": {
                        "description": "Payload Too Large"
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/LatestMessageResponse"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Internal server error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/LatestMessageResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/management/messages/v1/search": {
            "post": {
                "tags": [
                    "Messages"
                ],
                "operationId": "getMessagesForIsin_1",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/MessageQueryDTO"
                            }
                        }
                    },
                    "required": true
                },
                "responses": {
                    "400": {
                        "description": "Bad request"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "413": {
                        "description": "Payload Too Large"
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MessageSearchResponse"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Internal server error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MessageSearchResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/management/messages/v1/search/latest": {
            "post": {
                "tags": [
                    "Messages"
                ],
                "operationId": "getLatestMessagesForIsin_1",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/LatestMessageDTO"
                            }
                        }
                    },
                    "required": true
                },
                "responses": {
                    "400": {
                        "description": "Bad request"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "413": {
                        "description": "Payload Too Large"
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/LatestMessageResponse"
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Internal server error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/LatestMessageResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/probe/readiness": {
            "get": {
                "tags": [
                    "health-controller"
                ],
                "operationId": "ready",
                "responses": {
                    "400": {
                        "description": "Bad Request",
                        "content": {
                            "*/*": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "413": {
                        "description": "Payload Too Large"
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "text/plain": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/probe/liveness": {
            "get": {
                "tags": [
                    "health-controller"
                ],
                "operationId": "alive",
                "responses": {
                    "400": {
                        "description": "Bad Request",
                        "content": {
                            "*/*": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "413": {
                        "description": "Payload Too Large"
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "text/plain": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "Message": {
                "type": "null",
                "properties": {
                    "contentId": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Content ID of the message",
                        "example": "content-id-123"
                    },
                    "typeId": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Content Type of the message",
                        "example": "content-type-123"
                    },
                    "title": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Title of the message",
                        "example": "Amerika kiest voor 'amerika first'"
                    },
                    "articleDate": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "The article date of the message",
                        "example": "2025-11-07T16:30:22.577395+01:00"
                    }
                }
            },
            "MessageSearchResponse": {
                "type": "object",
                "properties": {
                    "total": {
                        "type": [
                            "integer",
                            "null"
                        ],
                        "format": "int64"
                    },
                    "hits": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Message"
                        }
                    }
                }
            },
            "MessageQueryDTO": {
                "type": "object",
                "properties": {
                    "language": {
                        "type": "string",
                        "enum": [
                            "de",
                            "en",
                            "fr",
                            "nl"
                        ]
                    },
                    "isin": {
                        "type": "string",
                        "description": "Isin",
                        "example": "BE0123456789"
                    },
                    "company": {
                        "type": "string",
                        "description": "Company code to determine for which entity you want to search",
                        "example": "0001"
                    },
                    "distributor": {
                        "type": "string",
                        "description": "Distributor code to determine for which entity you want to search",
                        "example": "01"
                    },
                    "from": {
                        "type": [
                            "integer",
                            "null"
                        ],
                        "format": "int32",
                        "description": "Index to start the resultset from",
                        "example": 0
                    },
                    "size": {
                        "type": [
                            "integer",
                            "null"
                        ],
                        "format": "int32",
                        "description": "Maximum amount of results to deliver",
                        "example": 10
                    }
                },
                "required": [
                    "company",
                    "distributor",
                    "isin",
                    "language"
                ]
            },
            "LatestMessageResponse": {
                "type": "object",
                "properties": {
                    "message": {
                        "$ref": "#/components/schemas/Message"
                    }
                }
            },
            "LatestMessageDTO": {
                "type": "object",
                "properties": {
                    "language": {
                        "type": "string",
                        "enum": [
                            "de",
                            "en",
                            "fr",
                            "nl"
                        ]
                    },
                    "isin": {
                        "type": "string",
                        "description": "Isin",
                        "example": "BE0123456789"
                    },
                    "company": {
                        "type": "string",
                        "description": "Company code to determine for which entity you want to search",
                        "example": "0001"
                    },
                    "distributor": {
                        "type": "string",
                        "description": "Distributor code to determine for which entity you want to search",
                        "example": "01"
                    }
                },
                "required": [
                    "company",
                    "distributor",
                    "isin",
                    "language"
                ]
            }
        }
    }
}

ACTUAL:

{
    "openapi": "3.1.0",
    "info": {
        "title": "Messages API",
        "description": "This app provides REST APIs for asset management messages requests",
        "version": "v1"
    },
    "servers": [
        {
            "url": "https://x9y-i.local.intapp.eu/X9Y-I/messages-search-service",
            "description": "Generated server url"
        }
    ],
    "tags": [
        {
            "name": "Messages",
            "description": "the Messages API"
        }
    ],
    "paths": {
        "/messages/v1/search": {
            "post": {
                "tags": [
                    "Messages"
                ],
                "operationId": "getMessagesForIsin",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "string",
                                "default": ""
                            }
                        }
                    },
                    "required": true
                },
                "responses": {
                    "400": {
                        "description": "Bad request"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "413": {
                        "description": "Content Too Large"
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MessageSearchResponse",
                                    "additionalProperties": {
                                        "default": ""
                                    },
                                    "default": ""
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Internal server error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MessageSearchResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/messages/v1/search/latest": {
            "post": {
                "tags": [
                    "Messages"
                ],
                "operationId": "getLatestMessagesForIsin",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "string",
                                "default": ""
                            }
                        }
                    },
                    "required": true
                },
                "responses": {
                    "400": {
                        "description": "Bad request"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "413": {
                        "description": "Content Too Large"
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/LatestMessageResponse",
                                    "additionalProperties": {
                                        "default": ""
                                    },
                                    "default": ""
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Internal server error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/LatestMessageResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/management/messages/v1/search": {
            "post": {
                "tags": [
                    "Messages"
                ],
                "operationId": "getMessagesForIsin_1",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "string",
                                "default": ""
                            }
                        }
                    },
                    "required": true
                },
                "responses": {
                    "400": {
                        "description": "Bad request"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "413": {
                        "description": "Content Too Large"
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MessageSearchResponse",
                                    "additionalProperties": {
                                        "default": ""
                                    },
                                    "default": ""
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Internal server error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MessageSearchResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/management/messages/v1/search/latest": {
            "post": {
                "tags": [
                    "Messages"
                ],
                "operationId": "getLatestMessagesForIsin_1",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "string",
                                "default": ""
                            }
                        }
                    },
                    "required": true
                },
                "responses": {
                    "400": {
                        "description": "Bad request"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "413": {
                        "description": "Content Too Large"
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/LatestMessageResponse",
                                    "additionalProperties": {
                                        "default": ""
                                    },
                                    "default": ""
                                }
                            }
                        }
                    },
                    "500": {
                        "description": "Internal server error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/LatestMessageResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/probe/readiness": {
            "get": {
                "tags": [
                    "health-controller"
                ],
                "operationId": "ready",
                "responses": {
                    "400": {
                        "description": "Bad Request",
                        "content": {
                            "*/*": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "413": {
                        "description": "Content Too Large"
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "text/plain": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/probe/liveness": {
            "get": {
                "tags": [
                    "health-controller"
                ],
                "operationId": "alive",
                "responses": {
                    "400": {
                        "description": "Bad Request",
                        "content": {
                            "*/*": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "413": {
                        "description": "Content Too Large"
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "text/plain": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "Message": {
                "type": "null",
                "properties": {
                    "contentId": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "default": "",
                        "description": "Content ID of the message",
                        "example": "content-id-123"
                    },
                    "typeId": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "default": "",
                        "description": "Content Type of the message",
                        "example": "content-type-123"
                    },
                    "title": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "default": "",
                        "description": "Title of the message",
                        "example": "Amerika kiest voor 'amerika first'"
                    },
                    "articleDate": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "default": "",
                        "description": "The article date of the message",
                        "example": "2025-11-07T16:30:22.577395+01:00"
                    }
                }
            },
            "MessageSearchResponse": {
                "type": "object",
                "properties": {
                    "total": {
                        "type": [
                            "integer",
                            "null"
                        ],
                        "format": "int64",
                        "default": ""
                    },
                    "hits": {
                        "type": "array",
                        "default": "",
                        "items": {
                            "$ref": "#/components/schemas/Message"
                        }
                    }
                }
            },
            "LatestMessageResponse": {
                "type": "object",
                "properties": {
                    "message": {
                        "$ref": "#/components/schemas/Message",
                        "default": ""
                    }
                }
            }
        }
    }
}

The openapi.json is generated by the annotation generated by the openapi-generator tool.

The generated controller:

@Validated
@Tag(
   name = "Messages",
   description = "the Messages API"
)
public interface MessagesApi {
   String PATH_GET_LATEST_MESSAGES_FOR_ISIN = "/messages/v1/search/latest";
   String PATH_GET_MESSAGES_FOR_ISIN = "/messages/v1/search";

   default MessagesApiDelegate getDelegate() {
      return new MessagesApiDelegate() {
      };
   }

   @Operation(
      operationId = "getLatestMessagesForIsin",
      tags = {"Messages"},
      responses = {@ApiResponse(
   responseCode = "200",
   description = "OK",
   content = {@Content(
   mediaType = "application/json",
   schema = @Schema(
   implementation = LatestMessageResponse.class
)
)}
), @ApiResponse(
   responseCode = "400",
   description = "Bad request"
), @ApiResponse(
   responseCode = "403",
   description = "Forbidden"
), @ApiResponse(
   responseCode = "500",
   description = "Internal server error"
)}
   )
   @RequestMapping(
      method = {RequestMethod.POST},
      value = {"/messages/v1/search/latest"},
      produces = {"application/json"},
      consumes = {"application/json"}
   )
   default ResponseEntity<LatestMessageResponse> getLatestMessagesForIsin(@Parameter(name = "LatestMessageDTO",description = "",required = true) @RequestBody @Valid LatestMessageDTO latestMessageDTO) {
      return this.getDelegate().getLatestMessagesForIsin(latestMessageDTO);
   }

   @Operation(
      operationId = "getMessagesForIsin",
      tags = {"Messages"},
      responses = {@ApiResponse(
   responseCode = "200",
   description = "OK",
   content = {@Content(
   mediaType = "application/json",
   schema = @Schema(
   implementation = MessageSearchResponse.class
)
)}
), @ApiResponse(
   responseCode = "400",
   description = "Bad request"
), @ApiResponse(
   responseCode = "403",
   description = "Forbidden"
), @ApiResponse(
   responseCode = "500",
   description = "Internal server error"
)}
   )
   @RequestMapping(
      method = {RequestMethod.POST},
      value = {"/messages/v1/search"},
      produces = {"application/json"},
      consumes = {"application/json"}
   )
   default ResponseEntity<MessageSearchResponse> getMessagesForIsin(@Parameter(name = "MessageQueryDTO",description = "",required = true) @RequestBody @Valid MessageQueryDTO messageQueryDTO) {
      return this.getDelegate().getMessagesForIsin(messageQueryDTO);
   }
}

Screenshots

ACTUAL:

Image

EXPECTED:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions