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

Add a new catalog field matching versions based in an expression #3460

Open
smoya opened this issue Dec 19, 2023 · 0 comments
Open

Add a new catalog field matching versions based in an expression #3460

smoya opened this issue Dec 19, 2023 · 0 comments
Labels
enhancement:build-server Propose something new for the SchemaStore web site or build server. (auto-generated by issue forms)

Comments

@smoya
Copy link
Contributor

smoya commented Dec 19, 2023

Description of the feature / enhancement.

Context

Comes from #2440 (comment)_

The need to use different JSON Schema files based on a field or a combination of them is a common use case. For example, AsyncAPI documents have an asyncapi field containing the version of the spec in use by that particular document, I.e. 3.0.0. Each AsyncAPI major version requires a different JSON Schema file for validating documents.

The current API for the Schema Store catalog only supports matching files with their corresponding JSON Schema docs based on the filename (fileMatch).

Description

Add a new field that allows them to match files with their JSON Schema documents based on their content. For instance, following the example above, the asyncapi field in an AsyncAPI spec file.

Additionally, to officialize the usage of the versions field found in some catalog entries as a map of version to JSON Schema document. In fact, I would suggest introducing a new field, not called versions but schemas. This name fits better with it's purpose, which is basically to create aliases of JSON Schema document alternatives.

The following is just a vague suggestion for implementing this feature request. Not written in stone, just for discussion sake:

"schemas": {
    "2.6.0": "https://www.asyncapi.com/schema-store/2.6.0.json",
    "3.0.0": "https://www.asyncapi.com/schema-store/3.0.0.json"
},
"schemaMatch": {
    "2.6.0": "asyncapi == '2.6.0'",
    "3.0.0": "asyncapi == '3.0.0'"
}

Where:

  • schemas field contains all possible JSON Schema documents identified by a name, id, or alias, the version in this case.
  • schemaMatch field contains a map between those schema id's and a JMESPath expression that allows to do boolean expressions over JSON documents. It has implementations in main programming languages.

Additionally, implementers such as VSCode, Taplo's TOML extension, and Red Hat's YAML extension will need to modify their implementations so they can apply those JMESPath expressions in order to match a particular schema.

Are you making a PR for this?

Yes, I will create a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement:build-server Propose something new for the SchemaStore web site or build server. (auto-generated by issue forms)
Projects
None yet
Development

No branches or pull requests

1 participant