Skip to content

[BUG] validation constraints for parameters in request body of form request are not generated (at least with Spring Boot generator) #21750

@oliverkuntze

Description

@oliverkuntze

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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

At least for the Spring Boot code generator:

Validation constraints like minLength, maxLength, pattern defined for parameters within request bodies of
application/x-www-form-urlencoded content are not generated in the API interfaces.

The formParams.mustache is missing the beanValidationBodyParams template call (as opposed for example to the regular bodyParams.mustache).

I have provided a PR that fixes this problem for the Spring Boot generator -> #21749

Please let me know if there is anything more I can / have to do to get this fix included in the next release ;-)

openapi-generator version

7.14.0

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: Test form
  version: 1.0.0
servers:
  - url: https://where.am.i
paths:
  /add:
    post:
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - id
                - quantity
              properties:
                name:
                  type: string
                  pattern: '^[[:print:]]+$'
                quantity:
                  type: integer
                  minimum: 1
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: boolean
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix

I fixed this in #21749

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