Skip to content

[BUG] [Typescript] Application/JSON query parameter not serialized correctly #6367

Description

@gbertoncelli

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used? 4.3.0
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

I'm trying to generate the SDK with this endpoint definition:

  '/entities/{id}/secondentities':
    get:
      operationId: getSecondEntitiesByEntities
      tags:
        - channels
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          required: true
        - $ref: '#/components/parameters/problematicParameter'
      responses:
        '200':
          $ref: '#/components/responses/data200'
        '404':
          description: Not found
        '500':
          description: Internal server error

and the parameter is described as a content/application-json complex object that should be serialized in the query string:

    problematicParameter:
      in: query
      required: false
      name: filter
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/problematicParameterSchema'

The schema is something like this:

    problematicParameterSchema:
      type: object
      properties:
        tags:
          type: array
          items:
            type: string
        attributes:
          type: array
          items:
            type: string

The generated typescript code has a signature like this:

    public getSecondEntitiesByEntities(id: number, filter?: ProblematicParameterSchema, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<Array<PlacemarkData>>;

The model of ProblematicParameter is correctly generated, but when I call this function with a valid object of type ProblematicParameterSchema the URL is not generated correctly.

For example with:

getSecondEntitiesByEntities(1, {attributes: ['c', 'd'], tags: ['a', 'b']})

the generated URL is:

API_BASE/entities/{id}/secondentities?attributes="c"&attributes="d"&tags="a"&tags="b"

completely ignoring the name filter of the parameter.
The expected result should be something like this:

API_BASE/entities/{id}/secondentities?filter='{"attributes": ["c", "d"], "tags": ["a", "b"]}'
openapi-generator version

4.3.0

OpenAPI declaration file content or url
Command line used for generation
openapi-generator generate -i oas3.json -o sdk -g typescript-angular
Steps to reproduce
  1. Create the schema described above
  2. Create the parameter described above
  3. Run
Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions