mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
fix release note json serialization
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
module Handler.Package.V0.ReleaseNotes where
|
module Handler.Package.V0.ReleaseNotes where
|
||||||
|
|
||||||
import Data.Aeson (ToJSON (..))
|
import Data.Aeson (ToJSON (..), object, KeyValue((.=)))
|
||||||
import Data.HashMap.Strict (HashMap)
|
import Data.HashMap.Strict (HashMap)
|
||||||
import Data.HashMap.Strict qualified as HM
|
import Data.HashMap.Strict qualified as HM
|
||||||
import Database.Queries (fetchAllAppVersions)
|
import Database.Queries (fetchAllAppVersions)
|
||||||
@@ -10,14 +10,15 @@ import Foundation (Handler, RegistryCtx (..))
|
|||||||
import Lib.Types.Core (PkgId)
|
import Lib.Types.Core (PkgId)
|
||||||
import Lib.Types.Emver (Version)
|
import Lib.Types.Emver (Version)
|
||||||
import Model (VersionRecord (..))
|
import Model (VersionRecord (..))
|
||||||
import Startlude (Down (..), Eq, Show, Text, fst, pure, sortOn, ($), (&&&), (.), (<$>))
|
import Startlude (Down (..), Eq, Show, Text, fst, pure, sortOn, ($), (&&&), (.), (<$>), show)
|
||||||
import Yesod (ToContent (..), ToTypedContent (..), YesodPersist (runDB), getYesod)
|
import Yesod (ToContent (..), ToTypedContent (..), YesodPersist (runDB), getYesod)
|
||||||
|
import Data.Aeson.Key (fromText)
|
||||||
|
|
||||||
|
|
||||||
newtype ReleaseNotes = ReleaseNotes {unReleaseNotes :: HashMap Version Text}
|
newtype ReleaseNotes = ReleaseNotes {unReleaseNotes :: HashMap Version Text}
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
instance ToJSON ReleaseNotes where
|
instance ToJSON ReleaseNotes where
|
||||||
toJSON ReleaseNotes{..} = toJSON unReleaseNotes
|
toJSON ReleaseNotes {..} = object [ version .= value | (key, value) <- HM.toList unReleaseNotes, let version = fromText $ show key]
|
||||||
instance ToContent ReleaseNotes where
|
instance ToContent ReleaseNotes where
|
||||||
toContent = toContent . toJSON
|
toContent = toContent . toJSON
|
||||||
instance ToTypedContent ReleaseNotes where
|
instance ToTypedContent ReleaseNotes where
|
||||||
|
|||||||
Reference in New Issue
Block a user