When generating typescript-angular, the import for api and modules are generated with backslash:
E.g.
import { ApiResponse } from '../model\apiResponse';
v.3.0.2
http://petstore.swagger.io/v2/swagger.json
java -jar swagger-codegen-cli-3.0.2.jar generate -i http://petstore.swagger.io/v2/swagger.json -l typescript-angular
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
I confirm, getting import { SomeDto } from '../model\someDto'; on Windows 10 with swagger-codegen-cli-3.0.0-20180717.153005-90.jar
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:
supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts"));
supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts"));
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?
Most helpful comment
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:
supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts"));supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts"));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?