版本草案07的Spring Boot json架构验证抛出JsonSchemaException:未知元架构:https://json-schema.org/draft-07/schema 问题

版本草案07的Spring Boot json架构验证抛出JsonSchemaException:未知元架构:https://json-schema.org/draft-07/schema 问题,json,spring-boot,jsonschema,json-schema-validator,Json,Spring Boot,Jsonschema,Json Schema Validator,使用json模式验证器验证json会引发加载json模式文件的异常: at com.networknt.schema.JsonSchemaFactory.findMetaSchemaForSchema(JsonSchemaFactory.java:267) at com.networknt.schema.JsonSchemaFactory.createValidationContext(JsonSchemaFactory.java:258) at com.networ

使用json模式验证器验证json会引发加载json模式文件的异常:



    at com.networknt.schema.JsonSchemaFactory.findMetaSchemaForSchema(JsonSchemaFactory.java:267)
    at com.networknt.schema.JsonSchemaFactory.createValidationContext(JsonSchemaFactory.java:258)
    at com.networknt.schema.JsonSchemaFactory.newJsonSchema(JsonSchemaFactory.java:252)
    at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:296)
    at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:304)
    at com.example.demojsonschemavalidation07.JsonSchemaValidator.validate(JsonSchemaValidator.java:28)
    at com.example.demojsonschemavalidation07.JsonSchemaValidatorTest.test_valid_message(JsonSchemaValidatorTest.java:19)
...
  • Json模式版本草稿-07:
    • 库贡献者已经测试了我的输入,因此验证程序库按预期工作:
  • Json验证程序:
  • Spring Boot项目:2.2.10
测试项目

Json模式 JSON文本 完全例外



从草稿-07的URI的
https
中删除
s

草稿-07的URI为
http://...


用于标识模式方言的URI不一定是网络可寻址的。。。换句话说,“它只是一个字符串”,应该完全匹配。

删除草稿-07 URI的
https
中的
s

草稿-07的URI为
http://...

用于标识模式方言的URI不一定是网络可寻址的。。。换句话说,“它只是一个字符串”,应该完全匹配。

找到了错误
JsonSchemaFactory.getInstance()
使用的是默认版本4

修理
JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaPath.getInputStream())

找到了错误
JsonSchemaFactory.getInstance()
使用的是默认版本4

修理
JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaPath.getInputStream())

看起来您最好使用支持的自动检测:“看起来您最好使用支持的自动检测”100%同意您的意见,thx。看起来您最好使用支持的自动检测:“看起来您最好使用支持的自动检测”100%同意您的意见,thx。对,您通常可以强制使用特定的草稿(方言),但最好基于模式本身中定义的方言自动检测。对,您通常可以强制使用特定的草稿(方言),但最好基于模式本身中定义的方言自动检测。
{
  "$id": "https://example.com/person.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Person",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string",
      "description": "The person's first name."
    },
    "lastName": {
      "type": "string",
      "description": "The person's last name."
    },
    "age": {
      "description": "Age in years which must be equal to or greater than zero.",
      "type": "integer",
      "minimum": 0
    }
  }
}
{
  "firstName": "John",
  "lastName": "Doe",
  "age": 21
}
com.networknt.schema.JsonSchemaException: Unknown MetaSchema: https://json-schema.org/draft-07/schema

    at com.networknt.schema.JsonSchemaFactory.findMetaSchemaForSchema(JsonSchemaFactory.java:267)
    at com.networknt.schema.JsonSchemaFactory.createValidationContext(JsonSchemaFactory.java:258)
    at com.networknt.schema.JsonSchemaFactory.newJsonSchema(JsonSchemaFactory.java:252)
    at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:296)
    at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:304)
    at com.example.demojsonschemavalidation07.JsonSchemaValidator.validate(JsonSchemaValidator.java:28)
    at com.example.demojsonschemavalidation07.JsonSchemaValidatorTest.test_valid_message(JsonSchemaValidatorTest.java:19)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:212)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:208)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
    at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
    at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)



Process finished with exit code 255