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

Vocab for combinations of keywords #43

Open
gregsdennis opened this issue Jul 20, 2022 · 5 comments
Open

Vocab for combinations of keywords #43

gregsdennis opened this issue Jul 20, 2022 · 5 comments

Comments

@gregsdennis
Copy link
Member

The keyword set defined by the core vocabs can do lots of things, but sometimes those things are difficult or cumbersome to represent.

I'd like to propose a combinatorics vocab that defines keywords that represent combinations of applicators.

For example, if you wanted to require any of a number of properties, you currently have to do

{
  "anyOf": [
    { "required": [ "foo" ] },
    { "required": [ "bar" ] },
    { "required": [ "baz" ] },
    { "required": [ "qux" ] },
    { "required": [ "quux" ] },
    { "required": [ "quuz" ] }
  ]
}

or maybe (though it's not quite the same thing because the above also allows additional properties)

{
  "properties": {
    "foo": true,
    "bar": true,
    "baz": true,
    "qux": true,
    "quux": true,
    "quuz": true
  },
  "additionalProperties": false,
  "minProperties": 1
}

But the vocab could define a single keyword, e.g. anyOfRequired that does this much more simply

{
  "anyOfRequired": [ "foo", "bar", "baz", "qux", "quux", "quuz" ]
}

This vocab would be full of odds and ends like this.

A lot of keyword requests are about making things like this easier, so maybe we just have an evolving vocab to contain these "refactor" keywords.

@gregsdennis
Copy link
Member Author

There is mention of this in json-schema-org/json-schema-spec#846 (comment)

There are a number of syntactic sugar proposals, and as @jdesrosiers notes maybe making them an additional vocabulary outside of the Core and Validation specification documents would be a good approach. - @handrews

@Era-cell
Copy link

I think there should be a minimumRequired keyword.

@gregsdennis
Copy link
Member Author

@Era-cell we already have min/max properties. Is that different from what you're asking for?

@Era-cell
Copy link

Era-cell commented Feb 27, 2024

@Era-cell we already have min/max properties. Is that different from what you're asking for?

Yeah its different, like: arrays have minContains so we should have minRequired which will be taking integer values

@gregsdennis
Copy link
Member Author

@Era-cell you're probably going to be interested in json-schema-org/json-schema-spec#1488. I think this covers what you're looking for.

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

No branches or pull requests

2 participants