packages feed

rfc 0.0.0.14 → 0.0.0.15

raw patch · 2 files changed

+16/−2 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- RFC.Data.IdAnd: instance Data.Swagger.Internal.Schema.ToSchema a => Data.Swagger.Internal.Schema.ToSchema (RFC.Data.IdAnd.IdAnd a)
+ RFC.Data.IdAnd: instance (Data.Swagger.Internal.Schema.ToSchema a, Data.Aeson.Types.ToJSON.ToJSON a, Servant.Docs.Internal.ToSample a) => Data.Swagger.Internal.Schema.ToSchema (Data.Map.Internal.Map Data.UUID.Types.Internal.UUID (RFC.Data.IdAnd.IdAnd a))
+ RFC.Data.IdAnd: instance (Data.Swagger.Internal.Schema.ToSchema a, Data.Aeson.Types.ToJSON.ToJSON a, Servant.Docs.Internal.ToSample a) => Data.Swagger.Internal.Schema.ToSchema (RFC.Data.IdAnd.IdAnd a)

Files

rfc.cabal view
@@ -1,5 +1,5 @@ name:                rfc-version:             0.0.0.14+version:             0.0.0.15 synopsis:            Robert Fischer's Common library description:         An enhanced Prelude and various utilities for Aeson, Servant, PSQL, and Redis that Robert Fischer uses. homepage:            https://github.com/RobertFischer/rfc#README.md
src/RFC/Data/IdAnd.hs view
@@ -71,17 +71,31 @@ instance (ToRow a) => ToRow (IdAnd a) where   toRow (IdAnd (id,a)) = toField id : toRow a -instance (ToSchema a) => ToSchema (IdAnd a) where+instance (ToSchema a, ToJSON a, ToSample a) => ToSchema (IdAnd a) where   declareNamedSchema _ = do     NamedSchema{..} <- declareNamedSchema (Proxy :: Proxy a)     let aMaybeName =  _namedSchemaName     aSchema <- declareSchemaRef (Proxy :: Proxy a)     idSchema <- declareSchemaRef (Proxy :: Proxy UUID)+    let maybeSample = safeHead $ toSamples (Proxy :: Proxy (IdAnd a))     return $ NamedSchema (map (\name -> "IdAnd " ++ name) aMaybeName) $       mempty         & type_ .~ SwaggerObject         & properties .~ [("id", idSchema), ("value", aSchema)]         & required .~ ["id", "value"]+        & example .~ (toJSON . snd <$> maybeSample)++instance (ToSchema a, ToJSON a, ToSample a) => ToSchema (Map UUID (IdAnd a)) where+  declareNamedSchema _ = do+    NamedSchema{..} <- declareNamedSchema (Proxy :: Proxy a)+    let aMaybeName =  _namedSchemaName+    idAndASchema <- declareSchemaRef (Proxy :: Proxy (IdAnd a))+    let maybeSample = safeHead $ toSamples (Proxy :: Proxy (Map UUID (IdAnd a)))+    return $ NamedSchema (map (\name -> "Map of IdAnd " ++ name) aMaybeName) $+      mempty+        & type_ .~ SwaggerObject+        & additionalProperties .~ (Just idAndASchema)+        & example .~ (toJSON . snd <$> maybeSample)  uuidList :: [UUID] uuidList = List.cycle $ map (fromMaybe UUID.nil) $ map UUID.fromString