Skip to content

Conversation

@svenallers
Copy link
Contributor

@svenallers svenallers commented Feb 2, 2026

This PR gives the option to access basePath & basePathWithoutHost with the Kotling Spring Webclient. This is already possible for many clients and the implemented approach is based on how it is implemented for the Multiplatform client, but improved in the sense that it's also possible to access basePathWithoutHost. For us this feature would be very useful to have as we do versioning via the path which we include as base path into the OpenAPI definitions.

Apart from the feature I added additional Kotlin assertion classes to check for companions, functions & secondary constructors for testing purposes. I also added some abstract assertion classes on the way, because I realized that there was a lot of copy paste work involved during implementation of the new assertion classes.

@karismann @Zomzog @andrewemery @4brunu @yutaka0m @stefankoppier @e5l

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Expose base URL and base path in Kotlin JVM Spring WebClient clients via generated constants and helpers, plus a simple way to build clients with a versioned base path. This improves support for path‑based versioning and aligns with other Kotlin clients.

  • New Features

    • Generate ApiClient companion constants: BASE_URL (from basePath) and BASE_PATH_WITHOUT_HOST (from basePathWithoutHost).
    • Add createUrlWithBasePath(baseUrl, basePath = ApiClient.BASE_PATH_WITHOUT_HOST) to safely join URL and base path.
    • API classes: default secondary constructor parameter baseUrl = ApiClient.BASE_URL.
    • API classes: companion function createWithBasePath(baseUrl, basePath = ApiClient.BASE_PATH_WITHOUT_HOST).
  • Refactors

    • Introduce reusable Kotlin PSI assertion helpers for functions, parameters, companions, and secondary constructors; remove old ParameterAssert.
    • Add tests verifying constants, helper function, and constructors for jvm-spring-webclient; update samples accordingly.

Written for commit 49fae38. Summary will update on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 40 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="samples/client/petstore/kotlin-jvm-spring-2-webclient/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt">

<violation number="1" location="samples/client/petstore/kotlin-jvm-spring-2-webclient/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt:82">
P2: createUrlWithBasePath blindly appends basePath even when baseUrl already includes it (BASE_URL already ends with /v2 and basePath defaults to /v2), yielding double base paths like http://petstore.swagger.io/v2/v2 when using ApiClient.BASE_URL.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@svenallers svenallers force-pushed the kotlin-client-include-base-path branch from a684398 to 49fae38 Compare February 2, 2026 08:52
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 622 files

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant