Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Kotlin] Fix (de)serialization of enum classes (kotlinx serialization) #9143

Merged

Conversation

kvn-stgl
Copy link
Contributor

@kvn-stgl kvn-stgl commented Mar 31, 2021

Enum class which are inside the dataClass.mustache file are missing the Serializable annotation. This leads to a wrong behavior of the serializer where the names instead of the the SerialName values are used.

You can reproduce this issue if you run the kotlin-retrofit2-kotlinx_serialization sample project. A warning like Explicit @Serializable annotation on enum class is required when @SerialName or @SerialInfo annotations are used on its members. will be thrown.

The changeset also adds the Xopt-in compiler flags for the ExperimentalSerializationApi which also leads to compiler warnings.

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 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    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*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.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.

@jimschubert @dr4ke616 @karismann @Zomzog @andrewemery @4brunu @yutaka0m

@auto-labeler
Copy link

auto-labeler bot commented Mar 31, 2021

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@wing328
Copy link
Member

wing328 commented Apr 1, 2021

@kvn-stgl thanks for the PR. Is this similar to #7917? Can you review it as well to see if it solves the problem for you?

@kvn-stgl
Copy link
Contributor Author

kvn-stgl commented Apr 1, 2021

Hi @wing328 , it seems to be the same but it's still a bit different (and yes, I copied the title and I also looked at it). The PR #7917 is a fix for the Jackson library, mine is a fix for the Kotlinx serialization library. They also handle different subprojects, mine is for the kotlin project and the other pr is for the kotlin-string project. So sadly it does not solve my problems.

@wing328
Copy link
Member

wing328 commented Apr 16, 2021

@kvn-stgl thanks for the explanation. Let's go with this fix and see if the community has a different opinion on this.

@wing328 wing328 merged commit 6dce817 into OpenAPITools:master Apr 16, 2021
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.

None yet

2 participants