Hi, I have the following implementation:

@ApiModel(parent = classOf[Item])
case class Book(code: String, title: Option[String]) extends Item

@ApiModel(parent = classOf[Item])
case class Car(code: String, licenseNumber: String) extends Item

@JsonTypeInfo(
  use = JsonTypeInfo.Id.NAME,
  include = JsonTypeInfo.As.PROPERTY,
  property = "type",
  visible = true)
@JsonSubTypes(Array(
  new JsonSubTypes.Type(value = classOf[Book], name = "Book"),
  new JsonSubTypes.Type(value = classOf[Car], name = "Car")
))
@ApiModel(value = "Item", subTypes = Array(classOf[Book], classOf[Car]))
trait Item {
  val code: String
}


This is generating the following swagger documentation for these objects:

"Item": {
"type": "object",
"discriminator": "type"
},
"Book": {
"allOf": [
{
"$ref": "#/definitions/Item"
},
{
"type": "object",
"required": [
"code"
],
"properties": {
"code": {
"type": "string"
},
"title": {
"type": "string"
}
}
}
]
},
"Car": {
"allOf": [
{
"$ref": "#/definitions/Item"
},
{
"type": "object",
"required": [
"code"
],
"properties": {
"code": {
"type": "string"
}
}
}
]
} 

Any idea why is the code not defined as a property for Item?

I've tried adding the @ApiModelProperty annotation for the code in the 
trait but that didn't help.

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to