Skip to content

Required multipart/form-data parameters not reflected in generated schema #1106

Closed
@ali-rantakari

Description

@ali-rantakari

Given a REST controller handler method like this (note how one parameter (stringParam) is required, while the other (fileParam) is not — as per the required property of the @RequestPart annotation):

@PostMapping("/foo", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
fun foo(
    @RequestPart stringParam: String,
    @RequestPart(required = false) fileParam: MultipartFile?
) {}

…SpringDoc produces an API definition that looks something like this (note how neither of the parameters are marked as required):


"requestBody": {
  "content": {
    "multipart/form-data": {
      "schema": {
        "properties": {
          "fileParam": {
            "format": "binary",
            "type": "string"
          },
          "stringParam": {
            "type": "string"
          }
        },
        "type": "object"
      }
    }
  }
},

Expected: the multipart/form-data schema object in the generated spec to include "required": ["stringParam"].

Using:

  • Spring boot v. 2.4.2
  • springdoc-openapi-ui v. 1.5.4
  • springdoc-openapi-kotlin v. 1.5.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions