[BUG] [cpp-qt5-client] Response headers are checked using case sensitive string comparison
Created by: st-agnes
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
I've got the following issue with the cpp-qt5-client generator: If the server sends a "content-type" header using lowercase letters for "content-type" (rather than "Content-Type"), the response body isn't read by the client. It seems to me that the issues lays in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpRequest.cpp.mustache where a case-sensitive comparison of strings is performed (see method process_response).
openapi-generator version
Version 5.1.0
OpenAPI declaration file content or url
Here's the yaml I'm using - I've shortened it for brevity:
---
openapi: 3.0.0
info:
title: Team API
version: 1.0.0-oas3
servers:
- url: https://localhost:5001/api/v1
tags:
- name: authentication
paths:
/login:
post:
operationId: Login
tags:
- authentication
summary: User login
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/LoginRequest'
required: true
responses:
"200":
description: Successful login
content:
application/json:
schema:
$ref: '#/components/schemas/LoginResponse'
"400":
description: Invalid request parameter
"403":
description: Invalid login data
components:
schemas:
LoginRequest:
properties:
teamId:
type: integer
example: 12345
password:
type: string
format: password
example: abcd6789
required:
- teamId
- password
additionalProperties: false
LoginResponse:
type: object
properties:
accessToken:
type: string
description: User Access token
example: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiVGVhbSA0NSIsImlhdCI6MTYxMDgxMjgwMCwiZXhwIjoxNjEwODk5MjAwLCJ0ZWFtSWQiOiI0NSIsInNlc3Npb25JZCI6ImM1MWNlMTVmLTU4MWItMTFlYi05NjY1LTQyMDEwYTljMDA5NiIsInJvbGUiOiJwbGF5ZXIifQ.kguZV64mj7PIDCwQjMzRk2K-ivhD59uVixDIF6v7LkOTQ5kE0n0b-ICHP3xly7iY_0Tp-9shUg-bONwnk2_yuAlv1BVoo18ZE6kNHmvf1nvR6tGxWL4lcBJ1oYg_bPaEHJlSuInEKj-PJKxykPCTPPiqlsZn2ffMfm720qajMpSojFbNZH6CGlqYvC1TBjy1qBD1r-pVqRiSIdJDvAg6dByIbHPJfhoi-xrL2X55GxDpOXdmcKRLOPJ2Jndcaau2IgqkrVE9BxM3i62HGConYxyoKrqzKNnJE9NiWcmzBzihCgtS8COcHDQ_kYHIVGsyiaR4ugy2VC7zijM9CzPq_g
additionalProperties: false
Generation Details
docker run --rm -v %cd%:/local openapitools/openapi-generator-cli generate -i /local/api/team-api-openapi.yaml -g cpp-qt5-client --additional-properties=cppNamespace=autogen::team,modelNamePrefix=teamapi_ -o /local/autogen/team
Steps to reproduce
- Generate a client using qt5-client generator, from any yaml file that defines an endpoint with a response containing a body.
- Create a server that responds with "content-type" rather than "Content-Type" in the header. (For example I'm using asp.net core for the server which does exactly this.)
- Start server and client
- From the client make a request to the mentioned endpoint and observe the result.
The response body will be ignored as if no content had been sent by the server.
Related issues/PRs
No related issues.
Suggest a fix
Case-insensitive string comparison must be used. Or alternatively, headers taken from the response must be transformed to the same format in which they will be checked for later.