Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Regression: @Header(schema = @Schema(type = "string")) generates empty or broken schema in OpenAPI output since 2.8.0 #2972

@bvo42

Description

@bvo42

Description:

In versions prior to 2.8.0 of springdoc-openapi, using @Header with @Schema(type = "string") correctly generated the expected schema in the OpenAPI documentation.

However, starting with 2.8.0, the generated schema became incorrect, and as of 2.8.6 it results in a completely empty schema.


Reproducer Example:

@ApiResponse(
  responseCode = "201",
  description = "Created",
  headers = {
    @Header(name = "Location", required = true, schema = @Schema(type = "string"))
  }
)

Expected OpenAPI Output (as seen with 2.7.0):

headers:
  Location:
    required: true
    schema:
      type: string
    style: simple

Actual Output:

  • With 2.8.0:
headers:
  Location:
    required: true
    schema:
      example: null
    style: simple
  • With 2.8.6:
headers:
  Location:
    required: true
    schema: {}
    style: simple

Workaround:

Switching to implementation = String.class fixes the issue:

@Header(name = "Location", required = true, schema = @Schema(implementation = String.class))

This produces the correct OpenAPI YAML again.


Environment:

  • springdoc-openapi version: 2.8.6
  • Spring Boot version: 3.4.4
  • Java version: OpenJDK 17

Additional Notes:

This seems to be a regression introduced in 2.8.0. The schema handling for headers appears to be broken when using type = "string", which previously worked. The problem did not exist in 2.7.0.

Please let me know if you need a full minimal sample project to reproduce.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    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