Fix all hlint errors except for pattern error
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@ main = do
|
||||
|
||||
conf' <- readOptions
|
||||
host <- getHostName
|
||||
conf <- return conf' { configHost = host }
|
||||
let conf = conf'{configHost = host}
|
||||
let port = configPort conf
|
||||
pgSettings = cs (configDatabase conf)
|
||||
appSettings = setPort port
|
||||
|
||||
@@ -32,13 +32,13 @@ toSwaggerType "numeric" = SwaggerNumber
|
||||
toSwaggerType _ = SwaggerString
|
||||
|
||||
makeProperty :: Column -> (Text, Referenced Schema)
|
||||
makeProperty c = (colName c, Inline $ u)
|
||||
makeProperty c = (colName c, Inline u)
|
||||
where
|
||||
r = (mempty :: Schema)
|
||||
r = mempty :: Schema
|
||||
s = if null $ colEnum c
|
||||
then r
|
||||
else r & enum_ .~ decode (encode (colEnum c))
|
||||
t = s & type_ .~ (toSwaggerType $ colType c)
|
||||
t = s & type_ .~ toSwaggerType (colType c)
|
||||
u = t & format ?~ colType c
|
||||
|
||||
makeProperties :: [Column] -> InsOrdHashMap Text (Referenced Schema)
|
||||
@@ -49,7 +49,7 @@ makeDefinition (t, cs, _) =
|
||||
let tn = tableName t in
|
||||
(tn, (mempty :: Schema)
|
||||
& type_ .~ SwaggerObject
|
||||
& properties .~ (makeProperties cs))
|
||||
& properties .~ makeProperties cs)
|
||||
|
||||
makeDefinitions :: [(Table, [Column], [Text])] -> InsOrdHashMap Text Schema
|
||||
makeDefinitions ti = fromList $ map makeDefinition ti
|
||||
@@ -73,7 +73,7 @@ makeRowFilter c =
|
||||
& pattern ?~ makeOperatorPattern)
|
||||
|
||||
makeRowFilters :: [Column] -> [Param]
|
||||
makeRowFilters cs = map makeRowFilter cs
|
||||
makeRowFilters = map makeRowFilter
|
||||
|
||||
makeOrderItems :: [Column] -> [Text]
|
||||
makeOrderItems cs =
|
||||
@@ -163,7 +163,7 @@ makeDeleteParams =
|
||||
[ makePreferParam ["return=representation", "return=minimal"] ]
|
||||
|
||||
makePathItem :: (Table, [Column], [Text]) -> (FilePath, PathItem)
|
||||
makePathItem (t, cs, _) = ("/" ++ (unpack tn), p $ tableInsertable t)
|
||||
makePathItem (t, cs, _) = ("/" ++ unpack tn, p $ tableInsertable t)
|
||||
where
|
||||
tOp = (mempty :: Operation)
|
||||
& tags .~ Set.fromList [tn]
|
||||
@@ -194,11 +194,11 @@ apiSpec ti h p = (mempty :: Swagger)
|
||||
& basePath ?~ "/"
|
||||
& schemes ?~ [Http]
|
||||
& info .~ ((mempty :: Info)
|
||||
& version .~ (pack prettyVersion)
|
||||
& version .~ pack prettyVersion
|
||||
& title .~ "PostgREST API"
|
||||
& description ?~ "This is a dynamic API generated by PostgREST")
|
||||
& host .~ h'
|
||||
& definitions .~ (makeDefinitions ti)
|
||||
& paths .~ (makePathItems ti)
|
||||
& definitions .~ makeDefinitions ti
|
||||
& paths .~ makePathItems ti
|
||||
where
|
||||
h' = Just $ Host h (Just (fromInteger p))
|
||||
|
||||
@@ -220,13 +220,13 @@ app dbStructure conf apiRequest =
|
||||
|
||||
where
|
||||
toTableInfo :: [Table] -> [(Table, [Column], [Text])]
|
||||
toTableInfo ts = map (\t ->
|
||||
toTableInfo = map (\t ->
|
||||
let tSchema = tableSchema t
|
||||
tTable = tableName t
|
||||
cols = filter (filterCol tSchema tTable) $ dbColumns dbStructure
|
||||
pkeys = map pkName $ filter (filterPk tSchema tTable) allPrKeys
|
||||
in
|
||||
(t, cols, pkeys)) ts
|
||||
(t, cols, pkeys))
|
||||
encodeApi :: [(Table, [Column], [Text])] -> BL.ByteString
|
||||
encodeApi ti = encode $ apiSpec ti host port
|
||||
host = configHost conf
|
||||
|
||||
Reference in New Issue
Block a user