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

Add feature to allow comments in schema files #589

Closed
randombk opened this issue Jul 11, 2016 · 4 comments
Closed

Add feature to allow comments in schema files #589

randombk opened this issue Jul 11, 2016 · 4 comments
Milestone

Comments

@randombk
Copy link

Add a togglable feature to allow comments in input schema files.

As jsonschema2pojo uses Jackson internally, this can be done by enabling the JsonParser.Feature.ALLOW_COMMENTS flag for the appropriate ObjectMapper instances.

@joelittlejohn
Copy link
Owner

I think we should turn this on permanently rather than introduce a configuration option, I'm happy to be relaxed about the schemas this plugin accepts in cases like this. Thanks for the info. If you'd like to submit a pull request that sets this feature on for the ObjectMappers we use then please feel free.

@joelittlejohn joelittlejohn added this to the 0.4.24 milestone Jul 16, 2016
@randombk
Copy link
Author

Thanks for adding this!

@yomik
Copy link
Contributor

yomik commented Feb 15, 2017

This feature is causing build issues in my android library. I upgraded jsonschema2pojo version today from 0.4.21 to 0.4.30 and it wasn't working anymore, so I downgraded until the build would pass again.
Things work until 0.4.23 and start failing with 0.4.24 :
Looking through the changed files, this PR is probably the cause, based on the stacktrace I get :

Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.jsonschema2pojo.ContentResolver at org.jsonschema2pojo.SchemaStore.<init>(SchemaStore.java:33) at org.jsonschema2pojo.rules.RuleFactory.<init>(RuleFactory.java:72) at org.jsonschema2pojo.Jsonschema2Pojo.createRuleFactory(Jsonschema2Pojo.java:96) at org.jsonschema2pojo.Jsonschema2Pojo.generate(Jsonschema2Pojo.java:56) at org.jsonschema2pojo.Jsonschema2Pojo$generate.call(Unknown Source) at org.jsonschema2pojo.gradle.GenerateJsonSchemaAndroidTask.generate(GenerateJsonSchemaAndroidTask.groovy:53) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)

Which is caused by the following error :

Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.enable([Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/databind/ObjectMapper; at org.jsonschema2pojo.ContentResolver.<clinit>(ContentResolver.java:42) at org.jsonschema2pojo.SchemaStore.<init>(SchemaStore.java:33) at org.jsonschema2pojo.rules.RuleFactory.<init>(RuleFactory.java:72) at org.jsonschema2pojo.Jsonschema2Pojo.createRuleFactory(Jsonschema2Pojo.java:96) at org.jsonschema2pojo.Jsonschema2Pojo.generate(Jsonschema2Pojo.java:56) at org.jsonschema2pojo.Jsonschema2Pojo$generate.call(Unknown Source) at org.jsonschema2pojo.gradle.GenerateJsonSchemaAndroidTask.generate(GenerateJsonSchemaAndroidTask.groovy:53) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)

Note that I'm using gson in this specific project.

@joelittlejohn
Copy link
Owner

@yomik Are you using the Gradle or Maven plugin? It looks like you have a conflict in the Jackson version that is on the plugin classpath. We require Jackson 2.5.0 or later.

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

3 participants