Spock-api
Safe HaskellNone
LanguageHaskell2010

Web.Spock.Api.Document

Description

Typed parameter and schema metadata shared by server registration and OpenAPI generation. Schemas describe JSON encodings; custom schemas should match the application's ToJSON/FromJSON instances.

Synopsis

Documentation

data Schema a Source #

schemaObject :: [(Text, Value)] -> Schema a Source #

Construct a custom JSON Schema object (OpenAPI 3.1 / JSON Schema 2020-12). The caller is responsible for its validity and correspondence to the codec.

data PathParameters (p :: [Type]) where Source #

Exactly one name and schema for each captured path value, in path order.

Constructors

NoPathParameters :: PathParameters ('[] :: [Type]) 
PathParameter :: forall a (p1 :: [Type]). ParameterInfo a -> PathParameters p1 -> PathParameters (a ': p1) 

data Parameter a where Source #

Constructors

QueryParam :: forall a. (FromHttpApiData a, ToHttpApiData a) => ParameterInfo a -> Parameter a 
OptionalQueryParam :: forall a1. (FromHttpApiData a1, ToHttpApiData a1) => ParameterInfo a1 -> Parameter (Maybe a1) 
QueryList :: forall a1. (FromHttpApiData a1, ToHttpApiData a1) => ParameterInfo a1 -> Parameter [a1]

Repeated ?name=one&name=two values, preserving order. Missing means [].

HeaderParam :: forall a. (FromHttpApiData a, ToHttpApiData a) => ParameterInfo a -> Parameter a 
OptionalHeaderParam :: forall a1. (FromHttpApiData a1, ToHttpApiData a1) => ParameterInfo a1 -> Parameter (Maybe a1) 

data Parameters (q :: [Type]) where Source #

Constructors

NoParameters :: Parameters ('[] :: [Type]) 
(:>) :: forall a (q1 :: [Type]). Parameter a -> Parameters q1 -> Parameters (a ': q1) infixr 5 

data BodySchema (i :: Maybe Type) where Source #

Constructors

NoBody :: BodySchema ('Nothing :: Maybe Type) 
JsonBody :: forall a. Schema a -> BodySchema ('Just a) 

data SomeEndpoint where Source #

Constructors

SomeEndpoint :: forall (p :: [Type]) (q :: [Type]) (i :: Maybe Type) o. DocumentedEndpoint p q i o -> SomeEndpoint 

newtype OpenApiError Source #

Constructors

OpenApiError Text 

Instances

Instances details
Eq OpenApiError Source # 
Instance details

Defined in Web.Spock.Api.Document

Methods

(==) :: OpenApiError -> OpenApiError -> Bool

(/=) :: OpenApiError -> OpenApiError -> Bool

Show OpenApiError Source # 
Instance details

Defined in Web.Spock.Api.Document

Methods

showsPrec :: Int -> OpenApiError -> ShowS

show :: OpenApiError -> String

showList :: [OpenApiError] -> ShowS

validateEndpoint :: forall (p :: [Type]) (q :: [Type]) (i :: Maybe Type) o. DocumentedEndpoint p q i o -> Either OpenApiError () Source #

openApiDocument :: Text -> Text -> [SomeEndpoint] -> Either OpenApiError Value Source #

Generate OpenAPI 3.1.1 with JSON request/response schemas and typed path, query, and header parameters. Conflicting operation IDs, duplicate methods, and equivalent templates using different path names are rejected.

openApiDocumentWith :: SlashPolicy -> Text -> Text -> [SomeEndpoint] -> Either OpenApiError Value Source #

Generate paths with the application's slash policy. Strict and redirect policies retain trailing and repeated literal slashes in the specification.