Skip to content

Commit c01d5fd

Browse files
committed
wip
1 parent 0feae34 commit c01d5fd

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/Serv/Swagger.hs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ module Serv.Swagger where
1010
import Control.Lens
1111
import Data.Monoid
1212
import Data.Singletons
13-
import Data.Singletons.Prelude.List
13+
import Data.Singletons.Prelude
1414
import Data.Singletons.TypeLits
1515
import Data.Swagger
16+
import qualified Network.HTTP.Types.Status as S
1617
import Serv.Internal.Api
1718
import Serv.Internal.StatusCode
1819
import Serv.Internal.Verb
1920

21+
class HasExample a where
22+
anExample :: Maybe a
23+
2024
opOfVerb :: forall (v :: Verb) . Sing v -> Lens' PathItem (Maybe Operation)
2125
opOfVerb v =
2226
case v of
@@ -31,10 +35,13 @@ opOfVerb v =
3135
pathItem :: forall (v :: Verb) . Sing v -> Operation -> PathItem
3236
pathItem v op = mempty & opOfVerb v .~ Just op
3337

34-
-- swResponses :: forall (rs :: [ (StatusCode Nat, Output Symbol *) ]) . Sing rs -> Responses
35-
-- swResponses rs = mempty & responsesResponses .~ makeRs rs where
36-
-- makeRs SNil = mempty
37-
-- makeRs (SCons (STuple2 code out) rest) = rest & ix
38+
swResponses :: forall (rs :: [ (StatusCode Nat, Output Symbol *) ]) . Sing rs -> Responses
39+
swResponses SNil = mempty
40+
swResponses (SCons (STuple2 code out) rest) =
41+
let cont = swResponses rest
42+
statusNum = S.statusCode (httpStatus code)
43+
resp = mempty
44+
in cont & responsesResponses . ix statusNum .~ Inline resp
3845

3946
swHandler :: forall (h :: Handler Nat Symbol *) . Sing h -> PathItem
4047
swHandler h =

0 commit comments

Comments
 (0)