You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
any class that contain enum and called Deserialize error will throw
Related issues/PRs
Suggest a fix/enhancement
the simple fix will be change the mustache https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/Java/modelEnum.mustache
change
{{#jackson}}
@JsonCreator
{{/jackson}}
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}
.......
to
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
{{/jackson}}
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}
The text was updated successfully, but these errors were encountered:
Description
Currently when we have enum class generated, Deserialize will failed, error:
threw exception [Request processing failed; nested exception is feign.codec.DecodeException: Error while extracting response for type [x.y.z.a.b.c.class] and content type [application/vnd.x.y.z.v1+json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Input mismatch reading Enum
x.y.z.a.b.c.enum
: properties-based@JsonCreator
([method x.y.z.a.b.c.enum#fromValue(class name)]) expects JSON Object (JsonToken.START_OBJECT), got JsonToken.VALUE_STRING; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Input mismatch reading Enumx.y.z.a.b.c.enum
: properties-based@JsonCreator
([method x.y.z.a.b.c.enum#fromValue(x.y.z.a.b.c.enum)]) expects JSON Object (JsonToken.START_OBJECT), got JsonToken.VALUE_STRINGthis one can refer to FasterXML/jackson-module-kotlin#336
Swagger-codegen version
3.0.25
Swagger declaration file content or url
Command line used for generation
Steps to reproduce
any class that contain enum and called Deserialize error will throw
Related issues/PRs
Suggest a fix/enhancement
the simple fix will be change the mustache
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/Java/modelEnum.mustache
change
{{#jackson}}
@JsonCreator
{{/jackson}}
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}
.......
to
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
{{/jackson}}
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}
The text was updated successfully, but these errors were encountered: