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

Impossible to bundle JSON Schema draft-04 itself. #213

Closed
robertmassaioli opened this issue Feb 4, 2021 · 5 comments
Closed

Impossible to bundle JSON Schema draft-04 itself. #213

robertmassaioli opened this issue Feb 4, 2021 · 5 comments

Comments

@robertmassaioli
Copy link

Here is my basic schema:

{
    "$schema": "http:https://json-schema.org/draft-07/schema#",
    "additionalProperties": false,
    "properties": {
        "schema": {
            "$ref": "http:https://json-schema.org/draft-04/schema",
            "title": "schema"
        },
        "tags": {
            "items": {
                "enum": [
                    "forge"
                ],
                "type": "string"
            },
            "title": "tags",
            "type": "array"
        },
    },
    "required": [
        "schema"
    ],
    "type": "object"
}

My code is:

const $RefParser = require('json-schema-ref-parser');

$RefParser.bundle("schema.json").then(schema => {
   console.log(JSON.stringify(schema, null, 2));
}).catch(e => {
   console.error(e);
});

As you can see in "$ref": "http:https://json-schema.org/draft-04/schema",, I want to bundle the draft-04 schema. Instead, my output is:

{
  "$schema": "http:https://json-schema.org/draft-07/schema#",
  "additionalProperties": false,
  "properties": {
    "schema": {
      "$ref": "#/properties/schema/properties/not",
      "title": "schema"
    },
    "tags": {
      "items": {
        "enum": [
          "forge"
        ],
        "type": "string"
      },
      "title": "tags",
      "type": "array"
    }
  },
  "required": [
    "schema"
  ],
  "type": "object"
}

That's not even a valid schema. This looks like a bug to me but I would be very interested in understanding what I have done wrong.

Can somebody please confirm if this is a bug? Cheers.

@robertmassaioli
Copy link
Author

Oh, here is a complete bundle of a sample app.
error-example.zip

@philsturgeon
Copy link
Member

philsturgeon commented Mar 13, 2021

Can you expand on why this needs to work? Not sure of the use case or what is happening, the issue is pretty sparse.

@robertmassaioli
Copy link
Author

@philsturgeon If I want to have a JSON value, that contains a JSON Schema at v4, then I should be able to just reference the v4 schema as a validator. And then when I run the bundle tool here on it, it should make sure that it is bundled inline and that everything works as expected.

@robertmassaioli
Copy link
Author

What do I need to provide such that the use case is easier to understand here? I'm confused that it's not clear that this is a bug and what the expected output would be.

@philsturgeon
Copy link
Member

What tool are you passing this JSON value too that it needs the JSON Schema $schema definition bundled in? Why would a tool want or need that to be done?

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