Skip to content

test the format-assertion vocabulary with a custom metaschema #519

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

Merged
merged 1 commit into from
Sep 28, 2021
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
12 changes: 12 additions & 0 deletions remotes/draft2020-12/format-assertion-false.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$id": "http://localhost:1234/draft2020-12/format-assertion-false.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$vocabulary": {
"https://json-schema.org/draft/2020-12/vocab/core": true,
"https://json-schema.org/draft/2020-12/vocab/format-assertion": false
},
"allOf": [
{ "$ref": "https://json-schema.org/draft/2020-12/schema/meta/core" },
{ "$ref": "https://json-schema.org/draft/2020-12/schema/meta/format-assertion" }
]
}
12 changes: 12 additions & 0 deletions remotes/draft2020-12/format-assertion-true.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$id": "http://localhost:1234/draft2020-12/format-assertion-true.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$vocabulary": {
"https://json-schema.org/draft/2020-12/vocab/core": true,
"https://json-schema.org/draft/2020-12/vocab/format-assertion": true
},
"allOf": [
{ "$ref": "https://json-schema.org/draft/2020-12/schema/meta/core" },
{ "$ref": "https://json-schema.org/draft/2020-12/schema/meta/format-assertion" }
]
}
42 changes: 42 additions & 0 deletions tests/draft-future/optional/format-assertion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"description": "schema that uses custom metaschema with format-assertion: false",
"schema": {
"$id": "https://schema/using/format-assertion/false",
"$schema": "http://localhost:1234/draft2020-12/format-assertion-false.json",
"format": "ipv4"
},
"tests": [
{
"description": "format-assertion: false: valid string",
"data": "127.0.0.1",
"valid": true
},
{
"description": "format-assertion: false: invalid string",
"data": "not-an-ipv4",
"valid": false
}
]
},
{
"description": "schema that uses custom metaschema with format-assertion: true",
"schema": {
"$id": "https://schema/using/format-assertion/true",
"$schema": "http://localhost:1234/draft2020-12/format-assertion-true.json",
"format": "ipv4"
},
"tests": [
{
"description": "format-assertion: true: valid string",
"data": "127.0.0.1",
"valid": true
},
{
"description": "format-assertion: true: invalid string",
"data": "not-an-ipv4",
"valid": false
}
]
}
]
42 changes: 42 additions & 0 deletions tests/draft2020-12/optional/format-assertion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"description": "schema that uses custom metaschema with format-assertion: false",
"schema": {
"$id": "https://schema/using/format-assertion/false",
"$schema": "http://localhost:1234/draft2020-12/format-assertion-false.json",
"format": "ipv4"
},
"tests": [
{
"description": "format-assertion: false: valid string",
"data": "127.0.0.1",
"valid": true
},
{
"description": "format-assertion: false: invalid string",
"data": "not-an-ipv4",
"valid": false
Comment on lines +16 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The results for this test depend on whether the implementation supports the format-assertion vocabulary or not. That's fine considering that this is in "optional", but it might be nice to have a $comment or something that this is the expected result for an implementation that does support the format-assertion vocabulary. Implementations that don't support format-assertion will not error, but will return different result.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably do that for everything in optional/... I think there's an old issue asking for an expanded README too.

Maybe after the conference is done we can have some discussions about how to improve the layout of the test suite?

}
]
},
{
"description": "schema that uses custom metaschema with format-assertion: true",
"schema": {
"$id": "https://schema/using/format-assertion/true",
"$schema": "http://localhost:1234/draft2020-12/format-assertion-true.json",
"format": "ipv4"
},
"tests": [
{
"description": "format-assertion: true: valid string",
"data": "127.0.0.1",
"valid": true
},
{
"description": "format-assertion: true: invalid string",
"data": "not-an-ipv4",
"valid": false
}
]
}
]