Skip to content

Commit

Permalink
added schema testdata back
Browse files Browse the repository at this point in the history
  • Loading branch information
conneroisu committed Oct 26, 2024
1 parent 8e0b071 commit 4038a36
Show file tree
Hide file tree
Showing 52 changed files with 3,324 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ func TestReflectFromType(t *testing.T) {
s := r.ReflectFromType(typ)
assert.EqualValues(
t,
"https://github.com/conneroisu/groq-go/test-user",
"https://github.com/conneroisu/groq-go/pkg/schema/test-user",
s.ID,
)

Expand Down
1 change: 1 addition & 0 deletions pkg/schema/testdata/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.out.json
229 changes: 229 additions & 0 deletions pkg/schema/testdata/allow_additional_props.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/conneroisu/groq-go/pkg/schema/test-user",
"$ref": "#/$defs/TestUser",
"$defs": {
"Bytes": {
"type": "string",
"contentEncoding": "base64"
},
"GrandfatherType": {
"properties": {
"family_name": {
"type": "string"
}
},
"type": "object",
"required": [
"family_name"
]
},
"MapType": {
"type": "object"
},
"TestUser": {
"properties": {
"id": {
"type": "integer"
},
"some_base_property": {
"type": "integer"
},
"grand": {
"$ref": "#/$defs/GrandfatherType"
},
"SomeUntaggedBaseProperty": {
"type": "boolean"
},
"PublicNonExported": {
"type": "integer"
},
"MapType": {
"$ref": "#/$defs/MapType"
},
"name": {
"type": "string",
"maxLength": 20,
"minLength": 1,
"pattern": ".*",
"title": "the name",
"description": "this is a property",
"default": "alex",
"readOnly": true,
"examples": [
"joe",
"lucy"
]
},
"password": {
"type": "string",
"writeOnly": true
},
"friends": {
"items": {
"type": "integer"
},
"type": "array",
"description": "list of IDs, omitted when empty"
},
"tags": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"options": {
"type": "object"
},
"TestFlag": {
"type": "boolean"
},
"TestFlagFalse": {
"type": "boolean",
"default": false
},
"TestFlagTrue": {
"type": "boolean",
"default": true
},
"birth_date": {
"type": "string",
"format": "date-time"
},
"website": {
"type": "string",
"format": "uri"
},
"network_address": {
"type": "string",
"format": "ipv4"
},
"photo": {
"type": "string",
"contentEncoding": "base64"
},
"photo2": {
"$ref": "#/$defs/Bytes"
},
"feeling": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"age": {
"type": "integer",
"maximum": 120,
"exclusiveMaximum": 121,
"minimum": 18,
"exclusiveMinimum": 17
},
"email": {
"type": "string",
"format": "email"
},
"uuid": {
"type": "string",
"format": "uuid"
},
"Baz": {
"type": "string",
"foo": [
"bar",
"bar1"
],
"hello": "world"
},
"bool_extra": {
"type": "string",
"isFalse": false,
"isTrue": true
},
"color": {
"type": "string",
"enum": [
"red",
"green",
"blue"
]
},
"rank": {
"type": "integer",
"enum": [
1,
2,
3
]
},
"mult": {
"type": "number",
"enum": [
1.0,
1.5,
2.0
]
},
"roles": {
"items": {
"type": "string",
"enum": [
"admin",
"moderator",
"user"
]
},
"type": "array"
},
"priorities": {
"items": {
"type": "integer",
"enum": [
-1,
0,
1
]
},
"type": "array"
},
"offsets": {
"items": {
"type": "number",
"enum": [
1.570796,
3.141592,
6.283185
]
},
"type": "array"
},
"anything": true,
"raw": true
},
"type": "object",
"required": [
"id",
"some_base_property",
"grand",
"SomeUntaggedBaseProperty",
"PublicNonExported",
"MapType",
"name",
"password",
"TestFlag",
"photo",
"photo2",
"age",
"email",
"uuid",
"Baz",
"color",
"roles",
"raw"
]
}
}
}
91 changes: 91 additions & 0 deletions pkg/schema/testdata/anyof.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/conneroisu/groq-go/pkg/schema/root-any-of",
"$ref": "#/$defs/RootAnyOf",
"$defs": {
"ChildAnyOf": {
"anyOf": [
{
"required": [
"child1",
"child4"
],
"title": "group1"
},
{
"required": [
"child2",
"child3"
],
"title": "group2"
}
],
"properties": {
"child1": {
"type": "string"
},
"child2": {
"type": "string"
},
"child3": {
"oneOf": [
{
"type": "string"
},
{
"type": "array"
}
]
},
"child4": {
"type": "string"
}
},
"additionalProperties": false,
"type": "object"
},
"RootAnyOf": {
"anyOf": [
{
"required": [
"field1",
"field4"
],
"title": "group1"
},
{
"required": [
"field2"
],
"title": "group2"
}
],
"properties": {
"field1": {
"type": "string"
},
"field2": {
"type": "string"
},
"field3": {
"anyOf": [
{
"type": "string"
},
{
"type": "array"
}
]
},
"field4": {
"type": "string"
},
"child": {
"$ref": "#/$defs/ChildAnyOf"
}
},
"additionalProperties": false,
"type": "object"
}
}
}
34 changes: 34 additions & 0 deletions pkg/schema/testdata/array_handling.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/conneroisu/groq-go/pkg/schema/array-handler",
"$ref": "#/$defs/ArrayHandler",
"$defs": {
"ArrayHandler": {
"properties": {
"min_len": {
"items": {
"type": "string",
"minLength": 2
},
"type": "array",
"default": [
"qwerty"
]
},
"min_val": {
"items": {
"type": "number",
"minimum": 2.5
},
"type": "array"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"min_len",
"min_val"
]
}
}
}
13 changes: 13 additions & 0 deletions pkg/schema/testdata/array_type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/conneroisu/groq-go/pkg/schema/array-type",
"$ref": "#/$defs/ArrayType",
"$defs": {
"ArrayType": {
"items": {
"type": "string"
},
"type": "array"
}
}
}
Loading

0 comments on commit 4038a36

Please sign in to comment.