OpenAPITools / OpenAPITools/openapi-generator

[BUG][Typescript Axios] Binary format for strings always generate `any` type

Open
#12,744 5 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

Description

When trying to generate a binary type for typescript, it always comes up with any

Im find code:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java#L438-L442

but this code dont working correctly?

openapi-generator version

5.4.0

OpenAPI declaration file content or url
objectTest:
  type: object
  description: 'test object'
  properties:
    file:
      type: string
      format: binary
Generation Details

Generated to:

export interface IObjectTest {
    /**
     * 
     * @type {any}
     * @memberof IObjectTest
     */
    file?: any;
}
Steps to reproduce
  1. Create any field (type = string, format = binary)
  2. Generate

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 in modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java around lines 438-442. Reproduce the issue with the provided binary string property and inspect the generated TypeScript interface. Done means the generated field no longer receives the unintended any type, with the relevant generator behavior covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.