Bug Report Checklist
Description
@RequestParam is used instead of @RequestPart in a multipart/form-data request when the model contains an additionalProperties tag.
The @RequestPart annotation is correctly generated, if the additionalProperties are removed from the model.
openapi-generator version
Tested with release 7.13.0, 7.14.0 and commit 5eb083e (latest)
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Example API
version: 0.0.1
paths:
/index/file:
post:
summary: Index new files
operationId: IndexFiles
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required:
- file
- additionalMetadata
properties:
file:
type: string
format: binary
additionalMetadata:
$ref: '#/components/schemas/additionalMetadata'
responses:
'200':
description: Indexing successful
components:
schemas:
additionalMetadata:
type: object
required:
- name
- additionalProperties
properties:
name:
type: string
additionalProperties:
type: string
Generation Details
#!/bin/sh
UID=$(id -u)
GID=$(id -g)
docker run --rm \
-u "${UID}":"${GID}" \
-v "${PWD}":/local openapitools/openapi-generator-cli:v7.13.0 generate \
-i /local/openapi.yaml \
-g spring \
--additional-properties=useSpringBoot3=true \
--additional-properties=interfaceOnly=true \
--global-property=debugOperations \
-o /local/target/server
Steps to reproduce
- generate code
- start server
- use swagger ui to send data to the endpoint
- get a 400 status code with the following log
2025-06-24T11:12:40.121+02:00 WARN 51062 --- [nio-8080-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'additionalMetadata' for method parameter type AdditionalMetadata is not present]
Related issues/PRs
I found the following issue, but it seems to be a different problem. At least it does not mention multipart requests.
#13409
Suggest a fix
The isModel field for the param is set to false, if the model contains an additionalProperties tag. If you remove the tag from the example spec, it is set to true and generated correctly.
There is a isMultipart boolean in the operation containing the params. This could be used to determine the correct annotation.
Bug Report Checklist
Description
@RequestParamis used instead of@RequestPartin amultipart/form-datarequest when the model contains anadditionalPropertiestag.The
@RequestPartannotation is correctly generated, if theadditionalPropertiesare removed from the model.openapi-generator version
Tested with release 7.13.0, 7.14.0 and commit 5eb083e (latest)
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
I found the following issue, but it seems to be a different problem. At least it does not mention multipart requests.
#13409
Suggest a fix
The
isModelfield for the param is set tofalse, if the model contains anadditionalPropertiestag. If you remove the tag from the example spec, it is set to true and generated correctly.There is a
isMultipartboolean in the operation containing the params. This could be used to determine the correct annotation.