@@ -1,4 +1,3 @@
2{-# LANGUAGE DataKinds #-}
1{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveDataTypeable #-}
4{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE DeriveGeneric #-}
@@ -22,9 +21,6 @@ import Prelude.Compat
22import Control.Applicative
21import Control.Applicative
23import Control.Lens ((&), (.~), (?~))
22import Control.Lens ((&), (.~), (?~))
24import Data.Aeson hiding (Encoding)
23import Data.Aeson hiding (Encoding)
25−#if MIN_VERSION_aeson(2,0,0)
26−import qualified Data.Aeson.KeyMap as KeyMap
28import qualified Data.Aeson.Types as JSON
24import qualified Data.Aeson.Types as JSON
29import Data.Data (Constr, Data (..), DataType, Fixity (..), Typeable,
25import Data.Data (Constr, Data (..), DataType, Fixity (..), Typeable,
30 constrIndex, mkConstr, mkDataType)
26 constrIndex, mkConstr, mkDataType)
@@ -49,13 +45,17 @@ import Text.Read (readMaybe)
49import Data.HashMap.Strict.InsOrd (InsOrdHashMap)
45import Data.HashMap.Strict.InsOrd (InsOrdHashMap)
50import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
46import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
52−import Data.OpenApi.Aeson.Compat (deleteKey)
53−import Data.OpenApi.Internal.AesonUtils (AesonDefaultValue (..), HasSwaggerAesonOptions (..),
54− mkSwaggerAesonOptions, saoAdditionalPairs, saoSubObject,
55− sopSwaggerGenericParseJSON, sopSwaggerGenericToEncoding,
56− sopSwaggerGenericToJSON, sopSwaggerGenericToJSONWithOpts)
57−import Data.OpenApi.Internal.Utils
58import Generics.SOP.TH (deriveGeneric)
48import Generics.SOP.TH (deriveGeneric)
49+import Data.OpenApi.Internal.AesonUtils (sopSwaggerGenericToJSON
50+ ,sopSwaggerGenericToJSONWithOpts
51+ ,sopSwaggerGenericParseJSON
52+ ,HasSwaggerAesonOptions(..)
53+ ,AesonDefaultValue(..)
54+ ,mkSwaggerAesonOptions
57+import Data.OpenApi.Internal.Utils
58+import Data.OpenApi.Internal.AesonUtils (sopSwaggerGenericToEncoding)
61-- >>> :seti -XDataKinds
61-- >>> :seti -XDataKinds
@@ -196,7 +196,7 @@ data Components = Components
196 , _componentsExamples :: Definitions Example
196 , _componentsExamples :: Definitions Example
197 , _componentsRequestBodies :: Definitions RequestBody
197 , _componentsRequestBodies :: Definitions RequestBody
198 , _componentsHeaders :: Definitions Header
198 , _componentsHeaders :: Definitions Header
199− , _componentsSecuritySchemes :: SecurityDefinitions
199+ , _componentsSecuritySchemes :: Definitions SecurityScheme
200 , _componentsLinks :: Definitions Link
200 , _componentsLinks :: Definitions Link
201 , _componentsCallbacks :: Definitions Callback
201 , _componentsCallbacks :: Definitions Callback
202 } deriving (Eq, Show, Generic, Data, Typeable)
202 } deriving (Eq, Show, Generic, Data, Typeable)
@@ -337,7 +337,7 @@ data RequestBody = RequestBody
337 -- | The content of the request body.
337 -- | The content of the request body.
338 -- The key is a media type or media type range and the value describes it.
338 -- The key is a media type or media type range and the value describes it.
339 -- For requests that match multiple keys, only the most specific key is applicable.
339 -- For requests that match multiple keys, only the most specific key is applicable.
340− -- e.g. @text/plain@ overrides @text/\*@
340+ -- e.g. @text/plain@ overrides @text/*@
341 , _requestBodyContent :: InsOrdHashMap MediaType MediaTypeObject
341 , _requestBodyContent :: InsOrdHashMap MediaType MediaTypeObject
343 -- | Determines if the request body is required in the request.
343 -- | Determines if the request body is required in the request.
@@ -394,7 +394,7 @@ data Encoding = Encoding
394 -- for other primitive types – @text/plain@; for object - @application/json@;
394 -- for other primitive types – @text/plain@; for object - @application/json@;
395 -- for array – the default is defined based on the inner type.
395 -- for array – the default is defined based on the inner type.
396 -- The value can be a specific media type (e.g. @application/json@),
396 -- The value can be a specific media type (e.g. @application/json@),
397− -- a wildcard media type (e.g. @image/\*@), or a comma-separated list of the two types.
397+ -- a wildcard media type (e.g. @image/*@), or a comma-separated list of the two types.
398 _encodingContentType :: Maybe MediaType
398 _encodingContentType :: Maybe MediaType
400 -- | A map allowing additional information to be provided as headers,
400 -- | A map allowing additional information to be provided as headers,
@@ -734,7 +734,7 @@ data Response = Response
734 -- | A map containing descriptions of potential response payloads.
734 -- | A map containing descriptions of potential response payloads.
735 -- The key is a media type or media type range and the value describes it.
735 -- The key is a media type or media type range and the value describes it.
736 -- For responses that match multiple keys, only the most specific key is applicable.
736 -- For responses that match multiple keys, only the most specific key is applicable.
737− -- e.g. @text/plain@ overrides @text/\*@.
737+ -- e.g. @text/plain@ overrides @text/*@.
738 , _responseContent :: InsOrdHashMap MediaType MediaTypeObject
738 , _responseContent :: InsOrdHashMap MediaType MediaTypeObject
740 -- | Maps a header name to its definition.
740 -- | Maps a header name to its definition.
@@ -1125,7 +1125,6 @@ instance SwaggerMonoid Response
1125instance SwaggerMonoid ExternalDocs
1125instance SwaggerMonoid ExternalDocs
1126instance SwaggerMonoid Operation
1126instance SwaggerMonoid Operation
1127instance (Eq a, Hashable a) => SwaggerMonoid (InsOrdHashSet a)
1127instance (Eq a, Hashable a) => SwaggerMonoid (InsOrdHashSet a)
1128−instance SwaggerMonoid SecurityDefinitions
1130instance SwaggerMonoid MimeList
1129instance SwaggerMonoid MimeList
1131deriving instance SwaggerMonoid URL
1130deriving instance SwaggerMonoid URL
@@ -1492,7 +1491,7 @@ instance FromJSON Param where
1492instance FromJSON Responses where
1491instance FromJSON Responses where
1493 parseJSON (Object o) = Responses
1492 parseJSON (Object o) = Responses
1494 <$> o .:? "default"
1493 <$> o .:? "default"
1495− <*> parseJSON (Object (deleteKey "default" o))
1494+ <*> parseJSON (Object (HashMap.delete "default" o))
1496 parseJSON _ = empty
1495 parseJSON _ = empty
1498instance FromJSON Example where
1497instance FromJSON Example where
@@ -1615,5 +1614,3 @@ instance AesonDefaultValue MimeList where defaultValue = Just mempty
1615instance AesonDefaultValue Info
1614instance AesonDefaultValue Info
1616instance AesonDefaultValue ParamLocation
1615instance AesonDefaultValue ParamLocation
1617instance AesonDefaultValue Link
1616instance AesonDefaultValue Link
1618−instance AesonDefaultValue SecurityDefinitions where
1619− defaultValue = Just mempty