play-swagger icon indicating copy to clipboard operation
play-swagger copied to clipboard

Generic case class reflection

Open kailuowang opened this issue 8 years ago • 4 comments

play swagger stuck when it encounters a generic case class

kailuowang avatar Sep 20 '16 14:09 kailuowang

any workaround for this?

bayarmunkh avatar Dec 02 '16 21:12 bayarmunkh

Chka you can use custom type mapper to work around this. You will have to write your own mapping though. https://github.com/iheartradio/play-swagger#how-to-override-type-mappings

kailuowang avatar Dec 02 '16 21:12 kailuowang

I don't quite get how to use the override type feature for generic case class.

package com.model
case class Response[Err, Data](err: Err, data: Option[Data])

in routes:

# responses:
#   200:
#     schema:
#       $ref: '#/definitions/com.model.Response[String, Int]'

How would swagger-custom-mappings.yml and routes look like?

bayarmunkh avatar Dec 02 '16 22:12 bayarmunkh

I know this is old, but is it possible to get an example for this? In my situation, I have a case class that is a generic 'response' case class with common fields like 'version', 'response_code' and I want to nest a model inside of it without duplicating these common fields on every response object.

mrwillis avatar Apr 29 '18 22:04 mrwillis