Skip to content

Unexpected "application/json" content generated for request body of a POST operation #3128

@martin-rais-brcm

Description

@martin-rais-brcm

If a POJO model is described as the "application/x-www-form-urlencoded" request body content for the POST operation, see the DemoController#getBytes() in the attached demo project, an unexpected "application/json" content is also added to the OAS. This happens for both OAS 3.0 and 3.1.

To Reproduce
Steps to reproduce the behavior:

  • The spring-boot version is 3.5.7.
  • The springdoc-openapi-starter-webmvc-ui version 2.8.12.
  • Unpack the demo project.
  • In pom.xml toggle between springdoc-openapi-starter-webmvc-ui version 2.8.11 and 2.8.12.
  • Run the project locally and open the spec on http://localhost:8080/v3/api-docs
    • for 2.8.11 the "application/json" requestBody content is not present
    • for 2.8.12 the "application/json" unexpected requestBody content is present

Expected behavior
The "application/json" request body content shall not appear in the generated OAS since an explicit request body content schema is provided by the @RequestBody.content annotation (same behavior as in 2.8.11)

Screenshots
Image

Additional context
Observed also in the version 2.8.14.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions