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.
-
openapi3 Data.OpenApi.Internal.Schema.Validation Validation error message.
invalid :: String -> Validation schema aopenapi3 Data.OpenApi.Internal.Schema.Validation Issue an error message.
renderValidationErrors :: (ToJSON a, ToSchema a) => (a -> [ValidationError]) -> a -> Maybe Stringopenapi3 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" } }runValidation :: Validation s a -> Config -> s -> Result aopenapi3 Data.OpenApi.Internal.Schema.Validation No documentation available.
-
openapi3 Data.OpenApi.Internal.Schema.Validation Validation passed.
validateArray :: Vector Value -> Validation Schema ()openapi3 Data.OpenApi.Internal.Schema.Validation No documentation available.
validateEnum :: Value -> Validation Schema ()openapi3 Data.OpenApi.Internal.Schema.Validation No documentation available.
validateInteger :: Scientific -> Validation Schema ()openapi3 Data.OpenApi.Internal.Schema.Validation No documentation available.
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.-
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.