Upgrade swagger to 2.4.
Two changes: - tags are now an insert-ordered hashset - type_ .~ -> type_ ?~ with some magic type inference This also updates stack.yaml to the newest GHC 8.6 LTS release.
This commit is contained in:
committed by
Steve Chávez
parent
713b214c9a
commit
4d0661fd9b
+2
-2
@@ -65,7 +65,7 @@ library
|
|||||||
, hasql-transaction >= 0.7.2 && < 0.8
|
, hasql-transaction >= 0.7.2 && < 0.8
|
||||||
, heredoc >= 0.2 && < 0.3
|
, heredoc >= 0.2 && < 0.3
|
||||||
, http-types >= 0.12.2 && < 0.13
|
, http-types >= 0.12.2 && < 0.13
|
||||||
, insert-ordered-containers >= 0.1 && < 0.3
|
, insert-ordered-containers >= 0.2.2 && < 0.3
|
||||||
, interpolatedstring-perl6 >= 1 && < 1.1
|
, interpolatedstring-perl6 >= 1 && < 1.1
|
||||||
, jose >= 0.8.1 && < 0.9
|
, jose >= 0.8.1 && < 0.9
|
||||||
, lens >= 4.14 && < 4.18
|
, lens >= 4.14 && < 4.18
|
||||||
@@ -76,7 +76,7 @@ library
|
|||||||
, protolude >= 0.2.2 && < 0.3
|
, protolude >= 0.2.2 && < 0.3
|
||||||
, regex-tdfa >= 1.2.2 && < 1.3
|
, regex-tdfa >= 1.2.2 && < 1.3
|
||||||
, scientific >= 0.3.4 && < 0.4
|
, scientific >= 0.3.4 && < 0.4
|
||||||
, swagger2 >= 2.1.4 && < 2.4
|
, swagger2 >= 2.4 && < 2.5
|
||||||
, text >= 1.2.2 && < 1.3
|
, text >= 1.2.2 && < 1.3
|
||||||
, time >= 1.6 && < 1.9
|
, time >= 1.6 && < 1.9
|
||||||
, unordered-containers >= 0.2.8 && < 0.3
|
, unordered-containers >= 0.2.8 && < 0.3
|
||||||
|
|||||||
+14
-14
@@ -10,7 +10,7 @@ module PostgREST.OpenAPI (
|
|||||||
, pickProxy
|
, pickProxy
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified Data.Set as Set
|
import qualified Data.HashSet.InsOrd as Set
|
||||||
|
|
||||||
import Control.Arrow ((&&&))
|
import Control.Arrow ((&&&))
|
||||||
import Data.Aeson (decode, encode)
|
import Data.Aeson (decode, encode)
|
||||||
@@ -55,7 +55,7 @@ makeTableDef pks (t, cs, _) =
|
|||||||
let tn = tableName t in
|
let tn = tableName t in
|
||||||
(tn, (mempty :: Schema)
|
(tn, (mempty :: Schema)
|
||||||
& description .~ tableDescription t
|
& description .~ tableDescription t
|
||||||
& type_ .~ SwaggerObject
|
& type_ ?~ SwaggerObject
|
||||||
& properties .~ fromList (map (makeProperty pks) cs)
|
& properties .~ fromList (map (makeProperty pks) cs)
|
||||||
& required .~ map colName (filter (not . colNullable) cs))
|
& required .~ map colName (filter (not . colNullable) cs))
|
||||||
|
|
||||||
@@ -84,13 +84,13 @@ makeProperty pks c = (colName c, Inline s)
|
|||||||
& enum_ .~ e
|
& enum_ .~ e
|
||||||
& format ?~ colType c
|
& format ?~ colType c
|
||||||
& maxLength .~ (fromIntegral <$> colMaxLen c)
|
& maxLength .~ (fromIntegral <$> colMaxLen c)
|
||||||
& type_ .~ toSwaggerType (colType c)
|
& type_ ?~ toSwaggerType (colType c)
|
||||||
|
|
||||||
makeProcSchema :: ProcDescription -> Schema
|
makeProcSchema :: ProcDescription -> Schema
|
||||||
makeProcSchema pd =
|
makeProcSchema pd =
|
||||||
(mempty :: Schema)
|
(mempty :: Schema)
|
||||||
& description .~ pdDescription pd
|
& description .~ pdDescription pd
|
||||||
& type_ .~ SwaggerObject
|
& type_ ?~ SwaggerObject
|
||||||
& properties .~ fromList (map makeProcProperty (pdArgs pd))
|
& properties .~ fromList (map makeProcProperty (pdArgs pd))
|
||||||
& required .~ map pgaName (filter pgaReq (pdArgs pd))
|
& required .~ map pgaName (filter pgaReq (pdArgs pd))
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ makeProcProperty :: PgArg -> (Text, Referenced Schema)
|
|||||||
makeProcProperty (PgArg n t _) = (n, Inline s)
|
makeProcProperty (PgArg n t _) = (n, Inline s)
|
||||||
where
|
where
|
||||||
s = (mempty :: Schema)
|
s = (mempty :: Schema)
|
||||||
& type_ .~ toSwaggerType t
|
& type_ ?~ toSwaggerType t
|
||||||
& format ?~ t
|
& format ?~ t
|
||||||
|
|
||||||
makePreferParam :: [Text] -> Param
|
makePreferParam :: [Text] -> Param
|
||||||
@@ -109,7 +109,7 @@ makePreferParam ts =
|
|||||||
& required ?~ False
|
& required ?~ False
|
||||||
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
||||||
& in_ .~ ParamHeader
|
& in_ .~ ParamHeader
|
||||||
& type_ .~ SwaggerString
|
& type_ ?~ SwaggerString
|
||||||
& enum_ .~ decode (encode ts))
|
& enum_ .~ decode (encode ts))
|
||||||
|
|
||||||
makeProcParam :: ProcDescription -> [Referenced Param]
|
makeProcParam :: ProcDescription -> [Referenced Param]
|
||||||
@@ -132,28 +132,28 @@ makeParamDefs ti =
|
|||||||
& required ?~ False
|
& required ?~ False
|
||||||
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
||||||
& in_ .~ ParamQuery
|
& in_ .~ ParamQuery
|
||||||
& type_ .~ SwaggerString))
|
& type_ ?~ SwaggerString))
|
||||||
, ("order", (mempty :: Param)
|
, ("order", (mempty :: Param)
|
||||||
& name .~ "order"
|
& name .~ "order"
|
||||||
& description ?~ "Ordering"
|
& description ?~ "Ordering"
|
||||||
& required ?~ False
|
& required ?~ False
|
||||||
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
||||||
& in_ .~ ParamQuery
|
& in_ .~ ParamQuery
|
||||||
& type_ .~ SwaggerString))
|
& type_ ?~ SwaggerString))
|
||||||
, ("range", (mempty :: Param)
|
, ("range", (mempty :: Param)
|
||||||
& name .~ "Range"
|
& name .~ "Range"
|
||||||
& description ?~ "Limiting and Pagination"
|
& description ?~ "Limiting and Pagination"
|
||||||
& required ?~ False
|
& required ?~ False
|
||||||
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
||||||
& in_ .~ ParamHeader
|
& in_ .~ ParamHeader
|
||||||
& type_ .~ SwaggerString))
|
& type_ ?~ SwaggerString))
|
||||||
, ("rangeUnit", (mempty :: Param)
|
, ("rangeUnit", (mempty :: Param)
|
||||||
& name .~ "Range-Unit"
|
& name .~ "Range-Unit"
|
||||||
& description ?~ "Limiting and Pagination"
|
& description ?~ "Limiting and Pagination"
|
||||||
& required ?~ False
|
& required ?~ False
|
||||||
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
||||||
& in_ .~ ParamHeader
|
& in_ .~ ParamHeader
|
||||||
& type_ .~ SwaggerString
|
& type_ ?~ SwaggerString
|
||||||
& default_ .~ decode "\"items\""))
|
& default_ .~ decode "\"items\""))
|
||||||
, ("offset", (mempty :: Param)
|
, ("offset", (mempty :: Param)
|
||||||
& name .~ "offset"
|
& name .~ "offset"
|
||||||
@@ -161,14 +161,14 @@ makeParamDefs ti =
|
|||||||
& required ?~ False
|
& required ?~ False
|
||||||
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
||||||
& in_ .~ ParamQuery
|
& in_ .~ ParamQuery
|
||||||
& type_ .~ SwaggerString))
|
& type_ ?~ SwaggerString))
|
||||||
, ("limit", (mempty :: Param)
|
, ("limit", (mempty :: Param)
|
||||||
& name .~ "limit"
|
& name .~ "limit"
|
||||||
& description ?~ "Limiting and Pagination"
|
& description ?~ "Limiting and Pagination"
|
||||||
& required ?~ False
|
& required ?~ False
|
||||||
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
||||||
& in_ .~ ParamQuery
|
& in_ .~ ParamQuery
|
||||||
& type_ .~ SwaggerString))
|
& type_ ?~ SwaggerString))
|
||||||
]
|
]
|
||||||
<> concat [ makeObjectBody (tableName t) : makeRowFilters (tableName t) cs
|
<> concat [ makeObjectBody (tableName t) : makeRowFilters (tableName t) cs
|
||||||
| (t, cs, _) <- ti
|
| (t, cs, _) <- ti
|
||||||
@@ -190,7 +190,7 @@ makeRowFilter tn c =
|
|||||||
& required ?~ False
|
& required ?~ False
|
||||||
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
||||||
& in_ .~ ParamQuery
|
& in_ .~ ParamQuery
|
||||||
& type_ .~ SwaggerString
|
& type_ ?~ SwaggerString
|
||||||
& format ?~ colType c))
|
& format ?~ colType c))
|
||||||
|
|
||||||
makeRowFilters :: Text -> [Column] -> [(Text, Param)]
|
makeRowFilters :: Text -> [Column] -> [(Text, Param)]
|
||||||
@@ -213,7 +213,7 @@ makePathItem (t, cs, _) = ("/" ++ unpack tn, p $ tableInsertable t)
|
|||||||
& at 200 ?~ Inline ((mempty :: Response)
|
& at 200 ?~ Inline ((mempty :: Response)
|
||||||
& description .~ "OK"
|
& description .~ "OK"
|
||||||
& schema ?~ Inline (mempty
|
& schema ?~ Inline (mempty
|
||||||
& type_ .~ SwaggerArray
|
& type_ ?~ SwaggerArray
|
||||||
& items ?~ (SwaggerItemsObject $ Ref $ Reference $ tableName t)
|
& items ?~ (SwaggerItemsObject $ Ref $ Reference $ tableName t)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-17
@@ -1,20 +1,4 @@
|
|||||||
# stack.yaml is used for circle-ci tests. Profiling build fails on circleci
|
resolver: lts-14.3
|
||||||
# with GHC 8.6, so we build with 8.4 for now.
|
|
||||||
|
|
||||||
resolver: lts-13.29
|
|
||||||
extra-deps:
|
|
||||||
- Ranged-sets-0.4.0
|
|
||||||
- configurator-pg-0.1.0.3
|
|
||||||
- http-types-0.12.3
|
|
||||||
- hasql-1.4
|
|
||||||
- hasql-pool-0.5.1
|
|
||||||
- hasql-transaction-0.7.2
|
|
||||||
- text-builder-0.6.5.1
|
|
||||||
- deferred-folds-0.9.10.1
|
|
||||||
- primitive-0.6.4.0
|
|
||||||
- jose-0.8.1.0
|
|
||||||
- text-printer-0.5.0.1
|
|
||||||
- network-2.7.0.1
|
|
||||||
ghc-options:
|
ghc-options:
|
||||||
postgrest: -O2 -Werror -Wall -fwarn-identities -fno-warn-redundant-constraints -optP-Wno-nonportable-include-path
|
postgrest: -O2 -Werror -Wall -fwarn-identities -fno-warn-redundant-constraints -optP-Wno-nonportable-include-path
|
||||||
nix:
|
nix:
|
||||||
|
|||||||
Reference in New Issue
Block a user