Skip to content

Generated TypeScript-Code calls the HttpClient with ResponseType 'blob' by default (instead of 'json') #15316

@kotlincook

Description

@kotlincook

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

If the consumer does not explicitly define the content type (in Java con consumes = MediaType.APPLICATION_JSON_VALUE) then the generated TypeScript code is like

 public saveOrder(orderId: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: '*/*', context?: HttpContext}): Observable<Angebot>;

Important is httpHeaderAccept?: '*/*',

This leads to the fact that in the following generated lines

       let responseType_: 'text' | 'json' | 'blob' = 'json';
        if (localVarHttpHeaderAcceptSelected) {
            if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
                responseType_ = 'text';
            } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
                responseType_ = 'json';
            } else {
                responseType_ = 'blob';
            }
        }

the responseType is set to 'blob'. I don't think that was intended.

openapi-generator version

This Bug exists since version 5.4.0.

Suggest a fix

Consider also the case */* in the code above.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions