Skip to content

application/x-www-form-urlencoded destructure generates @NotNull on optional form parameters #478

Closed

Description

@phlawski

Follow-up to #412, which introduced application/x-www-form-urlencoded destructure support in 2026.2.

When using body-style: destructure (the default) for a application/x-www-form-urlencoded requestBody, the processor adds @NotNull to all generated @RequestParam parameters regardless of whether the field is listed in the schema's required array.

Expected: Only parameters listed in required should get @NotNull. Optional fields should get @RequestParam(name = "foo" required = false) with no @NotNull.

Actual: All destructured form parameters get @NotNull, making it impossible to call the endpoint without providing all fields - breaking flows like OAuth2 refresh_token where code, code_verifier, redirect_uri are legitimately absent.

Reproduction:

  requestBody:
    content:
      application/x-www-form-urlencoded:
        schema:
          type: object
          required:
            - grant_type
          properties:
            grant_type:
              type: string
            code:
              type: string        # optional — NOT in required
            code_verifier:
              type: string        # optional — NOT in required

Generates:

 @RequestParam(name = "grant_type") @NotNull String grantType,
 @RequestParam(name = "code") @NotNull String code,           // wrong
 @RequestParam(name = "code_verifier") @NotNull String codeVerifier  // wrong

Expected:

@RequestParam(name = "grant_type") @NotNull String grantType,
@RequestParam(name = "code", required = false) String code,
@RequestParam(name = "code_verifier", required = false) String codeVerifier

Version: openapi-processor-spring:2026.3.1

Activity

  1. added this to the 2026.4 milestone on Jun 29, 2026
  2. hauner commented on Jun 29, 2026

    @hauner
    Member

    I can reproduce this, looking at it.

  3. hauner commented on Jul 1, 2026

    @hauner
    Member

    thanks for reporting :-)

  4. modified the milestones: 2026.4, 2026.3.2 on Jul 5, 2026
  5. hauner commented on Jul 7, 2026

    @hauner
    Member

    fixed in openapi-processor-spring 2026.3.2

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions