Skip to content
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

Using @XmlEnum to generate an enum of type Integer in json schema #49

Open
jesse8888 opened this issue Oct 30, 2014 · 2 comments
Open

Comments

@jesse8888
Copy link

I have the following Java enum:

@XmlType
@XmlEnum(Integer.class)
public enum DefaultMessageVersion
{
@XmlEnumValue("1") ONE;
}

That is producing the following json schema snippet:

"defaultMessageVersion" : {
"type" : "string",
"enum" : [ "1" ]
}

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'm going to attempt to write the functionality myself, but would appreciate any pointers on where to get started, or a head-up if I'm just wrong about why it's not working.

@cowtowncoder
Copy link
Member

Hmmh. That is tricky, since although Jackson's JAXB annotations module does (when registered) use JAXB annotations, this annotation has no real counterpart in Jackson world... so it will not have any effect.

Except that with addition of @JsonFormat, it could actually be taken to mean roughly same as:

@JsonFormat(shape=Shape.NUMBER)

which should then end up doing what you want, I think.

Could you file an issue for jackson-module-jaxb-annotations, with a link back to this issue? It should be relatively easy thing to add.

@jesse8888
Copy link
Author

I have filed an issue here:

FasterXML/jackson-module-jaxb-annotations#33

Thanks for your quick response.

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

No branches or pull requests

2 participants