File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,13 +10,17 @@ module Serv.Swagger where
1010import Control.Lens
1111import Data.Monoid
1212import Data.Singletons
13- import Data.Singletons.Prelude.List
13+ import Data.Singletons.Prelude
1414import Data.Singletons.TypeLits
1515import Data.Swagger
16+ import qualified Network.HTTP.Types.Status as S
1617import Serv.Internal.Api
1718import Serv.Internal.StatusCode
1819import Serv.Internal.Verb
1920
21+ class HasExample a where
22+ anExample :: Maybe a
23+
2024opOfVerb :: forall (v :: Verb ) . Sing v -> Lens' PathItem (Maybe Operation )
2125opOfVerb v =
2226 case v of
@@ -31,10 +35,13 @@ opOfVerb v =
3135pathItem :: forall (v :: Verb ) . Sing v -> Operation -> PathItem
3236pathItem 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
3946swHandler :: forall (h :: Handler Nat Symbol * ) . Sing h -> PathItem
4047swHandler h =
You can’t perform that action at this time.
0 commit comments