-
Notifications
You must be signed in to change notification settings - Fork 54
case class with field option[Int] is resolved as object and not Number #55
Comments
The current code uses Java reflection and suffers from type erasure - the model converter basically just gets notified that quantityOpt is an Option[Any]. You should be able to use swagger annotations on the quantityOpt field to fix your swagger doc. |
I added an example of how you can workaround this issue - pjfanning/swagger-akka-http-sample@c2fa600 |
Thanks @pjfanning, using |
Isn't it possible to fix without annotation? |
What is the solution to this using OpenAPI V3.0? Option[Int] still doesn't work in latest version |
@GMTurbo #55 (comment) -- this is still the case |
so i'm not sure what annotation to use to modify the quantityOpt field. I have a bunch of case classes that have a lot of Options in them. Because I'm using OpenAPI V3.0, i don't have access to the I've tried the following: case class Metrics(id: String,
@(Schema @field)(`type` = "int") size: Option[Int] = None, This doesn't seem to work although it compiles fine. Any ideas? |
If you need OpenAPI 3, then you could try https://github.com/swagger-akka-http/swagger-scala-module - https://github.com/swagger-api/swagger-scala-module only supports swagger 2 spec. |
Ok, so i got this working using the following: case class Metrics(id: String,
@(Schema @field)(implementation = classOf[Int]) size: Option[Int] = None Thanks |
Hi,
When I have something like this:
The swagger model will have this properties:
But the right definition should be something like this
@pjfanning , @fehguy
There are any solution for it ?
Thanks !
The text was updated successfully, but these errors were encountered: