Skip to content

Fix #7866: Incorrect handling of --model-name-prefix/suffix (typescri… #7869

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

univac490
Copy link

@univac490 univac490 commented Mar 18, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows.
  • Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.
    @TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny

Description of the PR

Fix import in *.service.ts when using --model-name-prefix or --model-name-suffix

java -jar swagger-codegen-cli.jar generate -l typescript-angular --model-name-prefix swg

Before:

import { SwgSwgError } from '../model/swgSwgError';

After:

import { SwgError} from '../model/swgError';

@@ -377,7 +379,22 @@ public String toModelFilename(String name) {

@Override
public String toModelImport(String name) {
return modelPackage() + "/" + toModelFilename(name);
// with modelNamePrefix/modelNameSuffix, name already includes
Copy link
Contributor

Choose a reason for hiding this comment

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

The implementation lookgs good and well-documented.
However, is there a reason why this isnt implemented in the ‚toModelFilename()‘ method?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, if you implement it in toModelFilename, the file name will become Error.ts, but the import will stay the same:
import { SwgError} from '../model/swgError';

I did run a test to confirm.

@gummibjorn
Copy link

awesome, this PR will fix my issues

filename = StringUtils.removeEnd(filename, modelNameSuffix);
}

return modelPackage() + "/" + filename;

Choose a reason for hiding this comment

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

Filename is capitalised. import { SwgError} from '../model/SwgError'; leads to issues on case sensitive OS at least.

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.

4 participants