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

UnrecognizedPropertyException on enum serialization to schema #42

Closed
mchmielarz opened this issue Mar 13, 2013 · 6 comments
Closed

UnrecognizedPropertyException on enum serialization to schema #42

mchmielarz opened this issue Mar 13, 2013 · 6 comments
Labels

Comments

@mchmielarz
Copy link

I'm trying to create a model schema for the service where there is a class that has one field of enum type. Attempt causes generation of an empty DocumentationSchema for this class. I've tried to reproduce the situation in unit tests and after all I'm receiving stack trace pasted below.

The cause seems to be obvious but the question is: am I doing something wrong or there is it a bug? The entity (and its fields) is not annotated with any annotations from Swagger/Jackson.

Cheers,
Michal

Unrecognized field "enum" (class com.wordnik.swagger.core.DocumentationSchema), not marked as ignorable (13 known properties: , "items", "notes", "default", "access", "allowableValues", "uniqueItems", "$ref", "properties", "additionalProperties", "type", "id", "description", "required"])
at [Source: java.io.StringReader@3e018c74; line: 1, column: 187](through reference chain: com.wordnik.swagger.core.DocumentationSchema["properties"]->com.wordnik.swagger.core.DocumentationSchema["properties"]->com.wordnik.swagger.core.DocumentationSchema["enum"])
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "enum" (class com.wordnik.swagger.core.DocumentationSchema), not marked as ignorable (13 known properties: , "items", "notes", "default", "access", "allowableValues", "uniqueItems", "$ref", "properties", "additionalProperties", "type", "id", "description", "required"])
at [Source: java.io.StringReader@3e018c74; line: 1, column: 187](through reference chain: com.wordnik.swagger.core.DocumentationSchema["properties"]->com.wordnik.swagger.core.DocumentationSchema["properties"]->com.wordnik.swagger.core.DocumentationSchema["enum"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:79)
at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:579)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:672)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:906)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:328)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringMap(MapDeserializer.java:429)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:310)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:26)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:375)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:98)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:308)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringMap(MapDeserializer.java:429)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:310)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:26)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:375)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:98)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:308)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2796)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1942)
...

@dilipkrish
Copy link
Member

@mchmielarz I dont believe there is an outstanding bug. Having said that this is a new feature so its possible you might have uncovered one! If you send me more details, may be yr controller signature and/or yr test case, I can see if I can help you with your problem.

In the absence of that, I'll try and see if I can reproduce a similar scenario. Basically we're trying to generate the model schema for a class that is either an parameter or a return value of a controller and that class has only one property thats an enum.

Also you should be using 0.3.3 or a later version of the library.

@dilipkrish
Copy link
Member

@mchmielarz I confirmed that this is a bug. The swagger-core api does not support json schema completely. So any models that have enums in them, have issues rendering. It is unable to read the "enum" property thats generated, as you might've already guessed :)

Thank you for reporting this issue

dilipkrish added a commit that referenced this issue Mar 13, 2013
was unable to read json schema that is rendered by the types containing
enums

Closes Isssue #42
@dilipkrish
Copy link
Member

This fix should now be fixed in 0.3.4 or higher

@mchmielarz
Copy link
Author

Hi Dilip,

First of all THANK YOU for so quick fix! :)

I see in readme.md in 'Getting started' section that version is updated to 0.3.4. Does this mean this version is available on some maven repository? I can find in oss.sonatype.org repo version 0.3.2 only.

Cheers,
Michal

@dilipkrish
Copy link
Member

Seems like we're having some issues with sonatype. I'll look into it. Sorry for the wait.

@dilipkrish
Copy link
Member

@mchmielarz 0.3.4 should now be visible in maven central

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants