1{-# LANGUAGE LambdaCase #-}
3{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE TypeApplications #-}
5{-# LANGUAGE OverloadedLists #-}
6{-# LANGUAGE OverloadedStrings #-}
8module JsonSchemaSpec (spec, main) where
15import JSONSchema.Draft4 as D4
19type ArraySchema = 'SchemaArray '[ 'AEq 1] ('SchemaNumber '[ 'NGt 10])
21type ArrayField = '("foo", ArraySchema)
24 '[ ArrayField, '("bar", 'SchemaOptional ('SchemaText '[ 'TEnum '["foo", "bar"]]))]
26type SchemaExample = 'SchemaObject FieldsSchema
28exampleData :: JsonRepr SchemaExample
29exampleData = withRepr @SchemaExample $
30 field @"foo" [ReprNumber 13]
31 :& field @"bar" (pure (ReprText "foo"))
36 it "validates simple schema" $ do
37 let schema = D4.SchemaWithURI (fromJust $ toJsonSchema (Proxy @SchemaExample)) Nothing
38 fetchHTTPAndValidate schema (toJSON exampleData) >>= \case
39 Left _ -> fail "failed to validate test example"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list