Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Use the new API project with breaking changes #13

Merged
merged 3 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ex_component_schema/validator/type.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ defmodule ExComponentSchema.Validator.Type do
is_float(data) and Float.round(data) == data
end

defp valid?(_, "component", %{"type" => _}), do: true
defp valid?(_, "component", %{"_type" => _}), do: true
defp valid?(_, "component", _), do: false
defp valid?(_, "listener", data), do: is_map(data)

Expand Down
29 changes: 23 additions & 6 deletions priv/static/draft-lenra.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
"properties": {
"type": "object",
"properties": {
"type": {
"_type": {
"type": "object",
"properties": {
"enum": {
Expand All @@ -327,7 +327,7 @@
}
},
"required": [
"type"
"_type"
]
},
"additionalProperties": {
Expand All @@ -340,7 +340,7 @@
"items": [
{
"enum": [
"type"
"_type"
]
}
],
Expand Down Expand Up @@ -374,7 +374,23 @@
"properties": {
"type": "object",
"properties": {
"action": {
"_type": {
"type": "object",
"properties": {
"enum": {
"type": "array",
"items": [
{
"type": "string"
}
]
}
},
"required": [
"enum"
]
},
"name": {
"type": "object",
"properties": {
"type": {
Expand Down Expand Up @@ -403,7 +419,8 @@
},
"additionalProperties": true,
"required": [
"action",
"_type",
"name",
"props"
]
},
Expand All @@ -412,7 +429,7 @@
"items": [
{
"enum": [
"action"
"name"
]
}
],
Expand Down
38 changes: 24 additions & 14 deletions test/API-Component-Test-Suite/tests/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"schema": {
"type": "component",
"properties": {
"type": {
"_type": {
"enum": [
"machin"
]
Expand All @@ -20,23 +20,29 @@
}
},
"required": [
"type",
"_type",
"onPressed"
],
"additionalProperties": false,
"$defs": {
"listener": {
"type": "listener",
"properties": {
"action": {
"_type": {
"enum": [
"listener"
]
},
"name": {
"type": "string"
},
"props": {
"type": "object"
}
},
"required": [
"action"
"_type",
"name"
]
}
}
Expand All @@ -45,9 +51,10 @@
{
"description": "valid",
"data": {
"type": "machin",
"_type": "machin",
"onPressed": {
"action": "myAction",
"_type": "listener",
"name": "myAction",
"props": {
"my": "data"
}
Expand All @@ -58,9 +65,10 @@
{
"description": "valid, additional properties on listener allowed",
"data": {
"type": "machin",
"_type": "machin",
"onPressed": {
"action": "myAction",
"_type": "listener",
"name": "myAction",
"props": {
"my": "data"
},
Expand All @@ -72,9 +80,10 @@
{
"description": "invalid, additional properties on component not allowed",
"data": {
"type": "machin",
"_type": "machin",
"onPressed": {
"action": "myAction",
"_type": "listener",
"name": "myAction",
"props": {
"my": "data"
}
Expand All @@ -86,9 +95,10 @@
{
"description": "invalid, bad component name",
"data": {
"type": "foo",
"_type": "foo",
"onPressed": {
"action": "myAction",
"_type": "listener",
"name": "myAction",
"props": {
"my": "data"
}
Expand All @@ -99,7 +109,7 @@
{
"description": "invalid, action is required in listener",
"data": {
"type": "machin",
"_type": "machin",
"onPressed": {
"props": {
"my": "data"
Expand All @@ -111,7 +121,7 @@
{
"description": "invalid, onPressed must be defined",
"data": {
"type": "machin"
"_type": "machin"
},
"valid": false
}
Expand Down
14 changes: 7 additions & 7 deletions test/API-Component-Test-Suite/tests/component_child.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"schema": {
"type": "component",
"properties": {
"type": {
"_type": {
"enum": [
"machin"
]
Expand All @@ -15,7 +15,7 @@
"child": {
"type": "component",
"properties": {
"type": {
"_type": {
"enum": [
"truc"
]
Expand All @@ -24,7 +24,7 @@
}
},
"required": [
"type",
"_type",
"text"
],
"additionalProperties": false
Expand All @@ -33,21 +33,21 @@
{
"description": "valid, type for a children",
"data": {
"type": "machin",
"_type": "machin",
"text": "truc",
"child": {
"type": "truc"
"_type": "truc"
}
},
"valid": true
},
{
"description": "invalid, type for a children",
"data": {
"type": "machin",
"_type": "machin",
"text": "truc",
"child": {
"type": "machin"
"_type": "machin"
}
},
"valid": false
Expand Down
14 changes: 7 additions & 7 deletions test/API-Component-Test-Suite/tests/component_children.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"schema": {
"type": "component",
"properties": {
"type": {
"_type": {
"enum": [
"machin"
]
Expand All @@ -17,7 +17,7 @@
"items": {
"type": "component",
"properties": {
"type": {
"_type": {
"enum": [
"truc"
]
Expand All @@ -27,7 +27,7 @@
}
},
"required": [
"type",
"_type",
"text"
],
"additionalProperties": false
Expand All @@ -36,11 +36,11 @@
{
"description": "valid, type for a children",
"data": {
"type": "machin",
"_type": "machin",
"text": "truc",
"children": [
{
"type": "truc"
"_type": "truc"
}
]
},
Expand All @@ -49,11 +49,11 @@
{
"description": "invalid, type for a children",
"data": {
"type": "machin",
"_type": "machin",
"text": "truc",
"children": [
{
"type": "machin"
"_type": "machin"
}
]
},
Expand Down
Loading