json-schema-org / json-schema-org/JSON-Schema-Test-Suite

Tests for bundling

Open
#653 28 comments 2 reactions 1 assignee View on GitHub

@jdesrosiers is already working on this.

Since Oct 23, 2023.

enhancement missing test
Dominant language
Python
Stars
750
Forks
308
Avg merge
3d 17h
Merged PRs (30d)
24

Description

A while ago I released an implementation of the official bundling process and included a set of tests in JSON that could be adopted here if there is interest.

Here's an example:

{
  "description": "One external reference",
  "schema": {
    "$id": "https://bundler.hyperjump.io/main",
    "$schema": "https://json-schema.org/draft/2020-12/schema",

    "type": "object",
    "properties": {
      "foo": { "$ref": "/string" }
    }
  },
  "externalSchemas": [
    {
      "$id": "https://bundler.hyperjump.io/string",
      "$schema": "https://json-schema.org/draft/2020-12/schema",

      "type": "string"
    }
  ],
  "bundledSchema": {
    "$id": "https://bundler.hyperjump.io/main",
    "$schema": "https://json-schema.org/draft/2020-12/schema",

    "type": "object",
    "properties": {
      "foo": { "$ref": "/string" }
    },

    "$defs": {
      "https://bundler.hyperjump.io/string": {
        "$id": "https://bundler.hyperjump.io/string",

        "type": "string"
      }
    }
  }
}

Notes/Comments/Rationale:

  • I think this structure is pretty self explanatory, but please ask if anything isn't clear.
  • In hindsight, it might make more sense for "externalSchemas" to be an object rather than an array. The keys would be retrieval URIs and the values would be schemas. This would allow for tests where the retrieval URI and the $id don't match, or where the $id is relative, or where there is no $id.
  • Some of my tests might be a bit implementation specific, so I'm not sure the should all be here. For example, I have an option that allows the bundler to skip certain schemas that you want to remain external. That's not necessarily a feature everyone needs to support.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.