Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Servant/OpenApi.hs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ import Servant.OpenApi.Internal.Orphans ()
-- "$ref": "#/components/schemas/User"
-- }
-- }
-- }
-- },
-- "required": true
-- },
-- "responses": {
-- "200": {
Expand Down Expand Up @@ -288,7 +289,8 @@ import Servant.OpenApi.Internal.Orphans ()
-- "$ref": "#/components/schemas/User"
-- }
-- }
-- }
-- },
-- "required": true
-- },
-- "responses": {
-- "200": {
Expand Down Expand Up @@ -420,7 +422,8 @@ import Servant.OpenApi.Internal.Orphans ()
-- "$ref": "#/components/schemas/User"
-- }
-- }
-- }
-- },
-- "required": true
-- },
-- "responses": {
-- "200": {
Expand Down
3 changes: 2 additions & 1 deletion src/Servant/OpenApi/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ instance (KnownSymbol sym, ToParamSchema a, HasOpenApi sub, SBoolI (FoldRequired
& in_ .~ ParamHeader
& schema ?~ (Inline $ toParamSchema (Proxy :: Proxy a))

instance (ToSchema a, AllAccept cs, HasOpenApi sub, KnownSymbol (FoldDescription mods)) => HasOpenApi (ReqBody' mods cs a :> sub) where
instance (ToSchema a, AllAccept cs, HasOpenApi sub, KnownSymbol (FoldDescription mods), SBoolI (FoldRequired mods)) => HasOpenApi (ReqBody' mods cs a :> sub) where
toOpenApi _ = toOpenApi (Proxy :: Proxy sub)
& addRequestBody reqBody
& addDefaultResponse400 tname
Expand All @@ -402,6 +402,7 @@ instance (ToSchema a, AllAccept cs, HasOpenApi sub, KnownSymbol (FoldDescription
(defs, ref) = runDeclare (declareSchemaRef (Proxy :: Proxy a)) mempty
reqBody = (mempty :: RequestBody)
& description .~ transDesc (reflectDescription (Proxy :: Proxy mods))
& required .~ (if reflectBool (Proxy :: Proxy (FoldRequired mods)) then Just True else Nothing)
& content .~ InsOrdHashMap.fromList [(t, mempty & schema ?~ ref) | t <- allContentType (Proxy :: Proxy cs)]

-- | This instance is an approximation.
Expand Down