OpenAPITools / OpenAPITools/openapi-generator

[REQ] Document how import mappings work for TS

Open
#10,887 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

I just can't get the import mappings to work in TS (typescript-fetch) -- are they even supported?. They seem to be completely ignored.

I'm trying to use a custom model already defined in the code. I've tried various combinations of typeMappings, languageSpecificPrimitives and importMappings, but the result is always the same: the import maps are completely ignored and the models end up being imported from ./, which causes an error as they're not defined there.

Describe the solution you'd like

Clear documentation as to how import mappings work with TS, or document that they don't work / are not available.

Describe alternatives you've considered

Created a post on stackoverflow regarding this issue.

Additional context

This is the config I've been playing around with. The import maps seem to have no effect on the generated code.

inputSpec: openapi.yaml
outputDir: generated
generatorName: typescript-fetch
typeMappings:
  User: ApiUser
languageSpecificPrimitives:
  - User
importMappings:
  User: "src/User.ts"
  ApiUser: "src/User.ts"
additionalProperties:
  supportsES6: "true"
  typescriptThreePlus: "true"

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 with the typescript-fetch generator and the YAML configuration shown in the issue, focusing on typeMappings, languageSpecificPrimitives, and importMappings. Determine whether these options are supported and how they affect generated imports, then document the confirmed behavior or limitation with a usable configuration example.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 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.