SchemaStore / SchemaStore/schemastore
JSON schema catalog could include schema $id if available
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.8k
- Forks
- 2.3k
- Avg merge
- 20h 23m
- Merged PRs (30d)
- 124
Description
Description of the feature / enhancement.
Background:
JSON schemas are identified by the value of their $id attribute. Using the official schema drafts as examples:
- https://json-schema.org/draft/2020-12/schema
- http://json-schema.org/draft/2019-09/schema
- http://json-schema.org/draft-07/schema#
However, the URLs in the SchemaStore catalog do not always match:
- https://json-schema.org/draft/2020-12/schema (matches)
- https://json-schema.org/draft/2019-09/schema (uses https instead of http)
- https://json-schema.org/draft-07/schema (uses https, also missing the trailing
#)
Some people have copied these URLs into their documents' $schema properties, such as:
{
"$schema": "https://json-schema.org/draft-07/schema",
...
}
This identifies the schema as, well, nothing. It doesn't match any known or specified JSON schema draft.
Issue:
Tooling can accommodate a difference in schema identifiers vs. URLs. However, currently the catalog does not offer that data, so each schema needs to be downloaded, parsed for an $id value, and then the tooling can utilize that value as appropriate. This is expensive and could lead to extra load placed on the servers.
Request:
For schemas that have an "$id" value, it would be nice to have that data included in the catalog. If it is not available, it can be assumed to be the same as the URL already provided (this would be the same as the current state of the world - not necessarily accurate, but still an assumption being made). For example:
{
"name": "KSP-CKAN",
"description": "Metadata spec for KSP-CKAN",
"fileMatch": ["*.ckan"],
"url": "https://raw.githubusercontent.com/KSP-CKAN/CKAN/master/CKAN.schema"
},
{
"name": "JSON Schema Draft 4",
"description": "Meta-validation schema for JSON Schema Draft 4",
"url": "https://json-schema.org/draft-04/schema",
"id": "https://json-schema.org/draft-04/schema#"
},
{
"name": "JSON Schema Draft 7",
"description": "Meta-validation schema for JSON Schema Draft 7",
"url": "https://json-schema.org/draft-07/schema",
"id": "http://json-schema.org/draft-07/schema#"
},
{
"name": "JSON Schema Draft 8",
"description": "Meta-validation schema for JSON Schema Draft 8",
"url": "https://json-schema.org/draft/2019-09/schema",
"id": "http://json-schema.org/draft/2019-09/schema"
},
{
"name": "JSON Schema Draft 2020-12",
"description": "Meta-validation schema for JSON Schema Draft 2020-12",
"url": "https://json-schema.org/draft/2020-12/schema",
"id": "https://json-schema.org/draft/2020-12/schema"
},
{
"name": "xunit.runner.json",
"description": "xUnit.net runner configuration file",
"fileMatch": ["xunit.runner.json"],
"url": "https://json.schemastore.org/xunit.runner.schema.json",
"id": "https://xunit.net/schema/v2.3/xunit.runner.schema.json"
},
Here I've included a new "id" property for not only the JSON Schema drafts, but also the XUnit runner schema - which you may note is quite different from its URL. The KSP-CKAN does not declare an $id property, so it omits the value in the catalog.
Are you making a PR for this?
No, someone else must create the PR.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue defines a new catalog "id" property and gives examples for schemas with and without an $id. Start by locating the repository's catalog generation and validation entry points, then trace how schema URLs are collected. Done means catalog entries include the declared $id when available and omit the property otherwise, with the examples represented correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100