OpenAPITools / OpenAPITools/openapi-generator
[BUG][TYPESCRIPT-AXIOS] Typescript-axios generator creates the wrong return type and encoding
Nobody has claimed this yet.
- 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
- One weird thing is that the Data Api
getDocumentWithPathfunction was generated withDeletePolicyModule200Responsewhich is definitely not the expected case. - The path param in
getDocumentWithPathis getting encoded so I can't reach nested paths (e.g/firstPath/secondPath) since it is trying to get tofirstPath%2FsecondPaththat doesn't exist, which makes a lot of sense. Maybe there's a possibility to utilize the theurlfield in the axios config argument that is passed as the last param of the function
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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