[kotlin] implement serializable data classes (fix #8317)
Implement java.io.Serializable in kotlin data classes for kotlin-spring generator when serializableModel option is enabled.
Fixes #8317.
These existing samples clearly show the effect of this change, as they have serializableModel already set to true:
- kotlin-springboot
- kotlin-springboot-3
- kotlin-springboot-modelMutable
- kotlin-springboot-source-swagger1
- kotlin-springboot-source-swagger2
- kotlin-springboot-springfox
See the added Serializable interface on all generated models for those samples, as well as the serialVersionUID constant in each data class.
PR checklist
- [x] Read the contribution guidelines.
- [X] 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.
- [X] Run the following to build the project and update samples:
(For Windows users, please run the script in Git BASH) 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./mvnw clean package ./bin/generate-samples.sh ./bin/configs/*.yaml ./bin/utils/export_docs_generators.sh./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. - [X] File the PR against the correct branch:
master(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks) - [x] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
cc @jimschubert (2017/09) ❤️, @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06)
Could someone please review this?
Hi, can you please take a look at CI that is failing?
Perform git status
HEAD detached at pull/18386/merge
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: samples/client/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Category.kt
modified: samples/client/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt
modified: samples/client/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Order.kt
modified: samples/client/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Pet.kt
modified: samples/client/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Tag.kt
modified: samples/client/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/User.kt
and another one
* What went wrong:
Execution failed for task ':bootJar'.
> Error while evaluating property 'mainClass' of task ':bootJar'
> Failed to calculate the value of task ':bootJar' property 'mainClass'.
3 actionable tasks: 3 executed
> Main class name has not been configured and it could not be resolved
@4brunu Thanks for checking, and sorry for the late reaction.
I fixed the issue with uncommitted changes in the samples files, but I'm not sure about the second problem you pointed out. Where do you see this, or how could I try to reproduce this problem?
CI is failing, here is the link. https://github.com/OpenAPITools/openapi-generator/actions/runs/9234395104/job/25415874312?pr=18386
@4brunu Seems the issue has been fixed by someone else on the master branch, the CI no longer fails.