Skip to content

Support parameter expansion for application/x-www-form-urlencoded similar to multipart/form-data #412

@phlawski

Description

@phlawski

Description

While using openapi-processor-spring, I noticed an inconsistency in how
multipart/form-data and application/x-www-form-urlencoded request bodies
are handled.

According to the documentation:
https://openapiprocessor.io/spring/processor/requestbody.html#_multipartform_data

Instead of generating a @RequestBody parameter for the object schema the
processor creates a parameter for each property of the object annotated
with @RequestParam

This behavior works very well for multipart/form-data.

However, for application/x-www-form-urlencoded, the processor always generates
a single @RequestBody parameter, even when the request body schema is an
object with simple scalar properties.

In Spring MVC, both multipart/form-data and
application/x-www-form-urlencoded are typically handled as request parameters
(@RequestParam / form fields), not as a raw request body.

This causes issues for common and important use cases such as OAuth2 token
endpoints (/token), where application/x-www-form-urlencoded is required
by the specification.


Expected behavior

For application/x-www-form-urlencoded request bodies with an object schema,
the processor should generate one @RequestParam per property, similar to the
existing behavior for multipart/form-data.

Example OpenAPI:

requestBody:
  content:
    application/x-www-form-urlencoded:
      schema:
        type: object
        properties:
          grant_type:
            type: string
          code:
            type: string

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions