-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
JsonIgnoreProperties not considered while converting groovy class to json #519
Comments
Can you update to 1.3.4, which was released yesterday? It should pick up
|
am using 1.3.4. I see below output when I enabled debug. 12:33:11,559 DEBUG processing method public java.lang.String com.company.my.support.mongo.functionality.SMModificationDetails.toString() [http-nio-8080-exec-2] ModelPropertyParser 12:33:11,559 DEBUG processing method public int com.company.my.support.mongo.functionality.SMModificationDetails.hashCode() [http-nio-8080-exec-2] ModelPropertyParser 12:33:11,560 DEBUG processing method public groovy.lang.MetaClass com.company.my.support.mongo.functionality.SMModificationDetails.getMetaClass() [http-nio-8080-exec-2] ModelPropertyParser 12:33:11,560 DEBUG validating datatype groovy.lang.MetaClass against 12 keys, got groovy.lang.MetaClass [http-nio-8080-exec-2] ModelPropertyParser 12:33:11,560 DEBUG inspecting groovy.lang.MetaClass [http-nio-8080-exec-2] ModelPropertyParser 12:33:11,560 DEBUG validating datatype MetaClass against 12 keys, got MetaClass [http-nio-8080-exec-2] ModelPropertyParser 12:33:11,560 DEBUG validating datatype MetaClass against 12 keys, got MetaClass [http-nio-8080-exec-2] ModelPropertyParser 12:33:11,560 DEBUG added param type groovy.lang.MetaClass for field metaClass [http-nio-8080-exec-2] ModelPropertyParser |
FYI Its a Jersey JaxRs resource service for which I am integrating swagger. gradle dependencies are 'com.wordnik:swagger-jersey-jaxrs_2.10:1.3.4', 'com.fasterxml.jackson.core:jackson-core:2.3.0', "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.0.0", |
Can anyone provide me a work around? Is this a bug? Am planning to change all my classes from groovy to java to proceed further. This is a painful process. Want to know if this indeed is a problem? or am I missing anything? |
If you can help create a test case to reproduce the issue, we can help. It
|
I have been suffering from this same issue. Please see the below test case which demonstrates @JsonIgnoreProperties being ignored. https://github.com/azhawkes/swagger-core/commit/e55630dc28a45a6e7f039db01131e4a6cde5787e If you run "mvn test" in my fork, you'll see the failure. Please note that @JsonIgnore is handled fine; it is the class-level annotation @JsonIgnoreProperties that is totally ignored by ModelPropertyParser. Because a huge number of Groovy meta-properties are added at runtime, using the regular @JsonIgnore is not an option. As it currently stands, there are so many Groovy meta-properties being serialized that swagger-ui crashes my browser. |
Pull request submitted that should fix the issue... hope that helps. |
Just a note for anyone Googling... @fehguy merged my fix into the development branch today and it's been built in 1.3.5-SNAPSHOT. Using 1.3.5-SNAPSHOT, I'm now able to use Groovy models just fine like this: import com.fasterxml.jackson.annotation.JsonIgnoreProperties
@JsonIgnoredProperties(["metaClass"])
class SampleModel {
String name
int age
} |
@fehguy - is this still an issue for 1.5? Doesn't the Jackson parsing read these annotations now? |
Will add tests and close after confirming. |
supported and tested in 1.5.x-M1 and greater, see https://github.com/swagger-api/swagger-core/blob/develop_2.0/modules/swagger-core/src/test/scala/1_3/converter/JsonIgnorePropertiesModelTest.scala |
I have a Rest resource with as groovy class as response type.
I used @JsonIgnoreProperties annotation to exclude metaClass property from groovy. But still this property is listed in swagger-ui Response Class model.
http://stackoverflow.com/questions/22763820/exclude-metaclass-properties-for-groovy-model-classes-in-swagger lists the Foo instance.
com.wordnik.swagger.converter.ModelPropertyParser class does not seem to consider the JsonIgnoreProperties annotation. Is this true? How do I make swagger consider my JsonIgnoreProperties annotation?
The text was updated successfully, but these errors were encountered: