Skip to content

[BUG][JAVA] ApiClient.basePath doesnt respect relative urls as described in the openapi definition #19475

@thmsckldt

Description

@thmsckldt

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

The generator prefixes the basePath variable in class ApiClient with "http://localhost" when servers[0].url == '/api-xyz'
resulting in a basePath == 'http://localhost/api-xyz'

The expected basePath is '/api-xyz'

openapi-generator version

7.2.0

OpenAPI declaration file content or url
openapi: "3.0.3"
info: 
  title: "test api"
  version: v1
servers: 
  - url: "/api-xyz"
paths: 
 "/account/v1/json/login":
    post: 
      responses:
        '201':
          description: Created
      requestBody: 
        description: ""
        content: 
          "application/json": 
            schema: 
              type: object
              properties: 
                emailAddress: 
                  type: string
                password: 
                  type: string
Related issues/PRs

#10056

Suggest a fix

The regex used in

return Pattern.matches("^(\\/[\\w\\d]+)+", firstServer.getUrl());
doesnt allow special characters in relative paths.

Suggestion: ^(\/[\w\d_-]+)+
(will allow "-" and "_" in relative paths)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions