-
Notifications
You must be signed in to change notification settings - Fork 20
Using @XmlEnum to generate an enum of type Integer in json schema #33
Comments
Implemented so that annotation like this will have same semantics as: @JsonFormat(shape=Shape.NUMBER_INT) which for JSON will mean that enum will actually be written as numbers (using index). |
I am testing this in my environment (with the latest code pulled in) and am still seeing the same output schema "defaultMessageVersion" : { My apologies, but I am unfamiliar with the process here. Have you confirmed that your implementation works end to end, or is testing still needed? |
I haven't looked at JSON Schema part, just JAXB handling thereof (and usage from main serializer). |
Thanks! I’m happy to help you test anything you implement. |
Ok: two additional notes;
With these, JSON Schema generation should reflect the annotation. Beyond this, I am not sure if listing of enumerated values should or should not be included. |
Thanks for the dependencies info; I'll make sure I'm pulling in the right versions when I test. My vote is that the listing of the enumerated values should be included. |
That's sort of up JSON Schema spec: is number of enumerated values allowed for int types? |
What should the outcome of including @XmlEnumValue be? We have the following:
prior to this change, the result would have been "1" or "2." With this change, it is now 0 or 1. I've taken out the Integer.class from our code, but it was a bit of a sneaky gotcha when upgrading Jackson. Ideally I would think that we'd want the result to be 1 or 2, without the quotes? |
@kwinter I am guessing this is due to combination of things, and specifically indication that I think the handling is not optimal, and it is unfortunate that behavior changed for existing code. |
I just posted an issue in jackson-module-jsonSchema.
FasterXML/jackson-module-jsonSchema#49
For completeness:
I have the following Java enum:
That is producing the following json schema snippet:
This is because (I believe) Jackson ignores the @XmlEnum annotation. I would like the outputted snippet to have "type" : "integer" (or int? I'm not 100% sure which it is).
I have posted the issue here at the request of cowtowncoder, and am hoping that I can submit a fix myself (with pointers on where to look), or that someone else with more knowledge and expertise can take care of it without too much trouble.
The text was updated successfully, but these errors were encountered: