Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Import Mapping seems to not work with typescript-angular #3149

Closed
5 of 6 tasks
filipvh opened this issue Jun 13, 2019 · 7 comments · Fixed by #4341
Closed
5 of 6 tasks

[BUG] Import Mapping seems to not work with typescript-angular #3149

filipvh opened this issue Jun 13, 2019 · 7 comments · Fixed by #4341

Comments

@filipvh
Copy link

filipvh commented Jun 13, 2019

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

I used importMapping in combination with the typescript-angular generator.
Here is a redacted config file:

{
  "npmName": "the-package-name",
  "npmVersion": "1.8.0",
  "ngVersion": "1.7.0",
  "modelFileSuffix": ".type",
  "npmRepository" : "http://domain/is/redacted",
  "snapshot" : false,
  "importMappings": {
        "EnumValue":"some-other-package"
  }
}
openapi-generator version

4.0.1

What happens?
  • The 'EnumValue' is not generated (is missing from model folder) => OK
  • In an other type/interface EnumValue is still refferenced locally => NOK
import { EnumValue } from './enumValue.type';
What was expected?
  • The 'EnumValue' is not generated (is missing from model folder)
  • In an other type/interface EnumValue refferences the external package
import { EnumValue } from 'some-other-package';
Command line used for generation
generate -i model.yaml -g typescript-angular -c config.json -o out
@auto-labeler
Copy link

auto-labeler bot commented Jun 13, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@macjohnny
Copy link
Member

@filipvh would you like to try and fix this issue?

@filipvh
Copy link
Author

filipvh commented Jun 14, 2019

@macjohnny I can try. Wanted to make sure that it is an issue and that there isn't a duplicate i couldn't identify. If one would expect it to do what I expect... :-)

@scottydawg
Copy link
Contributor

@filipvh - I'm up against this issue as well for the TypeScriptNodeClientCodegen. I'm going to look into a fix unless you've already got something going here that might address both.

In the case of the Node client generator, these mappings seem to be intentionally obliterated in the constructor. The Angular generators don't clear the importMappings like that.

@scottydawg
Copy link
Contributor

I was mistaken about the Angular generators; the abstract class that these TypeScript generators all specialize also clears the initMappings in the constructor.

@scottydawg
Copy link
Contributor

@macjohnny @filipvh - I've created a PR that addresses this issue for the Node client generator. It should be a similar fix for the Angular (and other TypeScript) generators. It might be worth putting this change in the abstract class so that all the TS generators can pick it up, but I wanted a small impact crater for now.

@macjohnny
Copy link
Member

anyone interested in porting #3469 to the abstract typescript generator?

macjohnny pushed a commit that referenced this issue Oct 31, 2019
… primitive types (#4341)

* [typescript-angular] Fix importMapping;

#3149

* [typescript] Fix oneOf/anyOf/allOf;

#4130

* [typescript] remove unneeded mapping

#3149

* [typescript] fix import paths and export

#3149
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants