servant-openapi3 2.0.1.3 → 2.0.1.4
raw patch · 4 files changed
+31/−14 lines, 4 filesdep ~basedep ~base-compatdep ~bytestring
Dependency ranges changed: base, base-compat, bytestring, doctest, lens-aeson
Files
- example/example.cabal +3/−4
- servant-openapi3.cabal +6/−7
- src/Servant/OpenApi/Internal.hs +8/−0
- src/Servant/OpenApi/Internal/TypeLevel/API.hs +14/−3
example/example.cabal view
@@ -14,11 +14,10 @@ swagger.json tested-with:- GHC ==8.4.4- || ==8.6.5+ GHC ==8.6.5 || ==8.8.4- || ==8.10.4- || ==9.0.1+ || ==8.10.7+ || ==9.0.2 library ghc-options: -Wall
servant-openapi3.cabal view
@@ -1,5 +1,5 @@ name: servant-openapi3-version: 2.0.1.3+version: 2.0.1.4 synopsis: Generate a Swagger/OpenAPI/OAS 3.0 specification for your servant API. description: Swagger is a project used to describe and document RESTful APIs. The core of the @@ -29,11 +29,10 @@ build-type: Custom cabal-version: 1.18 tested-with:- GHC ==8.4.4- || ==8.6.5+ GHC ==8.6.5 || ==8.8.4- || ==8.10.4- || ==9.0.1+ || ==8.10.7+ || ==9.0.2 extra-source-files: README.md@@ -81,8 +80,8 @@ , bytestring >=0.10.8.1 && <0.11 , http-media >=0.7.1.3 && <0.9 , insert-ordered-containers >=0.2.1.0 && <0.3- , lens >=4.17 && <5.1- , servant >=0.17 && <0.19+ , lens >=4.17 && <5.2+ , servant >=0.17 && <0.20 , singleton-bool >=0.1.4 && <0.2 , openapi3 >=3.0.0 && <3.3 , text >=1.2.3.0 && <1.3
src/Servant/OpenApi/Internal.hs view
@@ -38,6 +38,9 @@ import Servant.API import Servant.API.Description (FoldDescription, reflectDescription) import Servant.API.Modifiers (FoldRequired)+#if MIN_VERSION_servant(0,19,0)+import Servant.API.Generic (ToServantApi)+#endif import Servant.OpenApi.Internal.TypeLevel.API @@ -414,6 +417,11 @@ #if MIN_VERSION_servant(0,18,2) instance (HasOpenApi sub) => HasOpenApi (Fragment a :> sub) where toOpenApi _ = toOpenApi (Proxy :: Proxy sub)+#endif++#if MIN_VERSION_servant(0,19,0)+instance (HasOpenApi (ToServantApi sub)) => HasOpenApi (NamedRoutes sub) where+ toOpenApi _ = toOpenApi (Proxy :: Proxy (ToServantApi sub)) #endif -- =======================================================================
src/Servant/OpenApi/Internal/TypeLevel/API.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-}@@ -7,14 +8,19 @@ {-# LANGUAGE UndecidableInstances #-} module Servant.OpenApi.Internal.TypeLevel.API where -import Data.Type.Bool (If)-import GHC.Exts (Constraint)+import GHC.Exts (Constraint) import Servant.API+#if MIN_VERSION_servant(0,19,0)+import Servant.API.Generic (ToServantApi)+#endif -- | Build a list of endpoints from an API. type family EndpointsList api where EndpointsList (a :<|> b) = AppendList (EndpointsList a) (EndpointsList b) EndpointsList (e :> a) = MapSub e (EndpointsList a)+#if MIN_VERSION_servant(0,19,0)+ EndpointsList (NamedRoutes api) = EndpointsList (ToServantApi api)+#endif EndpointsList a = '[a] -- | Check whether @sub@ is a sub API of @api@.@@ -43,6 +49,9 @@ type family IsIn sub api :: Constraint where IsIn e (a :<|> b) = Or (IsIn e a) (IsIn e b) IsIn (e :> a) (e :> b) = IsIn a b+#if MIN_VERSION_servant(0,19,0)+ IsIn e (NamedRoutes api) = IsIn e (ToServantApi api)+#endif IsIn e e = () -- | Check whether a type is a member of a list of types.@@ -83,5 +92,7 @@ BodyTypes' c (ReqBody' mods cs a :> api) = AddBodyType c cs a (BodyTypes' c api) BodyTypes' c (e :> api) = BodyTypes' c api BodyTypes' c (a :<|> b) = AppendList (BodyTypes' c a) (BodyTypes' c b)+#if MIN_VERSION_servant(0,19,0)+ BodyTypes' c (NamedRoutes api) = BodyTypes' c (ToServantApi api)+#endif BodyTypes' c api = '[]-