Skip to content

Using explode=false in query string doesn't work properly #2183

@TelpeNight

Description

@TelpeNight
go version: 1.25.5
oapi-codegen: 2.5.1

Here is the sample repository: https://github.com/TelpeNight/open-api-test/blob/main/explode_test.go

I believe, that param serialization with explode=false doesn't follow openapi spec. Here is the example from https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#style-examples:

array -> ["blue", "black", "brown"]
style=form,explode=false -> ?color=blue,black,brown

But running the sample:

Sending: [blue black brown]
Query: search_terms=blue%2Cblack%2Cbrown
Received: &[blue black brown]

Commas are escaped, through it seems they shouldn't.

But this also leads to bad client <-> server communication when search_terms (in this case) contains comma:

Sending: [a b c,d]
Query: search_terms=a%2Cb%2Cc%2Cd
Received: &[a b c d]

Note, that we are sending 3 terms, but receiving 4.

I believe that the right query string should be search_terms=a,b,c%2Cd. And it should be split on the first step, and then unescaped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions