Skip to content

Conversation

@pstorch
Copy link
Contributor

@pstorch pstorch commented Jul 26, 2024

fix #19244 kotlin-spring generator produces non-compiling Kotlin code for enum type integer.
The error is with @JsonProperty annotation which only accepts strings arguments.
This fix uses @JsonValue and @JsonCreator annotations.

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/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (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 ./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.6.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • 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, @stefankoppier

@4brunu 4brunu merged commit 37afe57 into OpenAPITools:master Jul 26, 2024
@wing328 wing328 added this to the 7.8.0 milestone Aug 18, 2024
@luismospinam
Copy link

luismospinam commented Dec 2, 2024

This MR introduced an error when generating enums. From Jackson 2.11, when using JsonCreator a Mode argument needs to be specified otherwise, it will throw an exception when deserializing an enum

Input mismatch reading Enum `EnumType`: properties-based `@JsonCreator` ([method EnumType#forValue(java.lang.String)]) expects JSON Object (JsonToken.START_OBJECT), got JsonToken.VALUE_STRING

Not entirely sure but I think adding the Mode JsonCreator.Mode.DELEGATING will work

@JsonCreator(mode = JsonCreator.Mode.DELEGATING)

Please see the following:
FasterXML/jackson-module-kotlin#336
https://cowtowncoder.medium.com/jackson-2-12-most-wanted-3-5-246624e2d3d0

@pstorch
Copy link
Contributor Author

pstorch commented Dec 26, 2024

@luismospinam do you have an example? I could successfully serialize and deserialize the enums with the generated code.

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.

[BUG] kotlin-spring generator produces non-compiling Kotlin code for enum type integer

4 participants