Swagger-codegen: Broken typescript-angular default.service.ts

Created on 12 Feb 2019  路  6Comments  路  Source: swagger-api/swagger-codegen

Description

The generated angular file default.service.ts uses wrong import path delimiters on windows installation.
import { UpdateInfo } from '../modelupdateInfo';
Most propably it is using windows path seperator while doing path concatenation, what is not correct way how angular import path should be constructed.

Expected value is import { UpdateInfo } from '../model/updateInfo';

The generated file has also missing } bracket before EOF.

There is missing body parameter in generated post method:
return this.httpClient.post(${this.basePath}/someurl,
body, ---is missing in generated code
{ ....

The import path issue is also in generated api.module.ts containing
import { DefaultService } from './apidefault.service';

The generation was invoked by swager-codegen-cli with parameter -l typescript-angular

Swagger-codegen version

3.0.rc2 and 3.0.4

Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

Most helpful comment

Regarding to the missing body parameters, any updates on it?

All 6 comments

Yes, happens the same to me on v3.0.4 from a simple yaml file where my endpoint has one parameter.

Regarding to the missing body parameters, any updates on it?

Do you guys know how to rename this DefaultService in config?

I don't know why but the codegen doesn't add the body on post endpoints.

In exemple for me I had:

return this.httpClient.post('${this.basePath}/notifications/subscribe',
{
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);

So i add manually the , body after the url.

return this.httpClient.post('${this.basePath}/notifications/subscribe', body,
{
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);

I think the problem is caused by "isBodyAllowed()" method in "modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java".
Because after I removed {{#isBodyAllowed}}{{isBodyAllowed}} in "/handlebars/typescript-angular/api.service.mustache" the problem was solved.
Of course, there may be other trouble if removing "isBodyAllowed" tag, but it's fine for me.

Was this page helpful?
0 / 5 - 0 ratings