I tried to use ng-openapi-gen to generate the service for querying the backend, but the generated responseType is not the right one (I want it to be 'text').
In the backend, using nestJS, defined the following function:
@ApiResponse({
status: 200,
description: 'Get the name of the file after download',
type: String
})
public async getCalibrationDownloadFilename(@Param('someId', new ParseIntPipe()) someId: number): Promise<string> {
...
}
When using the command ng-openapi-gen in the frontend (Angular), it generates:
calibrationCertificateControllerGetCalibrationDownloadFilename$Response(params: {
someId: number;
}): Observable<StrictHttpResponse<string>> {
const rb = new RequestBuilder(this.rootUrl, CalibrationSensorCertificationService.CalibrationCertificateControllerGetCalibrationDownloadFilenamePath, 'get');
if (params) {
rb.path('someId', params.someId, {});
}
return this.http.request(rb.build({
responseType: 'json',
accept: 'application/json'
})).pipe(
filter((r: any) => r instanceof HttpResponse),
map((r: HttpResponse<any>) => {
return r as StrictHttpResponse<string>;
})
);
}
The responseType is json instead of text.
If, in the backend, I remove the type: String, the responseType is set to text, but then the function return type becomes Observable<StrictHttpResponse<void>>.
I tried to set the type to string, and a 'string' but then I get errors.
How to properly set-up swagger for generating a function which returns an observable of string, and set the responseType of the query to be 'text'?