-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add @JsonProperty support for enum values #1533
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
Not sure what that means. Please take time to report a bug with additional details. Here are the issue submission guidelines |
Just try to create swagger docs with field of enum type and you will see that strage "stringEnum" with duplicate of enum values. |
There are demos and functional tests for enums that seem to suggest otherwise. Could you perhaps create a breaking test? |
I'll show you: I have a such DTO: public class LoginDTO implements Serializable {
private UserTypeEnum userType;
//other fields, getters/setters
} UserTypeEnum.java : public enum UserTypeEnum {
DRIVER, PASSENGER;
@JsonCreator
public static UserTypeEnum fromString(String name) {
return UserTypeEnum.valueOf(name.toUpperCase());
}
@JsonValue
public String getName() {
return name().toLowerCase();
}
} Actually, JSON annotations here are for lowercase view, but the same bug is without them Duplication of enum and weird "stringEnum" string. This bug is not reproducable for 2.5.0 |
BTW, is there another way of lowercase view of enum? |
Couple of things,
|
Please, read more careful, I wrote that this bug is only for 2.6.0, but not 2.5.0. {
"swagger": "2.0",
"info":
{
"description": "Api Documentation",
"version": "1.0",
"title": "Api Documentation",
"termsOfService": "urn:tos",
"contact":
{
},
"license":
{
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
},
"host": "HOST",
"basePath": "/",
"tags":
[
{
"name": "login-controller",
"description": "Login Controller"
}
],
"paths":
{
"/login":
{
"post":
{
"tags":
[
"login-controller"
],
"summary": "User login.",
"operationId": "loginUsingPOST",
"consumes":
[
"application/json"
],
"produces":
[
"*/*"
],
"parameters":
[
{
"in": "body",
"name": "login",
"description": "login",
"required": true,
"schema":
{
"$ref": "#/definitions/LoginDTO"
}
}
],
"responses":
{
"200":
{
"description": "OK",
"schema":
{
"$ref": "#/definitions/LoginDTO"
}
},
"201":
{
"description": "Created"
},
"401":
{
"description": "Unauthorized"
},
"403":
{
"description": "Forbidden"
},
"404":
{
"description": "Not Found"
}
}
}
},
"definitions":
{
"LoginDTO":
{
"type": "object",
"properties":
{
"deviceToken":
{
"type": "string"
},
"login":
{
"type": "string"
},
"password":
{
"type": "string"
},
"userType":
{
"type": "string",
"enum":
[
"driver",
"passenger"
]
}
}
}
}
} And answer please to the previous comment |
Ok I don't see any |
Oh, so it's not a fault of springfox? |
@dilipkrish is there another way of getting enum lowercased using springfox? |
You can try setting the allowable values in an |
It's not really a dynamic option (I mean it's not tolerant to changes). Do you have any plans to add support of @JsonProperty to emuns? |
I'd be happy to contribute. Please let me know if i can help. Best Regards |
@Syntobe absolutely! Would be awesome if you can help with this. |
@Syntobe @dilipkrish |
I'll try to have a look at it next week.
I keep you posted =)
…On Fri, 22 Jun 2018, 09:54 Serhii Solohub, ***@***.***> wrote:
@Syntobe <https://github.com/Syntobe> @dilipkrish
<https://github.com/dilipkrish>
Hi guys!
Is there any progress regarding support of @JsonProperty for enum values?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1533 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AZmygGr5j8yUyb7fK_7wIusvGxZTUsehks5t_KKqgaJpZM4Kb6dg>
.
|
Cool! Thanks |
@solo-yolo Hi! What kind of workaround? |
@doctorstrange85 sorry, but I don't work on that project anymore, and unfortunately can't remember what we did to workaround this issue :( |
Hi, starting from 2.6.0 version enums are showing so weird:
contactType (string, optional) = ['skype', 'email', 'phone']stringEnum:"skype", "email", "phone",
Fix it please.
The text was updated successfully, but these errors were encountered: