OpenAPITools / OpenAPITools/openapi-generator

[BUG][TYPESCRIPT-AXIOS] Typescript-axios generator creates the wrong return type and encoding

Open
#14,985 0 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

I used this official OPA openapi to generate an a client for OPA using typescript-axios

I ran the following to generate the code

npx @openapitools/openapi-generator-cli generate -i openapi.yaml -g typescript-axios -o gen -penumUnknownDefaultCase=true -pnpmName=my-npm-package -pnpmVersion=0.0.1 -pnullSafeAdditionalProps=true -pwithNodeImports=true -pwithSeparateModelsAndApi=true -pmodelPackage=models -papiPackage=api

I also tried with latest cli docker to make sure that it isn't something related to the npx version

  1. One weird thing is that the Data Api getDocumentWithPath function was generated with DeletePolicyModule200Response which is definitely not the expected case.
  2. The path param in getDocumentWithPath is getting encoded so I can't reach nested paths (e.g /firstPath/secondPath) since it is trying to get to firstPath%2FsecondPath that doesn't exist, which makes a lot of sense. Maybe there's a possibility to utilize the the url field in the axios config argument that is passed as the last param of the function

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 command with the linked OPA openapi.yaml and inspect the generated Data API method getDocumentWithPath. Compare its return type with the operation in the specification and check how its path parameter is encoded; done means the generated method uses the expected response type and can address nested paths containing slashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.