@@ -3,13 +3,11 @@
3{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE FlexibleContexts #-}
4{-# LANGUAGE FlexibleContexts #-}
5{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
6−{-# LANGUAGE OverloadedLists #-}
7{-# LANGUAGE OverloadedStrings #-}
6{-# LANGUAGE OverloadedStrings #-}
8{-# LANGUAGE PolyKinds #-}
7{-# LANGUAGE PolyKinds #-}
9{-# LANGUAGE RankNTypes #-}
8{-# LANGUAGE RankNTypes #-}
10{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE ScopedTypeVariables #-}
11{-# LANGUAGE TypeOperators #-}
10{-# LANGUAGE TypeOperators #-}
12−{-# LANGUAGE TypeFamilies #-}
13#if __GLASGOW_HASKELL__ >= 806
11#if __GLASGOW_HASKELL__ >= 806
14{-# LANGUAGE UndecidableInstances #-}
12{-# LANGUAGE UndecidableInstances #-}
@@ -32,13 +30,11 @@ import qualified Data.Swagger as Swagger
32import Data.Swagger.Declare
30import Data.Swagger.Declare
33import Data.Text (Text)
31import Data.Text (Text)
34import qualified Data.Text as Text
32import qualified Data.Text as Text
35−import GHC.Generics (D1, Meta(..), Rep)
36import GHC.TypeLits
33import GHC.TypeLits
37import Network.HTTP.Media (MediaType)
34import Network.HTTP.Media (MediaType)
38import Servant.API
35import Servant.API
39import Servant.API.Description (FoldDescription,
36import Servant.API.Description (FoldDescription,
40 reflectDescription)
37 reflectDescription)
41−import Servant.API.Generic (ToServantApi, AsApi)
42import Servant.API.Modifiers (FoldRequired)
38import Servant.API.Modifiers (FoldRequired)
44import Servant.Swagger.Internal.TypeLevel.API
40import Servant.Swagger.Internal.TypeLevel.API
@@ -153,10 +149,6 @@ mkEndpointNoContentVerb path _ = mempty
153addParam :: Param -> Swagger -> Swagger
149addParam :: Param -> Swagger -> Swagger
154addParam param = allOperations.parameters %~ (Inline param :)
150addParam param = allOperations.parameters %~ (Inline param :)
156−-- | Add a tag to every operation in the spec.
157−addTag :: Text -> Swagger -> Swagger
158−addTag tag = allOperations.tags %~ ([tag] <>)
160-- | Add accepted content types to every operation in the spec.
152-- | Add accepted content types to every operation in the spec.
161addConsumes :: [MediaType] -> Swagger -> Swagger
153addConsumes :: [MediaType] -> Swagger -> Swagger
162addConsumes cs = allOperations.consumes %~ (<> Just (MimeList cs))
154addConsumes cs = allOperations.consumes %~ (<> Just (MimeList cs))
@@ -447,9 +439,6 @@ instance (ToSchema a, Accept ct, HasSwagger sub, KnownSymbol (FoldDescription mo
447 & required ?~ True
439 & required ?~ True
448 & schema .~ ParamBody ref
440 & schema .~ ParamBody ref
450−instance (HasSwagger (ToServantApi routes), KnownSymbol datatypeName, Rep (routes AsApi) ~ D1 ('MetaData datatypeName moduleName packageName isNewtype) f) => HasSwagger (NamedRoutes routes) where
451− toSwagger _ = addTag (Text.pack $ symbolVal (Proxy :: Proxy datatypeName)) (toSwagger (Proxy :: Proxy (ToServantApi routes)))
453-- =======================================================================
442-- =======================================================================
454-- Below are the definitions that should be in Servant.API.ContentTypes
443-- Below are the definitions that should be in Servant.API.ContentTypes
455-- =======================================================================
444-- =======================================================================