| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
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
- data Schema a
- schemaObject :: [(Text, Value)] -> Schema a
- schemaValue :: Schema a -> Value
- textSchema :: Schema Text
- intSchema :: Schema Int
- integerSchema :: Schema Integer
- boolSchema :: Schema Bool
- doubleSchema :: Schema Double
- arraySchema :: Schema a -> Schema [a]
- nullableSchema :: Schema a -> Schema (Maybe a)
- data ParameterInfo a = ParameterInfo {}
- parameterInfo :: Text -> Schema a -> ParameterInfo a
- data PathParameters (p :: [Type]) where
- NoPathParameters :: PathParameters ('[] :: [Type])
- PathParameter :: forall a (p1 :: [Type]). ParameterInfo a -> PathParameters p1 -> PathParameters (a ': p1)
- data Parameter a where
- 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]
- 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
- NoParameters :: Parameters ('[] :: [Type])
- (:>) :: forall a (q1 :: [Type]). Parameter a -> Parameters q1 -> Parameters (a ': q1)
- data BodySchema (i :: Maybe Type) where
- NoBody :: BodySchema ('Nothing :: Maybe Type)
- JsonBody :: forall a. Schema a -> BodySchema ('Just a)
- data OperationInfo = OperationInfo {
- oi_operationId :: Text
- oi_summary :: Text
- oi_description :: Text
- oi_tags :: [Text]
- oi_deprecated :: Bool
- operationInfo :: Text -> OperationInfo
- data DocumentedEndpoint (p :: [Type]) (q :: [Type]) (i :: Maybe Type) o = DocumentedEndpoint {
- de_endpoint :: Endpoint p i o
- de_operation :: OperationInfo
- de_pathParameters :: PathParameters p
- de_parameters :: Parameters q
- de_body :: BodySchema i
- de_response :: Schema o
- data SomeEndpoint where
- SomeEndpoint :: forall (p :: [Type]) (q :: [Type]) (i :: Maybe Type) o. DocumentedEndpoint p q i o -> SomeEndpoint
- newtype OpenApiError = OpenApiError Text
- validateEndpoint :: forall (p :: [Type]) (q :: [Type]) (i :: Maybe Type) o. DocumentedEndpoint p q i o -> Either OpenApiError ()
- openApiDocument :: Text -> Text -> [SomeEndpoint] -> Either OpenApiError Value
- openApiDocumentWith :: SlashPolicy -> Text -> Text -> [SomeEndpoint] -> Either OpenApiError Value
Documentation
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.
schemaValue :: Schema a -> Value Source #
textSchema :: Schema Text Source #
boolSchema :: Schema Bool Source #
arraySchema :: Schema a -> Schema [a] Source #
data ParameterInfo a Source #
Constructors
| ParameterInfo | |
parameterInfo :: Text -> Schema a -> ParameterInfo a Source #
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 |
| 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 OperationInfo Source #
Constructors
| OperationInfo | |
Fields
| |
operationInfo :: Text -> OperationInfo Source #
data DocumentedEndpoint (p :: [Type]) (q :: [Type]) (i :: Maybe Type) o Source #
Constructors
| DocumentedEndpoint | |
Fields
| |
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
| Eq OpenApiError Source # | |
Defined in Web.Spock.Api.Document | |
| Show OpenApiError Source # | |
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.