OpenAPI: Change GET response type to array (#1149)
This commit is contained in:
committed by
Steve Chávez
parent
2b46afe1ec
commit
70e95649fd
@@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- #1113, Fix UPSERT failing when having a camel case PK column - @steve-chavez
|
||||
- #945, Fix slow start-up time on big schemas - @steve-chavez
|
||||
- #1129, Fix view embedding when table is capitalized - @steve-chavez
|
||||
- #1149, OpenAPI: Change `GET` response type to array - @laughedelic
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -198,8 +198,11 @@ makePathItem (t, cs, _) = ("/" ++ unpack tn, p $ tableInsertable t)
|
||||
& at 206 ?~ "Partial Content"
|
||||
& at 200 ?~ Inline ((mempty :: Response)
|
||||
& description .~ "OK"
|
||||
& schema ?~ (Ref $ Reference $ tableName t)
|
||||
& schema ?~ Inline (mempty
|
||||
& type_ .~ SwaggerArray
|
||||
& items ?~ (SwaggerItemsObject $ Ref $ Reference $ tableName t)
|
||||
)
|
||||
)
|
||||
postOp = tOp
|
||||
& parameters .~ map ref ["body." <> tn, "preferReturn"]
|
||||
& at 201 ?~ "Created"
|
||||
|
||||
@@ -85,6 +85,27 @@ spec = do
|
||||
|
||||
deleteResponse `shouldBe` Just "No Content"
|
||||
|
||||
it "includes an array type for GET responses" $ do
|
||||
r <- simpleBody <$> get "/"
|
||||
|
||||
let childGetSchema = r ^? key "paths"
|
||||
. key "/child_entities"
|
||||
. key "get"
|
||||
. key "responses"
|
||||
. key "200"
|
||||
. key "schema"
|
||||
|
||||
liftIO $
|
||||
childGetSchema `shouldBe` Just
|
||||
[aesonQQ|
|
||||
{
|
||||
"items": {
|
||||
"$ref": "#/definitions/child_entities"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
|]
|
||||
|
||||
it "includes definitions to tables" $ do
|
||||
r <- simpleBody <$> get "/"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user