C# 使用C中的其他JSON模式验证JSON模式#

C# 使用C中的其他JSON模式验证JSON模式#,c#,json,.net-core,jsonschema,json-schema-validator,C#,Json,.net Core,Jsonschema,Json Schema Validator,我想用另一个json模式来评估json模式。我正在创建一个带有默认json模式的表单,并添加一些新属性。之后,我将发布这个新的json模式。此时,我需要验证新模式。因为我想知道新模式中有一些属性。我想举个例子 我的默认架构: { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://example.com/product.s

我想用另一个json模式来评估json模式。我正在创建一个带有默认json模式的表单,并添加一些新属性。之后,我将发布这个新的json模式。此时,我需要验证新模式。因为我想知道新模式中有一些属性。我想举个例子

我的默认架构:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/product.schema.json",
  "title": "Product",
  "description": "A product from Acme's catalog",
  "type": "object",
  "properties": {
    "productId": {
      "description": "The unique identifier for a product",
      "type": "integer"
    },
    "productName": {
      "description": "Name of the product",
      "type": "string"
    }
  },
  "required": [ "productId", "productName" ]
}
新的成功模式:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/product.schema.json",
  "title": "Product",
  "description": "A product from Acme's catalog",
  "type": "object",
  "properties": {
    "productId": {
      "description": "The unique identifier for a product",
      "type": "integer"
    },
    "productName": {
      "description": "Name of the product",
      "type": "string"
    },
    "productType": {
      "description": "Type of the product",
      "type": "string"
    },
    "categoryId": {
      "description": "Category id",
      "type": "integer"
    }
  },
  "required": [ "productId", "productName", "categoryId" ]
}
新的错误模式:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/product.schema.json",
  "title": "Product",
  "description": "A product from Acme's catalog",
  "type": "object",
  "properties": {
    "productId": {
      "description": "The unique identifier for a product",
      "type": "integer"
    }
  },
  "required": [ "productId" ]
}
在一个成功的示例中,添加了具有默认属性的新属性。但是,在错误示例中,默认情况下应为的productName属性已被删除。那么,如何用另一个模式验证该模式呢


编辑:@Relequestual修复了我。我的问题是如何用元模式确认我的模式?

我不清楚你在问什么。你能稍微扩张一下吗?你的措辞意味着我不能理解你的问题。我不理解“用另一个模式验证模式”。这通常意味着使用元模式来确认模式是有效的,但看起来这不是你的意思,我不知道如何解释你所说的。我认为您需要进一步解释“我想知道新模式中有一些特性”的含义?很抱歉,我想提供帮助,但目前无法。@Relequestual“使用元架构确认架构有效”是我问题的正确句子。我有元模式来确认另一个模式。我如何用元模式确认模式?有一个元模式,用于验证JSON模式是否有效。它存在。听起来您创建了一个模式来检查特定的内容(我仍然不明白是什么)。模式仍然是JSON,所以只需将要验证的模式视为JSON即可。如果您只是想验证JSON模式实际上是有效的JSON模式,那么您可以使用元模式,在我看来,这就像您想验证一个模式是另一个模式的严格子集一样。据我所知,没有专门为此设计的工具。我也不明白你为什么要这么做。您的新模式可以
$ref
原始模式,然后添加您喜欢的任何新约束。