OpenAPITools / OpenAPITools/openapi-generator

[BUG][Angular] Query parameters with additionalProperties not serialized

Open
#3,935 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Client: TypeScript Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Having the following spec:

'/v1/job':
    get:
      parameters:
      ...
        - name: sort
          in: query
          required: false
          style: form
          explode: false
          schema:
            type: object
            additionalProperties:
              type: string
              enum:
                - asc
                - desc

The TS is correctly generated:

    getJobs(jobType: string, search?: string, limit?: number, page?: number, sort?: {
        [key: string]: 'asc' | 'desc';
    }, observe?: 'body', reportProgress?: boolean): Observable<Page>;

But the item is not serialized, instead I get a query like this: host/job?sort=[object Object]

Command line used for generation

/bin/docker run [...] openapitools/openapi-generator-cli generate -i source.yaml -g typescript-angular -o /data/sdk/angular --additional-properties=npmName=@api,withInterfaces=true,ngVersion=7.0.0

Suggest a fix/enhancement

Dictionary types should be serialized according to https://swagger.io/docs/specification/serialization/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the supplied OpenAPI specification and the typescript-angular generator command. Start by tracing how the generated getJobs method serializes query parameters, focusing on object values with additionalProperties. Done means the sort dictionary is serialized according to the referenced OpenAPI rules instead of becoming [object Object].

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, openapi, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.