swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

Broken typescript-angular default.service.ts

Open jamajamik opened this issue 7 years ago • 6 comments

Description

The generated angular file default.service.ts uses wrong import path delimiters on windows installation. import { UpdateInfo } from '../model\updateInfo'; 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 './api\default.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

jamajamik avatar Feb 12 '19 08:02 jamajamik

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

micaelboucard avatar Feb 17 '19 22:02 micaelboucard

Almost the same as https://github.com/swagger-api/swagger-codegen/issues/8930

xarling avatar Feb 18 '19 12:02 xarling

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

andrew-yangy avatar Mar 06 '19 05:03 andrew-yangy

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

micaelboucard avatar Mar 08 '19 03:03 micaelboucard

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 } );

ycocatrix avatar Mar 11 '19 15:03 ycocatrix

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.

Wooyme avatar Mar 19 '19 12:03 Wooyme