Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3399
Closed
Open
Issue created Jul 19, 2019 by Martin Delille@MartinDelilleContributor4 of 6 checklist items completed4/6 checklist items

[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 not https://api.myapp.com?
  • How do handle the https protocol ?

Ping @ravinikam @stkrwork @etherealjoy

Assignee
Assign to
Time tracking