Hoogle Search

Within LTS Haskell 24.65 (ghc-9.10.3)

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

  1. type ValidationError = String

    openapi3 Data.OpenApi.Internal.Schema.Validation

    Validation error message.

  2. invalid :: String -> Validation schema a

    openapi3 Data.OpenApi.Internal.Schema.Validation

    Issue an error message.

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

    openapi3 Data.OpenApi.Internal.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"
    }
    }
    

  4. runValidation :: Validation s a -> Config -> s -> Result a

    openapi3 Data.OpenApi.Internal.Schema.Validation

    No documentation available.

  5. valid :: Validation schema ()

    openapi3 Data.OpenApi.Internal.Schema.Validation

    Validation passed.

  6. validateArray :: Vector Value -> Validation Schema ()

    openapi3 Data.OpenApi.Internal.Schema.Validation

    No documentation available.

  7. validateEnum :: Value -> Validation Schema ()

    openapi3 Data.OpenApi.Internal.Schema.Validation

    No documentation available.

  8. validateInteger :: Scientific -> Validation Schema ()

    openapi3 Data.OpenApi.Internal.Schema.Validation

    No documentation available.

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

    openapi3 Data.OpenApi.Internal.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.

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

    openapi3 Data.OpenApi.Internal.Schema.Validation

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

Page 872 of many | Previous | Next