Skip to content

Explode option in openapi schema is not being respected #1255

@traed

Description

@traed

Description

We have an OpenAPI 3.0 spec that specifies query params like this:

{
  "name": "example",
  "in": "query",
  "description": "",
  "required": false,
  "explode": false,
  "schema": {
	  "type": "array",
	  "items": {
		  "type": "string"
	  }
  }
}

We want it to generate a query param for the request like ?example=e1,e2 but when we generate the client we get ?example=e1&example=e2. We could supply the querySerializer argument to fix this but it should not be needed if already supplied in the spec.

The client config looks like this:

/** @type {import('@hey-api/client-fetch').Config} */
const config = {
	baseUrl: PUBLIC_API_URL,
	throwOnError: true,
	credentials: 'include'
};

Reproducible example or configuration

No response

OpenAPI specification (optional)

{
	"openapi": "3.0.0",
	"info": {
		"title": "Test API",
		"license": {
			"name": "Copyright 2024 Test inc."
		},
		"version": "0.1.0"
	},
	"servers": [
		{
			"url": "http://127.0.0.1:3001",
			"description": "API"
		}
	],
	"paths": {
		"/test": {
			"get": {
				"summary": "Test route",
				"operationId": "get-test",
				"parameters": [
					{
						"name": "example",
						"in": "query",
						"description": "",
						"required": false,
						"explode": false,
						"schema": {
							"type": "array",
							"items": {
								"type": "string"
							}
						}
					}
				],
				"tags": [
					"Test"
				],
				"responses": {
					"200": {
						"description": "List of test items",
						"content": {
							"application/json": {
								"schema": {
									"type": "object",
									"title": "List of test items",
									"required": [
										"meta",
										"items"
									],
									"properties": {
										"meta": {
											"type": "object",
											"title": "Meta data",
											"required": [
												"total"
											],
											"properties": {
												"total": {
													"type": "integer",
													"minimum": 0,
													"maximum": 9223372036854775807
												}
											}
										},
										"items": {
											"type": "array",
											"items": {
												"$ref": "#/components/schemas/TestItem"
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	},
	"components": {
		"securitySchemes": {
			"token": {
				"type": "http",
				"description": "API token",
				"name": "",
				"in": "",
				"scheme": "bearer",
				"bearerFormat": "base32hex"
			}
		},
		"schemas": {
			"TestItem": {
				"type": "object",
				"required": [
					"id"
				],
				"properties": {
					"id": {
						"type": "string"
					}
				}
			}
		}
	},
	"tags": []
}

System information (optional)

MacOS 14.6.1
Node v20.18.0
@hey-api/open-ts v0.55.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Broken or incorrect behavior.important 📌This issue is important and will be addressed when capacity allows.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions