Skip to content

Conversation

@pkubowicz
Copy link
Contributor

By making those classes open, AspectJ can be used to enhance their behavior.

Closes #22271

@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.

@Picazsoo
Copy link
Contributor

Hi@pkubowicz - The fix looks good to me! But since this only fixes the issue in kotlin-client generator and I cannot really tell whether the original issue ticket pertains only to kotlin-client or also to kotlin-spring, I would be wary of closing the original issue. Because as far as I understand, the issue is fully valid in kotlin-spring as well.

Just to clarify - I am not a maintainer of this repo - just a random dev stopping by (-:

@pkubowicz
Copy link
Contributor Author

Hi, thanks for the comment. I'm not sure what you mean – if you see the samples affected, open appears in code generated for Spring with RestClient and so on.

My intention was to open all API classes generated by all Kotlin generators, since theoretically you could use AspectJ without Spring.

@Picazsoo
Copy link
Contributor

I mean - The issue you linked to be closed. It could also be understood to apply to kotlin-spring generator - not just kotlin-client generator. So I think your fix is great - it just possibly does not cover the issue in the kotlin-spring generator?

If I am mistaken, then I apologize for any confusion.

import org.openapitools.client.infrastructure.toMultiValue

class PathApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
open class PathApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
Copy link
Contributor

Choose a reason for hiding this comment

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

To prevent a future regression it would be a good idea to extend this class in some of the generated samples. So if someone were to incorrectly remove this "open" in mustache templates, the compilation would fail - making it clear that it is a regression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how to approach this. Samples are generated from YAML, I don't think I should add anything hand-written there.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can. Take a look at e.g. x "x-kotlin-implements". There are some interfaces included in a separate package that does not contain the auto-generated files.

But you are right that these can be carelessly deleted.

So maybe a unit test covering the generated class and checking that the "open" is present?.

I think that regressions are the most common type of bug introduced in a project such as this one. Unit/integration tests go a long way to force the other contributors to properly consider any impact of their changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it look ok? 7e34059

@Picazsoo
Copy link
Contributor

Just checked it on a pc (previous reply was from mobile) - you are fixing only the kotlin-client generator mustache files. Which is good! It might even resolve the issue entirely for the person who created the original issue. It is just that from the original issue it is not understandable (at least to me) whether the person had the issue in kotlin-client or kotlin-spring generator. So closing the issue might be premature.

@wing328
Copy link
Member

wing328 commented Nov 29, 2025

thanks for the pr

please review the build failure when you've time

By making those classes open, AspectJ can be used to enhance their
behavior.

I'm not changing kotlin-multiplatform templates, where 'open' was
already present before my changes.

Closes OpenAPITools#22271
@wing328 wing328 added this to the 7.18.0 milestone Nov 30, 2025
@wing328 wing328 merged commit 7b83462 into OpenAPITools:master Nov 30, 2025
68 checks passed
@pkubowicz pkubowicz deleted the kotlin-open branch December 1, 2025 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQ] Kotlin Generator: allows generated APIs/Client Classes to be "kotlin open" (non final)

3 participants