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

Improves Covering Schema #208 #209

Merged
merged 6 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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: 7 additions & 5 deletions format-specs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@
},
"covering": {
"type": "object",
"minProperties": 1,
"required": [
"bbox"
],
Comment on lines +77 to +79
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we want to make this required if we want to add other covering types in the future. Or would we remove this required when we add the future covering type?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or is there some way to define the specific key names allowed? E.g. that today we only allow the "bbox" key inside coverings, but that in the future other keys may be allowed as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that's the question. I mean right now it's required, isn't it? Otherwise it's empty or someone puts anything else.

In the future the requirement could be relaxed of course, but for 1.1 it doesn't feel very useful to not require it?!

With regards to your second comment, I'm not sure I understand what you are looking for.

Copy link
Collaborator

Choose a reason for hiding this comment

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

With regards to your second comment, I'm not sure I understand what you are looking for.

My understanding is that your change means that a bbox key is now required. Instead, is there some way in JSON schema to allow an enum of values? So we currently define an enum with a single variant but can expand that in the future?

Copy link
Collaborator Author

@m-mohr m-mohr Apr 29, 2024

Choose a reason for hiding this comment

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

You could do something like the following to indicate that you expect more fields in the future where having one of them is required:

"anyOf": [
  { "required": ["bbox"] }
]

It's not really different though, it's just an implicit indication for people reading the schema.

The question really is:

Are covering: {} or e.g. covering: { a: "b" } something that should be allowed in 1.1? Or do we always expect that in 1.1 there is a bbox member in covering? I couldn't really figure out what the intention is...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the expectation is that if the covering key exists, then it has a bbox member key.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Then the PR is correct. If you want I can update it to the anyOf, I'm pretty neutral on it. What do others think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed. I think it's fine as-is. Whenever more options are added, the "required": ["bbox"] can change to anyOf or oneOf without losing the meaning. And since only the outermost element has additionalProperties set to false, it seems consistent to leave it out here.

"properties": {
"bbox": {
"type": "object",
Expand All @@ -83,31 +85,31 @@
"xmin": {
"type": "array",
"items": [
{ "type": "string" },
{ "type": "string", "minLength": 1 },
m-mohr marked this conversation as resolved.
Show resolved Hide resolved
{ "const": "xmin" }
],
"additionalItems": false
},
"xmax": {
"type": "array",
"items": [
{ "type": "string" },
{ "type": "string", "minLength": 1 },
{ "const": "xmax" }
],
"additionalItems": false
},
"ymin": {
"type": "array",
"items": [
{ "type": "string" },
{ "type": "string", "minLength": 1 },
{ "const": "ymin" }
],
"additionalItems": false
},
"ymax": {
"type": "array",
"items": [
{ "type": "string" },
{ "type": "string", "minLength": 1 },
{ "const": "ymax" }
],
"additionalItems": false
Expand Down
10 changes: 9 additions & 1 deletion scripts/test_json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ def get_version() -> str:
},
}


# Allow "any_column.xmin" etc.
metadata = copy.deepcopy(metadata_covering_template)
valid_cases["valid_default_bbox"] = metadata
Expand All @@ -235,6 +234,15 @@ def get_version() -> str:
}
valid_cases["valid_but_not_bbox_struct_name"] = metadata

metadata = copy.deepcopy(metadata_covering_template)
metadata["columns"]["geometry"]["covering"]["bbox"] = {
"xmin": ["", "xmin"],
"ymin": ["", "ymin"],
"xmax": ["", "xmax"],
"ymax": ["", "ymax"],
}
invalid_cases["empty_column_name"] = metadata

metadata = copy.deepcopy(metadata_covering_template)
metadata["columns"]["geometry"]["covering"].pop("bbox")
invalid_cases["empty_geometry_bbox"] = metadata
Expand Down
Loading