-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[TYPESCRIPT][v3.0.2] Incorrect imports generated with backslash (windows 10) #8930
[TYPESCRIPT][v3.0.2] Incorrect imports generated with backslash (windows 10) #8930
Comments
I confirm, getting |
Still open in 3.0.4 ... |
In https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java the following lines:
replace the '.' character by the File.seperatorChar. The seperatorChar is the system-dependent default name-separator character, which is / for Unix and \ for Windows. Shouldn't it just be / independent of the system? |
Managed to generate a correct typescript-angular client with this generator, give it a try. |
In case you don't want to change the generator and can't wait till this bug is fixed, here's a quick dirty patch for maven you could invoke post code generation and before you start building the generated code: <plugin>
<!-- Hook into Maven's build life cycles and execute custom build that's outside of Maven convention
See https://maven.apache.org/plugins/maven-antrun-plugin/
-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>${ant-contrib.version}</version>
</dependency>
</dependencies>
<executions>
<!-- Default lifecycle -->
<execution>
<id>npm-install</id>
<phase>process-resources</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<condition property="isWindows"><os family="windows" /></condition>
<if>
<equals arg1="${isWindows}" arg2="true" />
<then>
<property name="npm.bin" value="npm.cmd" />
<!-- FIXME: Remove once issue 8930 is fixed -->
<echo message="Patching Swagger's default service on Windows only!" level="info" />
<echo message=" Remove once below bug has been fixed:" level="info" />
<echo message=" https://github.com/swagger-api/swagger-codegen/issues/8930" level="info" />
<!-- Patch this bug by replacing the path separator with the system independent one... -->
<replace file="${project.basedir}/.../generated/swagger-api/api/default.service.ts" token="\" value="/"/>
</then>
<else><property name="npm.bin" value="npm" /></else>
</if>
<available file="${ng-app.node_modules}" type="dir" property="skipNpmInstall"/>
<if>
<equals arg1="${skipNpmInstall}" arg2="true" />
<then>
<echo message="WARNING: ${ng-app.node_modules} exists, skipping npm install!" level="warning" />
</then>
<else>
<exec executable="${npm.bin}" dir="${ng-app.root}" failonerror="true">mvn
<arg value="install"/>
</exec>
</else>
</if>
</tasks>
</configuration>
</execution>
... |
hey @vtecnica @Maxim-Mazurok @dbusacca @xarling , i added a PR solving this issue. can you please check this when you have a chance? |
Description
When generating typescript-angular, the import for api and modules are generated with backslash:
E.g.
Swagger-codegen version
v.3.0.2
Swagger declaration file content or url
http://petstore.swagger.io/v2/swagger.json
Command line used for generation
java -jar swagger-codegen-cli-3.0.2.jar generate -i http://petstore.swagger.io/v2/swagger.json -l typescript-angular
Steps to reproduce
Download or generate swagger-codegen-cli-3.0.2.jar
java -jar swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l typescript-angular
The text was updated successfully, but these errors were encountered: