swagger-api / swagger-api/swagger-codegen

`file` mapping in Typescript generators

Open
#4,715 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: TypeScript Issue: Non-operational
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

As discovered by @TiFu TS generators do not have a consistent mapping for file at the moment:

The issue you noticed is caused by the typemapping from file => Buffer. This mapping was added to TypeScriptNodeCodegen.java almost a year ago. Somehow the ts node tests still contain the previous any type mapping defined in AbstractTypeScriptCodegen.java.
Another thing I noticed is, that TypeScriptNodeCodegen uses typeMapping.put("file", "Buffer");, whereas AbstratcTypeScriptCodegen uses typeMapping.put("File", "any"); (note the capitalization of file)

Ref: https://github.com/swagger-api/swagger-codegen/pull/4264#issuecomment-277345595

Swagger-codegen version

2.3.0

Related issues

https://github.com/swagger-api/swagger-codegen/pull/4264#issuecomment-277345595

Suggest a Fix

We'll need to review and fix the mapping for file

cc @Vrolijkx

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

Compare the file mappings in TypeScriptNodeCodegen.java and AbstractTypeScriptCodegen.java, including the capitalization difference and the existing TypeScript node tests. Review the related pull request comment, then run the TypeScript node tests after making the mappings consistent and verifying that the expected file type is used.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript
Domain
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.