Closed jgulotta closed 1 year ago
Thanks - 2.7.x is pretty experimental (mentioned in readme) - best to stick with v2.6.x. I can look at your example in a few days time.
Could you provide all the relevant classes so that I don't have to spend time reproducing the issue?
@jgulotta thanks for the example. I ran into the same problem, but couldn't get a good reproduction scenario.
There's no special class - near as I can tell It's anything with the Option[Map[...]]
form. This is as small a reproducer as I have right now
case class OptMap(optmap: Option[Map[String, Int]])
trait Route {
@Path("/")
@ApiResponse(content = Array(new Content(schema = new Schema(implementation = classOf[OptMap]))))
def optmap: OptMap = ???
}
new Reader(new SwaggerConfiguration().openAPI(new OpenAPI())).read(classOf[Route])
There's no special class - near as I can tell It's anything with the
Option[Map[...]]
form. This is as small a reproducer as I have right nowcase class OptMap(optmap: Option[Map[String, Int]]) trait Route { @Path("/") @ApiResponse(content = Array(new Content(schema = new Schema(implementation = classOf[OptMap])))) def optmap: OptMap = ??? } new Reader(new SwaggerConfiguration().openAPI(new OpenAPI())).read(classOf[Route])
I'm sorry, what I meant was that your example did help me create a reproduction test. It's in this PR, which should solve the problem https://github.com/swagger-akka-http/swagger-scala-module/pull/210
Oh! I was half responding to pjfanning, misinterpreted, and didn't notice you'd already filed the PR 😅
I'll sort out a 2.7.8 release - I'm travelling today so it might not be today
2.7.8 is published
Thanks for the quick fix!
Do you have any known issues that make the 2.7 series experimental? It'd be preferable for us due to not requiring annotations for handling of primitives + erasure.
Use v2.7 if you like but I can not guarantee that every scala class setup will operate as expected. The test coverage in this module is far from complete.
In version 2.6.0, having a field with type
Option[Map[String, CaseClass]]
would correctly generate a schema likeIn 2.7.7 the same type definition throws an exception like
Some initial debugging suggests that
ErasureHelper.erasedOptionalPrimitives
is incorrectly resolving theMap
as aString
because it recursively looks at only the first type parameter. I expect this might apply toOption[Seq[String]]
as well.