json-schema-validator icon indicating copy to clipboard operation
json-schema-validator copied to clipboard

Unknown Metaschema

Open s16508pjwstk opened this issue 5 years ago • 5 comments

Hi,

VERSION: 1.0.40

I've encountered a problem which I cannot solve.

Here is my json-schema validator.

{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://example.com/example.json", "type": "object", "title": "The root schema", "description": "The root schema comprises the entire JSON document.", "default": {}, "examples": [ { "id": "OneShop" } ], "required": [ "id" ], "additionalProperties": false, "properties": { "id": { "$id": "#/properties/id", "type": "string", "pattern":"(OneShop)", "title": "The id schema", "description": "An explanation about the purpose of this instance.", "default": "OneShop", "examples": [ "OneShop" ] } } }

Then I pass validation string listed above to create JsonSchema.

JsonSchema schema = factory.getSchema(schemaStr);

Unfortunately I get

java.util.concurrent.CompletionException: com.networknt.schema.JsonSchemaException: Unknown Metaschema: https://json-schema.org/draft-07/schema

As I saw in sources this should perform GET request for schema, address manually is responsible.

Does anyone know what is the problem?

s16508pjwstk avatar Jun 30 '20 13:06 s16508pjwstk

Change the schema to https from http and it should work. The latest schema URL is https. Thanks.

"$schema": "https://json-schema.org/draft-07/schema#"

stevehu avatar Jun 30 '20 15:06 stevehu

Hi, thanks for a quick response.

Unfortunately, the mentioned error remains. I've changed schema url as follows:

{
    "$schema": "https://json-schema.org/draft-07/schema#",
    "$id": "http://example.com/example.json",
    "type": "object",
    "title": "The root schema",
    "description": "The root schema comprises the entire JSON document.",
    "default": {},
    "examples": [
        {
            "id": "OneShop"
        }
    ],
    "required": [
        "id"
    ],
    "additionalProperties": false,
    "properties": {
        "id": {
            "$id": "#/properties/id",
            "type": "string",
            "pattern":"(OneShop)",
            "title": "The id schema",
            "description": "An explanation about the purpose of this instance.",
            "default": "OneShop",
            "examples": [
                "OneShop"
            ]
        }
    }
}

Any hints?

s16508pjwstk avatar Jun 30 '20 17:06 s16508pjwstk

Could you please submit a PR with your test case to reproduce the issue? Thanks.

stevehu avatar Jul 21 '20 02:07 stevehu

I had the same problem because I was half-consciously following the quickstart and didn't change the VersionFlag from V4 to V7

JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7);

gricey432 avatar Jan 14 '21 01:01 gricey432

@gricey432 Thanks a lot for your answer. It makes sense and I never thought about this reason. @s16508pjwstk Could you please check your source code to see if this is the root cause?

stevehu avatar Jan 14 '21 01:01 stevehu

Closed due to the lack of response from the OP.

fdutton avatar May 23 '23 00:05 fdutton