Skip to content

Fix import mappings for service in angular typescript#10644

Merged
macjohnny merged 4 commits intoOpenAPITools:masterfrom
rudolficzek:fix_#5079_import_mappings_for_typescript_angular_service
Oct 26, 2021
Merged

Fix import mappings for service in angular typescript#10644
macjohnny merged 4 commits intoOpenAPITools:masterfrom
rudolficzek:fix_#5079_import_mappings_for_typescript_angular_service

Conversation

@rudolficzek
Copy link
Copy Markdown
Contributor

@rudolficzek rudolficzek commented Oct 20, 2021

fixes #5079
Currently line https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache#L12 causes everything to be imported from ../model/models

So for a mapping :

"importMappings": {
"MyObject": "@company/mylib"
}

actual is:

import { MyObject} from '../model/models';

Expected:

import { MyObject} from '@company/mylib';

Solution exist in typescript-node to handle that. Pr aligns two generators to be symmetric

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
    @petejohansonxo
    @amakhrov

Copy link
Copy Markdown
Contributor

@amakhrov amakhrov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rudolficzek

Thanks for your contribution! The fix look good to me.
Seems that you still need to regenerate samples (bin/generate-samples.sh)

@amakhrov
Copy link
Copy Markdown
Contributor

@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02)

Copy link
Copy Markdown
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@macjohnny macjohnny merged commit d1089d7 into OpenAPITools:master Oct 26, 2021
@macjohnny macjohnny added this to the 5.3.1 milestone Oct 26, 2021
@wing328 wing328 changed the title fix import mappings for service in angular typescript Fix import mappings for service in angular typescript Dec 19, 2021
@ToppScorer
Copy link
Copy Markdown

ToppScorer commented Sep 21, 2022

@rudolficzek @macjohnny @amakhrov

This is not working when using something like

{
  ...
   "modelSuffix": "Model", 
   "modelFileSuffix": ".model",
  ...
}

in the generator configuration. The imports from the api.service.mustache are wrong then:

import { TestModel } from '../model/test-model.model';

but it should be

import { TestModel } from '../model/test.model';

as the file is named test.model.ts and the interface TestModel.

@macjohnny
Copy link
Copy Markdown
Member

@ToppScorer do you want to fix this?

@ToppScorer
Copy link
Copy Markdown

@ToppScorer do you want to fix this?

Unfortunately I'm too busy right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Question][typescript-angular] use imported mapping in service

5 participants