OpenAPITools / OpenAPITools/openapi-generator

[BUG][Java] ApiClient.basePath is not a path but an URL

Open
#7,480 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
Description

The ApiClient generated for Java looks like this:

@Component("some.package")
public class ApiClient extends JavaTimeFormatter {
    private boolean debugging = false;
    private HttpHeaders defaultHeaders = new HttpHeaders();
    private MultiValueMap<String, String> defaultCookies = new LinkedMultiValueMap();
    private String basePath = "https://example.org";
    // ...

with string-based getters and setters. But the naming is wrong imho. That's not a path but a (base) URL.

openapi-generator version

5.0.0-beta2

OpenAPI declaration file content or url

not required - use petstore

Generation Details
Steps to reproduce

Generate the petstore example for java, look at the ApiClient.

Related issues/PRs
Suggest a fix
  1. Rename into baseUrl with getBaseUrl and setBaseUrl.
  2. Replace String with java.net.URL - the only usage (in my case) seems to be in ApiClient.buildUrl().

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Generate the petstore example for Java and inspect the generated ApiClient, including its basePath accessors and the buildUrl usage. Confirm whether the intended fix is a naming change, a java.net.URL type change, or both; done means the generated client uses the agreed base URL API consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.