[BUG] OAS3 server URL/host not parsed
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Hi,
After a long time working on other subject, I come back to openapi-generator because I seriously consider using it for my project.
Description
I'm encountering a issue when generating a Qt5 client where there is a URL generation error: the protocol is not added when building the request:
OAIDefaultApi::OAIDefaultApi() : basePath("/v1"),
host("api.myapp.com"),
timeout(0){
}
...
void
OAIDefaultApi::findContactById(const QString& contact_id) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/contact/{contactId}");
...
}
This code generate the following url: api.myapp.com/v1/contact/{contactId}
instead of https://api.myapp.com/v1/contact/{contactId}
.
There is a easy way to fix it is to call defaultApi.setHost("https://api.myapp.com")
before findContactById
but I guess it might broke in the long term.
openapi-generator version
4.0.3
OpenAPI declaration file content or url
openapi: 3.0.1
servers:
- url: 'https://api.myapp.com/v1'
info:
description: This is myapp.com API.
version: 1.0.0
title: myapp.com
components:
schemas:
Contact:
type: object
required:
- id
- name
properties:
id:
type: string
name:
type: string
paths:
/contact/{contactId}:
get:
operationId: findContactById
parameters:
- name: contactId
in: path
schema:
type: string
required: true
responses:
'200':
description: An contact object
content:
application/json:
schema:
$ref: '#/components/schemas/Contact'
Command line used for generation
openapi-generator generate -i api.yaml -g cpp-qt5-client
Steps to reproduce
After generating the client, try to call the OAIDefaultApi::findContactById()
method and see how the URL is badly formed.
Related issues/PRs
None
Suggest a fix
I'll be happy to fix it but I'd like to have some direction how we should handle this case:
- Do we agree that here the host is
api.myapp.com
and nothttps://api.myapp.com
? - How do handle the
https
protocol ?
Ping @ravinikam @stkrwork @etherealjoy