We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
The jsonSchema returned for:
case class WorkingClass(int: Int) { def iterator: Iterator[Int] = List().toIterator }
looks correct:
{ "type" : "object", "id" : "urn:jsonschema:com:ccri:commons:config:schema:ReproduceIssue:WorkingClass", "properties" : { "int" : { "type" : "integer" } } }
But if the class is declared as extending Iterable[Int]
Iterable[Int]
case class FailingClass(int: Int) extends Iterable[Int] { def iterator: Iterator[Int] = List().toIterator }
I get:
{ "type" : "array" }
As far as I can tell, mixing in any trait that subclasses TraversableOnce produces {"type": "array"}.
TraversableOnce
{"type": "array"}
To reproduce:
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.jsonSchema.customProperties.ValidationSchemaFactoryWrapper import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper import com.fasterxml.jackson.module.scala.DefaultScalaModule import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper object JacksonHelper { val jacksonObjectMapper: ObjectMapper = new ObjectMapper() with ScalaObjectMapper jacksonObjectMapper.registerModule(DefaultScalaModule) val writer = jacksonObjectMapper.writer() val visitor: SchemaFactoryWrapper = new ValidationSchemaFactoryWrapper() val prettyPrinter = jacksonObjectMapper.writerWithDefaultPrettyPrinter() def jsonSchema(c: Class[_]) = { writer.acceptJsonFormatVisitor(c, visitor) val jsonSchema = visitor.finalSchema() prettyPrinter.writeValueAsString(jsonSchema) } } object ReproduceIssue extends App { case class WorkingClass(int: Int) { def iterator: Iterator[Int] = List().toIterator } case class FailingClass(int: Int) extends Iterable[Int] { def iterator: Iterator[Int] = List().toIterator } println("WorkingClass:") println(JacksonHelper.jsonSchema(classOf[WorkingClass])) println("FailingClass:") println(JacksonHelper.jsonSchema(classOf[FailingClass])) }
<dependency> <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-jsonSchema</artifactId> <version>2.6.3</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-scala_2.10</artifactId> <version>2.6.3</version> </dependency>
Am I doing something wrong, is this not supposed to work, or is it a bug?
The text was updated successfully, but these errors were encountered:
jackson-module-jsonSchema support is deprecated and due for removal when jackson 3 is released
Sorry, something went wrong.
No branches or pull requests
The jsonSchema returned for:
looks correct:
But if the class is declared as extending
Iterable[Int]
I get:
As far as I can tell, mixing in any trait that subclasses
TraversableOnce
produces{"type": "array"}
.To reproduce:
Am I doing something wrong, is this not supposed to work, or is it a bug?
The text was updated successfully, but these errors were encountered: