Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The recent change in OpenAPI Generator introduced by PR #20681 is causing issues with how query parameters are serialized in the generated Angular TypeScript SDK.
Previously, when an object was passed as a query parameter (e.g., {"alias":"test"}
), the generator would append each object's property as a separate query parameter. Now, it serializes the entire object, which results in incorrect query parameter construction.
openapi-generator version
The issue arises in OpenAPI Generator version v7.12.0.
OpenAPI declaration file content or url
openapi: 3.0.0
info:
version: 0.0.22
title: <title>
description: <description>
contact:
name: ...
email: ...
paths:
/instances/lookup:
get:
summary: Get instance by alias
description: Get instance by alias
operationId: instanceLookup
security: []
tags:
- Instance
parameters:
- $ref: "#/components/parameters/instanceAlias"
responses:
"200":
$ref: "#/components/responses/getInstanceConfigResponse"
"400":
$ref: "#/components/responses/badRequest"
"404":
$ref: "#/components/responses/notFound"
components:
parameters:
instanceAlias:
name: alias
in: query
required: true
description: Instance alias kebab case
example: "test-alias"
schema:
type: string
additionalProperties: false
description: Instance alias kebab case
pattern: '[a-z0-9]+(?:-[a-z0-9]+)*' # kebab-case
Generation Details
The generator was ran as a GitHub action:
name: Generate Angular SDK
on:
push:
branches: [ 'main' ]
paths: [ 'api/openapi.yaml' ]
workflow_dispatch:
jobs:
generate-angular-client:
runs-on: ubuntu-latest
name: Builder
steps:
# Checkout your code
- name: Checkout
uses: actions/checkout@v3
- name: Generate Angular Client
uses: openapi-generators/openapitools-generator-action@v1
with:
openapi-file: api/openapi.yaml
generator: typescript-angular
...
Steps to reproduce
- Generate the SDK using the OpenAPI specs
- Call the generated function
instanceLookup({ alias: 'test' })
. - Observe the generated query parameter string in the resulting GET request.
Expected: https://www.example.com/instances/lookup?alias=test
Actual: https://www.example.com/instances/lookup?alias=%7B%22alias%22%3A%22test%22%7D
Related issues/PRs
The issue appears to be related to PR #20681.
Suggest a fix
The regression seems to be related to the serialization logic where objects are being stringified. The logic should be updated to append individual object properties instead of the entire object being serialized as a string.