1module JsonSchemaSpec (spec, main) where
8import JSONSchema.Draft4 as D4
12type ArraySchema = 'SchemaArray '[ 'AEq 1] ('SchemaNumber '[ 'NGt 10])
14type ArrayField = '("foo", ArraySchema)
17 '[ ArrayField, '("bar", 'SchemaOptional ('SchemaText '[ 'TEnum '["foo", "bar"]]))]
19type SchemaExample = 'SchemaObject FieldsSchema
21arrayData :: JsonRepr ArraySchema
22arrayData = ReprArray [ReprNumber 13]
24arrayField :: FieldRepr ArrayField
25arrayField = FieldRepr arrayData
27objectData :: Rec FieldRepr FieldsSchema
28objectData = FieldRepr arrayData
29 :& FieldRepr (ReprOptional (Just (ReprText "foo")))
32exampleData :: JsonRepr SchemaExample
33exampleData = ReprObject objectData
37 it "validates simple schema" $ do
38 let schema = D4.SchemaWithURI (fromJust $ toJsonSchema (Proxy @SchemaExample)) Nothing
39 fetchHTTPAndValidate schema (toJSON exampleData) >>= \case
40 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