-
Notifications
You must be signed in to change notification settings - Fork 6k
Possible swagger hub codegen issue with Enums: @JsonValue annotation is missing from toString() #3611
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
Comments
@ralgor14 thanks for reporting the issue and suggesting a fix. I'll look into this tomorrow (Friday) and hopefully file a PR for the fix. |
@ralgor14 PR merged into master. Please pull the latest to give it a try. |
I do not see this version under https://github.com/swagger-api/swagger-codegen |
@ralgor14 please build the JAR locally ( |
Because of security issues I cannot download maven into my host. |
Can you use https://generator.swagger.io? If yes, I can setup another online code generator to run the latest version of Swagger Codegen. |
I didn't succeed. |
@wing328 I tried with the snapshot builds from here https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen-maven-plugin/2.2.2-SNAPSHOT/ Wed Nov 02 21:01:06 I am still not able to see the @JsonValue being there for the toString() method?
Am I missing anything here? |
That's a snapshot for the maven plug-in (not swagger codegen cli). Have you tried building the JAR locally based on the latest master? |
@wing328 It has dependency with the 2.2.2-SNAPSHOT swagger-codegen which should contain this fix right? https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen/2.2.2-SNAPSHOT/ - Wed Nov 02 21:00:06 |
@wing328 , I still see the issue with version 2.2.3 maven plugin, the @jsonValue does not get generated .. Any ideas? |
@wing328, like other users commented this issue is still reproducible with 2.2.3. Even tried with 2.3.0 and is reproducible. Should add any options while generating the code? Using cli, |
Sorry for the delayed reply.
Yes, sure.
…On Fri, Jan 5, 2018 at 3:39 PM, William Cheng ***@***.***> wrote:
@nmrao <https://github.com/nmrao> lets continue the discussion in #6587
<#6587>, ok?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3611 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEbSe6A6XP0Oe5vHXqG-IpivMrfdmCY5ks5tHfTYgaJpZM4JnoJ6>
.
|
Description
The @JsonValue annotation is missing when codegen creates java code (Server->jaxrs) for Enums.
This annotation should be on toString() method.
The following:
"state": {
"type": "string",
"enum": [
"active",
"inactive"
]
}
causes creation of the following Enum code:
public enum StateEnum {
ACTIVE("active"),
}
Which causes "active" and "inactive" in JSON files to be unrecognized.
In order to correct it the annotation @JsonValue should be added before toString():
@OverRide
@JsonValue
public String toString() {
return String.valueOf(value);
}
It was OK in previous versions of swagger hub.
Annotations are used by jackson's fasterXml package.
The text was updated successfully, but these errors were encountered: