OpenAPITools / OpenAPITools/openapi-generator

[BUG][typescript-axios] Broken client

Open
#9,036 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

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?
Description

openapi-generator create broken client for attached schema.
Errors:

  • Types error:
  > 75 |         apiProblemCreate: async (tags: Array<ProblemTagRequest>, options: any = {}): Promise<RequestArgs> => {
       |                                              ^ // ProblemTagRequest does not exist
    76 |             // verify required parameter 'tags' is not null or undefined
    77 |             assertParamExists('apiProblemCreate', 'tags', tags)
    78 |             const localVarPath = `/api/problem/`;
  • DataForm usage error
92 |  localVarFormParams.append(tags.join(COLLECTION_FORMATS.csv));
                               ^ // here should be append('tags', tags...
  • wrong array usage
92 |    localVarFormParams.append(tags.join(COLLECTION_FORMATS.csv));
                                         ^ // join returns [object Object],[object Object],
openapi-generator version

5.0.1
latest dev version

OpenAPI declaration schema

https://gist.github.com/vmstarchenko/9671d45499a66d73b6746e69168c6cc5

Generation Details
java -jar ./openapi-generator-5.0.1/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ./api-spec.yaml -g typescript-axios --additional-properties=useSingleRequestParameter=true -o ./client/typescript-axios

Generated client:
https://gist.github.com/vmstarchenko/5128a715559fcb065649b37b316f3be9

Steps to reproduce

Generate typescript-axios client with useSingleRequestParameter additional property and attached schema

Related issues/PRs
Suggest a fix

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

Start by running the documented openapi-generator CLI command with api-spec.yaml and the typescript-axios generator, then inspect the generated client linked in the report. The fix is complete when the generated client defines ProblemTagRequest, uses the expected form field name, and serializes the array values correctly.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.