@@ -22,6 +22,7 @@ import Data.HashMap.Strict.InsOrd (InsOrdHashMap)
22
22
import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
23
23
import Data.Foldable (toList )
24
24
import Data.Proxy
25
+ import Data.Typeable
25
26
import Data.Singletons.Bool
26
27
import Data.Swagger hiding (Header )
27
28
import qualified Data.Swagger as Swagger
@@ -236,13 +237,16 @@ instance (KnownSymbol sym, HasSwagger sub) => HasSwagger (sym :> sub) where
236
237
where
237
238
piece = symbolVal (Proxy :: Proxy sym )
238
239
239
- instance (KnownSymbol sym , ToParamSchema a , HasSwagger sub , KnownSymbol (FoldDescription mods )) => HasSwagger (Capture' mods sym a :> sub ) where
240
+ instance (KnownSymbol sym , Typeable a , ToParamSchema a , HasSwagger sub , KnownSymbol (FoldDescription mods )) => HasSwagger (Capture' mods sym a :> sub ) where
240
241
toSwagger _ = toSwagger (Proxy :: Proxy sub )
241
242
& addParam param
242
243
& prependPath capture
243
244
& addDefaultResponse404 tname
244
245
where
245
- pname = symbolVal (Proxy :: Proxy sym )
246
+ symbol = symbolVal (Proxy :: Proxy sym )
247
+ pname = if symbol == " "
248
+ then camelTo2 ' -' . tyConName . typeRepTyCon $ typeRep (Proxy :: Proxy a )
249
+ else symbol
246
250
tname = Text. pack pname
247
251
transDesc " " = Nothing
248
252
transDesc desc = Just (Text. pack desc)
@@ -256,7 +260,7 @@ instance (KnownSymbol sym, ToParamSchema a, HasSwagger sub, KnownSymbol (FoldDes
256
260
& paramSchema .~ toParamSchema (Proxy :: Proxy a ))
257
261
258
262
-- | Swagger Spec doesn't have a notion of CaptureAll, this instance is the best effort.
259
- instance (KnownSymbol sym , ToParamSchema a , HasSwagger sub ) => HasSwagger (CaptureAll sym a :> sub ) where
263
+ instance (KnownSymbol sym , Typeable a , ToParamSchema a , HasSwagger sub ) => HasSwagger (CaptureAll sym a :> sub ) where
260
264
toSwagger _ = toSwagger (Proxy :: Proxy (Capture sym a :> sub ))
261
265
262
266
instance (KnownSymbol desc , HasSwagger api ) => HasSwagger (Description desc :> api ) where
@@ -352,7 +356,7 @@ instance (ToSchema a, AllAccept cs, HasSwagger sub, KnownSymbol (FoldDescription
352
356
& schema .~ ParamBody ref
353
357
354
358
-- | This instance is an approximation.
355
- --
359
+ --
356
360
-- @since 1.1.7
357
361
instance (ToSchema a , Accept ct , HasSwagger sub , KnownSymbol (FoldDescription mods )) => HasSwagger (StreamBody' mods fr ct a :> sub ) where
358
362
toSwagger _ = toSwagger (Proxy :: Proxy sub )
0 commit comments