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

New property requiredResources #823

Closed
peterdesmet opened this issue Feb 27, 2023 · 4 comments
Closed

New property requiredResources #823

peterdesmet opened this issue Feb 27, 2023 · 4 comments
Milestone

Comments

@peterdesmet
Copy link
Member

When extending a data package profile (like we do for Camtrap DP) it is quite cumbersome to specify required resources. E.g. how to express a data package is only valid if one of the following combinations of resources is present (real use case described here):

  • foo and bar (and any other resource not named foo, bar, baz)
  • foo and baz (and any other resource not named foo, bar, baz)
  • foo, bar and baz (and any other resource not named foo, bar, baz)

Checking that certain resources are present is a common use case, so I asked on Slack.

@roll answered:

Yea not sure how express this in JSONSchema -- it might required an additional validation logic in python

It seems it might require a new Data Package feature like: requiredResource: [name1, name2, etc] while the presence of this property might be enforced in the profile via JSONSchema

Me (@peterdesmet):

Oh, that would be great! Even better would be supporting combinations of requirements, rather than a simple enum. Cf. gbif/ipt#1953 (comment)
🤔 Combinations could maybe also expressed at a higher level:

"oneOf": [
  {
    "requiredResources": ["foo", "bar"]
  },
  {
    "requiredResources: ["foo", "baz"],
  }
]

Something to explore, but it would definitely be very useful!

@roll:

Yea something to think. It's weird that no one thought about it before as package completeness is quite important

@roll
Copy link
Member

roll commented Feb 23, 2024

@peterdesmet
Great news! We can do it using vanilla JSONSchema:

https://json-schema.org/understanding-json-schema/reference/array

resources:
  type: array
  items: false
  prefixItems: # Another option is using "contains"
    - type: object
      properties:
        name: string
        enum: [foo]
    - type: object
      properties:
        name: string
        enum: [bar]

Then, by combining anyOf, etc., we can achieve any desired logic.


I think that's really great so we don't need to create new entities and complicate implementations. I'm closing let me know if it does not work

@roll
Copy link
Member

roll commented Feb 23, 2024

It's also really good because last day I've been thinking about all this stuff regarding profiles/etc we discussed on the call. And I'm getting closer and closer to the model when we can completely rely only on JSON Schema basically for everything on the mete-meta level

@peterdesmet
Copy link
Member Author

peterdesmet commented Feb 23, 2024

Nice and thanks for investigating! Good that we can rely on vanilla JSONSchema. I think it would be very useful though, if such tips make it to the documentation as examples, so others don't have to dive into GitHub issues.

@roll
Copy link
Member

roll commented Feb 23, 2024

Currently, I think that we might have an Extensions specification that might handle everything related to extending the specifications. Also, this guide is also planned - http://datapackage.org/guides/extending-data-package/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants