Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Specification Extensions #11 for v3.2.2 (with aeson 2 support) #43

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Data/OpenApi.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ module Data.OpenApi (
-- ** Miscellaneous
MimeList(..),
URL(..),
SpecificationExtensions (..),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

) where

import Data.OpenApi.Lens
Expand Down
12 changes: 12 additions & 0 deletions src/Data/OpenApi/Aeson/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
import qualified Data.Text as T

#if MIN_VERSION_aeson(2,0,0)
filterWithKey :: (T.Text -> v -> Bool) -> KeyMap.KeyMap v -> KeyMap.KeyMap v
filterWithKey p = KeyMap.filterWithKey (\k v -> p (keyToText k) v)

deleteKey :: Key -> KeyMap.KeyMap v -> KeyMap.KeyMap v
deleteKey = KeyMap.delete

Expand Down Expand Up @@ -43,7 +46,13 @@ lookupKey = KeyMap.lookup . Key.fromText

hasKey :: T.Text -> KeyMap.KeyMap a -> Bool
hasKey = KeyMap.member . Key.fromText

filterKeys :: (Key -> Bool) -> KeyMap.KeyMap a -> KeyMap.KeyMap a
filterKeys p = KeyMap.filterWithKey (\key _ -> p key)
#else
filterWithKey :: (T.Text -> v -> Bool) -> HM.HashMap T.Text v -> HM.HashMap T.Text v
filterWithKey = HM.filterWithKey

deleteKey :: T.Text -> HM.HashMap T.Text v -> HM.HashMap T.Text v
deleteKey = HM.delete

Expand Down Expand Up @@ -73,4 +82,7 @@ lookupKey = HM.lookup

hasKey :: T.Text -> HM.HashMap T.Text a -> Bool
hasKey = HM.member

filterKeys :: (T.Text -> Bool) -> HM.HashMap T.Text a -> HM.HashMap T.Text a
filterKeys p = HM.filterWithKey (\key _ -> p key)
#endif
Loading