Skip to content

fix: parse un-exploded query param to map#101

Merged
mromaszewicz merged 1 commit intooapi-codegen:mainfrom
alexdulin:fix-unexploded-map
Mar 2, 2026
Merged

fix: parse un-exploded query param to map#101
mromaszewicz merged 1 commit intooapi-codegen:mainfrom
alexdulin:fix-unexploded-map

Conversation

@alexdulin
Copy link
Contributor

@alexdulin alexdulin commented Mar 2, 2026

This fixes an issue where query parameters that are objects with additional properties cannot be parsed into their values. For example, a query parameter like tags=foo,bar,bim,baz should end up becoming:

map[string]string{
  "foo": "bar",
  "bim": "baz",
}

This adheres to the spec for paramters of style=form and explode=false.

Improves the problem described in oapi-codegen/oapi-codegen#698 for empty schemas with additional properties, but doesn't address the issue of a non-empty schema with additional properties.

This fixes an issue where query parameters
that are objects with additional properties
cannot be parsed into their values. For example,
a query parameter like `tags=foo,bar,bim,baz` should
end up becoming:

```go
map[string]string{
  "foo": "bar",
  "bim": "baz",
}
```

This adheres to the [spec](https://swagger.io/docs/specification/v3_0/serialization/#query-parameters)
for paramters of style=form and explode=false.

Fixes: oapi-codegen/oapi-codegen#698

Signed-off-by: Alex Dulin <alex@morningconsult.com>
@alexdulin alexdulin requested a review from a team as a code owner March 2, 2026 17:49
@mromaszewicz
Copy link
Member

This change is ok, but it doesn't quite fix oapi-codegen/oapi-codegen#698, because in that case, you've got a struct with a map for additional properties, and a custom JSON unmarshaler which knows how to handle it. We'd need something along those lines for parameters as well. It will work in the case where you have an empty schema with only additional properties, since that's converted to a map.

@mromaszewicz mromaszewicz added the bug Something isn't working label Mar 2, 2026
@mromaszewicz mromaszewicz merged commit d4b9383 into oapi-codegen:main Mar 2, 2026
14 checks passed
@alexdulin alexdulin deleted the fix-unexploded-map branch March 2, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants