Skip to content

[BUG] List<String> not bound correctly in x-www-form-urlencoded POST requests (JavaSpring generator) #14866

Open

Description

@bjansen

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Since #14449 was fixed, List<String> parameters are not mapped correctly in application/x-www-form-urlencoded requests (the controller receives a null value). @RequestPart does not work, but @RequestParam did.

openapi-generator version

6.4.0 (worked fine in 6.2.1).

OpenAPI declaration file content or url

See reproducer here: bjansen@a4f52bc#diff-4a3bd04de4c3c2657007483855f41966b5bfc3336abacdc74e13ff838341173b

Relevant spec section:

paths:
  /issue:
    post:
      operationId: reproduceIssue
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - in: body
          name: body
          schema:
            type: "object"
            properties:
              listOfStrings:
                type: "array"
                items:
                  type: "string"
      responses:
        '200':
          description: successful operation
Generation Details

./bin/generate-samples.sh ./bin/configs/spring-boot.yaml generates this mapping:

    default ResponseEntity<Void> reproduceIssue(
        @ApiParam(value = "") @Valid @RequestPart(value = "listOfStrings", required = false) List<String> listOfStrings
    ) {
...

The @RequestPart annotation does not bind the list correctly (see test in OpenApiGeneratorApplicationTests of the spring-boot server sample.

Steps to reproduce
Related issues/PRs
Suggest a fix

Activity

  1. changed the title [-][BUG] Description[/-] [+][BUG] `List<String>` not bound correctly in x-www-form-urlencoded POST requests (JavaSpring generator)[/+] on Mar 2, 2023
  2. wing328 commented on Mar 2, 2023

    @wing328
    Member

    @bjansen thanks for reporting the issue. May I know if you can also perform a git bisect to identify the commit that causes the issue?

  3. bjansen commented on Mar 2, 2023

    @bjansen
    ContributorAuthor

    Looks like this one: 4cd0807 (although I didn't do a bisect)

  4. wing328 commented on Mar 2, 2023

    @wing328
    Member

    @bjansen thanks.

    @MetroMarv I wonder if you can take a look at this issue when you've time to see if it's caused by 4cd0807

  5. tofi86 commented on Mar 2, 2023

    @tofi86
    Contributor

    It's indeed caused by 4cd0807, but I'd say this is the correct method to fix #14449 (the multipart issue).

    However, it looks like the fix introduced a regression with request parameters as mentioned in the above example of this issue. No multipart involved here...

  6. pdrosos commented on Jun 17, 2025

    @pdrosos

    This is still an issue with 7.13, any idea if will be fixed and how to avoid it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions