Hoogle Search

Within LTS Haskell 24.64 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. validateFromJSON :: (ToSchema a, FromJSON a) => Proxy a -> Property

    openapi3 Data.OpenApi.Schema.Generator

    No documentation available.

  2. module Data.OpenApi.Schema.Validation

    Validate JSON values with Swagger Schema.

  3. type ValidationError = String

    openapi3 Data.OpenApi.Schema.Validation

    Validation error message.

  4. renderValidationErrors :: (ToJSON a, ToSchema a) => (a -> [ValidationError]) -> a -> Maybe String

    openapi3 Data.OpenApi.Schema.Validation

    Pretty print validation errors together with actual JSON and Swagger Schema (using encodePretty).

    >>> import Data.Aeson as Aeson
    
    >>> import Data.Foldable (traverse_)
    
    >>> import GHC.Generics
    
    >>> data Phone = Phone { value :: String } deriving (Generic)
    
    >>> data Person = Person { name :: String, phone :: Phone } deriving (Generic)
    
    >>> instance ToJSON Person where toJSON p = object [ "name" Aeson..= name p ]
    
    >>> instance ToSchema Phone
    
    >>> instance ToSchema Person
    
    >>> let person = Person { name = "John", phone = Phone "123456" }
    
    >>> traverse_ putStrLn $ renderValidationErrors validateToJSON person
    Validation against the schema fails:
    * property "phone" is required, but not found in "{\"name\":\"John\"}"
    
    JSON value:
    {
    "name": "John"
    }
    
    Swagger Schema:
    {
    "properties": {
    "name": {
    "type": "string"
    },
    "phone": {
    "$ref": "#/components/schemas/Phone"
    }
    },
    "required": [
    "name",
    "phone"
    ],
    "type": "object"
    }
    
    Swagger Description Context:
    {
    "Phone": {
    "properties": {
    "value": {
    "type": "string"
    }
    },
    "required": [
    "value"
    ],
    "type": "object"
    }
    }
    

  5. validateJSON :: Definitions Schema -> Schema -> Value -> [ValidationError]

    openapi3 Data.OpenApi.Schema.Validation

    Validate JSON Value against Swagger Schema.

    validateJSON mempty (toSchema (Proxy :: Proxy Int)) (toJSON (x :: Int)) == []
    
    NOTE: validateJSON does not perform string pattern validation. See validateJSONWithPatternChecker.

  6. validateJSONWithPatternChecker :: (Pattern -> Text -> Bool) -> Definitions Schema -> Schema -> Value -> [ValidationError]

    openapi3 Data.OpenApi.Schema.Validation

    Validate JSON Value agains Swagger ToSchema for a given value and pattern checker. For validation without patterns see validateJSON.

  7. validatePrettyToJSON :: (ToJSON a, ToSchema a) => a -> Maybe String

    openapi3 Data.OpenApi.Schema.Validation

    Validate ToJSON instance matches ToSchema for a given value. This can be used with QuickCheck to ensure those instances are coherent:

    validateToJSON (x :: Int) == []
    
    NOTE: validateToJSON does not perform string pattern validation. See validateToJSONWithPatternChecker. See renderValidationErrors on how the output is structured.

  8. validateToJSON :: (ToJSON a, ToSchema a) => a -> [ValidationError]

    openapi3 Data.OpenApi.Schema.Validation

    Variant of validatePrettyToJSON with typed output.

  9. validateToJSONWithPatternChecker :: (ToJSON a, ToSchema a) => (Pattern -> Text -> Bool) -> a -> [ValidationError]

    openapi3 Data.OpenApi.Schema.Validation

    Validate ToJSON instance matches ToSchema for a given value and pattern checker. This can be used with QuickCheck to ensure those instances are coherent. For validation without patterns see validateToJSON. See also: renderValidationErrors.

  10. BiDiStreaming :: StreamingType

    proto-lens Data.ProtoLens.Service.Types

    No documentation available.

Page 626 of many | Previous | Next