Use a specific name for OpenAPI module
This commit is contained in:
+1
-1
@@ -128,7 +128,7 @@ library
|
|||||||
, PostgREST.RangeQuery
|
, PostgREST.RangeQuery
|
||||||
, PostgREST.ApiRequest
|
, PostgREST.ApiRequest
|
||||||
, PostgREST.Types
|
, PostgREST.Types
|
||||||
, PostgREST.ApiSpec
|
, PostgREST.OpenAPI
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
|
|
||||||
Test-Suite spec
|
Test-Suite spec
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ module PostgREST.App (
|
|||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Data.Bifunctor (first)
|
import Data.Bifunctor (first)
|
||||||
import qualified Data.ByteString.Char8 as BS
|
import qualified Data.ByteString.Char8 as BS
|
||||||
import qualified Data.ByteString.Lazy as BL
|
|
||||||
import Data.IORef (IORef, readIORef)
|
import Data.IORef (IORef, readIORef)
|
||||||
import Data.List (find, delete)
|
import Data.List (find, delete)
|
||||||
import Data.Maybe (fromMaybe, fromJust, mapMaybe)
|
import Data.Maybe (fromMaybe, fromJust, mapMaybe)
|
||||||
@@ -61,7 +60,7 @@ import PostgREST.QueryBuilder ( callProc
|
|||||||
, ResultsWithCount
|
, ResultsWithCount
|
||||||
)
|
)
|
||||||
import PostgREST.Types
|
import PostgREST.Types
|
||||||
import PostgREST.ApiSpec
|
import PostgREST.OpenAPI
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
@@ -227,8 +226,7 @@ app dbStructure conf apiRequest =
|
|||||||
pkeys = map pkName $ filter (filterPk tSchema tTable) allPrKeys
|
pkeys = map pkName $ filter (filterPk tSchema tTable) allPrKeys
|
||||||
in
|
in
|
||||||
(t, cols, pkeys))
|
(t, cols, pkeys))
|
||||||
encodeApi :: [(Table, [Column], [Text])] -> BL.ByteString
|
encodeApi ti = encodeOpenAPI ti host port
|
||||||
encodeApi ti = encode $ apiSpec ti host port
|
|
||||||
host = configHost conf
|
host = configHost conf
|
||||||
port = toInteger $ configPort conf
|
port = toInteger $ configPort conf
|
||||||
notFound = responseLBS status404 [] ""
|
notFound = responseLBS status404 [] ""
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module PostgREST.ApiSpec (
|
module PostgREST.OpenAPI (
|
||||||
apiSpec
|
encodeOpenAPI
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.Aeson (decode, encode)
|
import Data.Aeson (decode, encode)
|
||||||
|
import Data.ByteString.Lazy (ByteString)
|
||||||
import Data.HashMap.Strict.InsOrd (InsOrdHashMap, fromList)
|
import Data.HashMap.Strict.InsOrd (InsOrdHashMap, fromList)
|
||||||
import Data.String (IsString (..))
|
import Data.String (IsString (..))
|
||||||
import Data.Text (Text, unpack, pack, concat, intercalate)
|
import Data.Text (Text, unpack, pack, concat, intercalate)
|
||||||
@@ -199,8 +200,8 @@ makeRootPathItem = ("/", p)
|
|||||||
makePathItems :: [(Table, [Column], [Text])] -> InsOrdHashMap FilePath PathItem
|
makePathItems :: [(Table, [Column], [Text])] -> InsOrdHashMap FilePath PathItem
|
||||||
makePathItems ti = fromList $ makeRootPathItem : map makePathItem ti
|
makePathItems ti = fromList $ makeRootPathItem : map makePathItem ti
|
||||||
|
|
||||||
apiSpec :: [(Table, [Column], [Text])] -> String -> Integer -> Swagger
|
postgrestSpec:: [(Table, [Column], [Text])] -> String -> Integer -> Swagger
|
||||||
apiSpec ti h p = (mempty :: Swagger)
|
postgrestSpec ti h p = (mempty :: Swagger)
|
||||||
& basePath ?~ "/"
|
& basePath ?~ "/"
|
||||||
& schemes ?~ [Http]
|
& schemes ?~ [Http]
|
||||||
& info .~ ((mempty :: Info)
|
& info .~ ((mempty :: Info)
|
||||||
@@ -212,3 +213,6 @@ apiSpec ti h p = (mempty :: Swagger)
|
|||||||
& paths .~ makePathItems ti
|
& paths .~ makePathItems ti
|
||||||
where
|
where
|
||||||
h' = Just $ Host h (Just (fromInteger p))
|
h' = Just $ Host h (Just (fromInteger p))
|
||||||
|
|
||||||
|
encodeOpenAPI :: [(Table, [Column], [Text])] -> String -> Integer -> ByteString
|
||||||
|
encodeOpenAPI ti h p = encode $ postgrestSpec ti h p
|
||||||
Reference in New Issue
Block a user