Skip to content

Commit 9c0ceb9

Browse files
authored
Merge pull request #107 from wireapp/fix-validate-no-content
Exclude NoContent from BodyTypes
2 parents 98ff31c + b73dee8 commit 9c0ceb9

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/Servant/Swagger/Internal/Test.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ import Servant.Swagger.Internal.TypeLevel
7777
-- ...No instance for (Arbitrary Contact)
7878
-- ... arising from a use of ‘validateEveryToJSON’
7979
-- ...
80-
validateEveryToJSON :: forall proxy api. TMap (Every [Typeable, Show, Arbitrary, ToJSON, ToSchema]) (BodyTypes JSON api) =>
81-
proxy api -- ^ Servant API.
80+
validateEveryToJSON
81+
:: forall proxy api .
82+
TMap (Every [Typeable, Show, Arbitrary, ToJSON, ToSchema])
83+
(BodyTypes JSON api)
84+
=> proxy api -- ^ Servant API.
8285
-> Spec
8386
validateEveryToJSON _ = props
8487
(Proxy :: Proxy [ToJSON, ToSchema])

src/Servant/Swagger/Internal/TypeLevel/API.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ type AddBodyType c cs a as = If (Elem c cs) (a ': as) as
7272

7373
-- | Extract a list of "body" types for a specific content-type from a servant API.
7474
-- To extract unique types see @'BodyTypes'@.
75+
--
76+
-- @'NoContent'@ is removed from the list and not tested. (This allows for leaving the body
77+
-- completely empty on responses to requests that only accept 'application/json', while
78+
-- setting the content-type in the response accordingly.)
7579
type family BodyTypes' c api :: [*] where
7680
BodyTypes' c (Verb verb b cs (Headers hdrs a)) = AddBodyType c cs a '[]
81+
BodyTypes' c (Verb verb b cs NoContent) = '[]
7782
BodyTypes' c (Verb verb b cs a) = AddBodyType c cs a '[]
7883
BodyTypes' c (ReqBody' mods cs a :> api) = AddBodyType c cs a (BodyTypes' c api)
7984
BodyTypes' c (e :> api) = BodyTypes' c api

stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-11.7
1+
resolver: lts-13.25
22
packages:
33
- '.'
44
- example/

0 commit comments

Comments
 (0)