Skip to content

Fix form/explode=false incorrectly splitting primitive string values on commas#119

Open
f-kanari wants to merge 1 commit intooapi-codegen:mainfrom
f-kanari:fix/explode-default-behaviour
Open

Fix form/explode=false incorrectly splitting primitive string values on commas#119
f-kanari wants to merge 1 commit intooapi-codegen:mainfrom
f-kanari:fix/explode-default-behaviour

Conversation

@f-kanari
Copy link
Copy Markdown

@f-kanari f-kanari commented Apr 7, 2026

Summary

BindQueryParameterWithOptions and BindRawQueryParameter unconditionally split query parameter values on commas when explode=false, even for primitive (non-array, non-object) destination types. This causes
parameters like scope=openid,profile,email to fail with:

Invalid format for parameter scope: multiple values for single value parameter 'scope'

Per the OpenAPI specification, explode has no effect on primitive types — the serialization is identical regardless of the explode value:

Type explode=true explode=false
primitive id=5 id=5
array id=3&id=4&id=5 id=3,4,5
object role=admin&firstName=Alex role,admin,firstName,Alex

Comma splitting is only meaningful for array and object types.

Changes

  • bindparam.go: In both BindQueryParameterWithOptions and BindRawQueryParameter, check the destination type before splitting on commas. For primitive types (reflect.Kind is not Slice, Struct, or
    Map), bind the raw value directly without splitting.

How it was tested

  • Added regression tests for BindQueryParameter with form/explode=false binding a comma-containing string (required and optional variants)
  • Added regression tests for BindRawQueryParameter with form/explode=false binding a percent-encoded comma-containing string (required and optional variants)
  • All existing tests continue to pass

Related

This is similar in spirit to #115 / #114, which fixed the same class of bug in BindStyledParameterWithOptions for simple/form style parameters. This PR addresses the equivalent issue in the query parameter
binding functions.

@f-kanari f-kanari marked this pull request as ready for review April 7, 2026 03:01
@f-kanari f-kanari requested a review from a team as a code owner April 7, 2026 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant