servant-swagger-0.1: Generate Swagger specification for your servant API.

Safe HaskellNone
LanguageHaskell2010

Servant.Swagger.Internal

Synopsis

Documentation

class HasSwagger api where Source

Methods

toSwagger :: Proxy api -> Swagger Source

Instances

HasSwagger * Raw Source 
(HasSwagger * a, HasSwagger * b) => HasSwagger * ((:<|>) a b) Source 
AllAccept [*] cs => HasSwagger * (Get cs ()) Source 
(ToSchema a, AllAccept [*] cs, AllToResponseHeader [*] hs) => HasSwagger * (Get cs (Headers hs a)) Source 
(ToSchema a, AllAccept [*] cs) => HasSwagger * (Get cs a) Source 
AllAccept [*] cs => HasSwagger * (Post cs ()) Source 
(ToSchema a, AllAccept [*] cs, AllToResponseHeader [*] hs) => HasSwagger * (Post cs (Headers hs a)) Source 
(ToSchema a, AllAccept [*] cs) => HasSwagger * (Post cs a) Source 
AllAccept [*] cs => HasSwagger * (Delete cs ()) Source 
(ToSchema a, AllAccept [*] cs, AllToResponseHeader [*] hs) => HasSwagger * (Delete cs (Headers hs a)) Source 
(ToSchema a, AllAccept [*] cs) => HasSwagger * (Delete cs a) Source 
AllAccept [*] cs => HasSwagger * (Put cs ()) Source 
(ToSchema a, AllAccept [*] cs, AllToResponseHeader [*] hs) => HasSwagger * (Put cs (Headers hs a)) Source 
(ToSchema a, AllAccept [*] cs) => HasSwagger * (Put cs a) Source 
AllAccept [*] cs => HasSwagger * (Patch cs ()) Source 
(ToSchema a, AllAccept [*] cs, AllToResponseHeader [*] hs) => HasSwagger * (Patch cs (Headers hs a)) Source 
(ToSchema a, AllAccept [*] cs) => HasSwagger * (Patch cs a) Source 
(ToSchema a, AllAccept [*] cs, HasSwagger k sub) => HasSwagger * ((:>) * k (ReqBody * cs a) sub) Source 
(KnownSymbol sym, ToParamSchema a, HasSwagger k sub) => HasSwagger * ((:>) * k (Header sym a) sub) Source 
(KnownSymbol sym, HasSwagger k sub) => HasSwagger * ((:>) * k (QueryFlag sym) sub) Source 
(KnownSymbol sym, ToParamSchema a, HasSwagger k sub) => HasSwagger * ((:>) * k (QueryParams * sym a) sub) Source 
(KnownSymbol sym, ToParamSchema a, HasSwagger k sub) => HasSwagger * ((:>) * k (QueryParam * sym a) sub) Source 
(KnownSymbol sym, ToParamSchema a, HasSwagger k sub) => HasSwagger * ((:>) * k (Capture * sym a) sub) Source 
(KnownSymbol sym, HasSwagger k sub) => HasSwagger * ((:>) Symbol k sym sub) Source 

subOperations :: forall sub api. (IsSubAPI sub api, HasSwagger sub) => Proxy sub -> Proxy api -> Traversal' Swagger Operation Source

All operations of sub API.

addTag :: TagName -> Operation -> Operation Source

Tag an operation.

setResponse :: HttpStatusCode -> Response -> Operation -> Operation Source

Set a response for an operation.

mkEndpoint :: forall a cs hs proxy _verb. (ToSchema a, AllAccept cs, AllToResponseHeader hs) => FilePath -> Lens' PathItem (Maybe Operation) -> HttpStatusCode -> proxy (_verb cs (Headers hs a)) -> Swagger Source

noContentEndpoint :: forall cs proxy verb. AllAccept cs => FilePath -> Lens' PathItem (Maybe Operation) -> proxy (verb cs ()) -> Swagger Source

mkEndpointWithSchemaRef :: forall cs hs proxy verb a. (AllAccept cs, AllToResponseHeader hs) => Maybe (Referenced Schema) -> FilePath -> Lens' PathItem (Maybe Operation) -> HttpStatusCode -> proxy (verb cs (Headers hs a)) -> Swagger Source

prependPath :: FilePath -> Swagger -> Swagger Source

Prepend path to all API endpoints.

addParam :: Param -> Swagger -> Swagger Source

Add parameter to every operation in the spec.

addConsumes :: [MediaType] -> Swagger -> Swagger Source

Add accepted content types to every operation in the spec.

addResponseWith :: (Response -> Response -> Response) -> HttpStatusCode -> Response -> Swagger -> Swagger Source

Add/modify response for every operation in the spec.

addResponse :: HttpStatusCode -> Response -> Swagger -> Swagger Source

Add/overwrite response for every operation in the spec.

class AllAccept cs where Source

Instances

AllAccept [k] ([] k) Source 
(Accept k c, AllAccept [k] cs) => AllAccept [k] ((:) k c cs) Source 

type family AllIsElem xs api :: Constraint Source

Check that every element of xs is an endpoint of api.

Equations

AllIsElem `[]` api = () 
AllIsElem (x : xs) api = (IsIn x api, AllIsElem xs api) 

type family MapSub e xs Source

Apply (e :>) to every API in xs.

Equations

MapSub e `[]` = `[]` 
MapSub e (x : xs) = (e :> x) : MapSub e xs 

type family AppendList xs ys Source

Append two type-level lists.

Equations

AppendList `[]` ys = ys 
AppendList (x : xs) ys = x : AppendList xs ys 

type family EndpointsList api Source

Build a list of endpoints from an API.

type family IsSubAPI sub api :: Constraint Source

Check whether sub is a sub API of api.

Equations

IsSubAPI sub api = AllIsElem (EndpointsList sub) api 

type family Or a b :: Constraint Source

Equations

Or () b = () 
Or a () = () 

type family IsIn sub api :: Constraint Source

Equations

IsIn e (a :<|> b) = Or (IsIn e a) (IsIn e b) 
IsIn (e :> a) (e :> b) = IsIn a b 
IsIn e e = ()