fix: empty enum in 'preferParams' openAPI parameter
This commit is contained in:
@@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
- Fix logging the Haskell type instead of the listener error message directly by @laurenceisla in #3588
|
- Fix logging the Haskell type instead of the listener error message directly by @laurenceisla in #3588
|
||||||
- Fix format of `IPv6` address logged at PostgREST startup by @taimoorzaeem in #4291
|
- Fix format of `IPv6` address logged at PostgREST startup by @taimoorzaeem in #4291
|
||||||
|
- Fix empty enum in `preferParams` OpenAPI parameter by @laurenceisla in #4292
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -171,8 +171,9 @@ makePreferParam ts =
|
|||||||
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
& schema .~ ParamOther ((mempty :: ParamOtherSchema)
|
||||||
& in_ .~ ParamHeader
|
& in_ .~ ParamHeader
|
||||||
& type_ ?~ SwaggerString
|
& type_ ?~ SwaggerString
|
||||||
& enum_ .~ JSON.decode (JSON.encode $ foldl (<>) [] (val <$> ts)))
|
& enum_ .~ if null enu then Nothing else JSON.decode (JSON.encode enu))
|
||||||
where
|
where
|
||||||
|
enu = foldl (<>) [] (val <$> ts)
|
||||||
val :: Text -> [Text]
|
val :: Text -> [Text]
|
||||||
val = \case
|
val = \case
|
||||||
"count" -> ["count=none"]
|
"count" -> ["count=none"]
|
||||||
|
|||||||
@@ -1085,6 +1085,13 @@ spec = describe "OpenAPI" $ do
|
|||||||
immutableGet `shouldNotBe` Nothing
|
immutableGet `shouldNotBe` Nothing
|
||||||
immutablePost `shouldNotBe` Nothing
|
immutablePost `shouldNotBe` Nothing
|
||||||
|
|
||||||
|
it "does not include empty enum in the preferParams parameter" $ do
|
||||||
|
r <- simpleBody <$> get "/"
|
||||||
|
let preferParams = r ^? key "parameters" . key "preferParams" . key "enum"
|
||||||
|
|
||||||
|
liftIO $ do
|
||||||
|
preferParams `shouldBe` Nothing
|
||||||
|
|
||||||
describe "Security" $
|
describe "Security" $
|
||||||
it "does not include security or security definitions by default" $ do
|
it "does not include security or security definitions by default" $ do
|
||||||
r <- simpleBody <$> get "/"
|
r <- simpleBody <$> get "/"
|
||||||
|
|||||||
Reference in New Issue
Block a user