2

para 要素を参照し、para 要素自体が para 要素を参照する text 要素の次の基本的な例を考えます。

これを JSON スキーマで正しく表現しているかどうか疑問に思っていますか?

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="text">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="para"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="para">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="para"/>
      </xs:choice>
      <xs:attribute name="id" type="xs:ID"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

このスタイル { "$ref": "#/definitions/diskDevice" }, http://json-schema.org/example2.htmlで行う必要があると思います 。

これは正しいです?

{
 "id": "http://some.site.somewhere/entry-schema#",
 "$schema": "http://json-schema.org/draft-04/schema#",
 "title": "text",
 "type": "object",
 "properties": {
   "$ref": "#/definitions/para"
 },
 "definitions": {"para": {
  "required": true,
  "type": "object",
  "properties": {
   "id": {
    "type": "string",
    "required": true
   },
   "$ref": "#/definitions/para"
   }
  }
 }
}

ありがとう

4

1 に答える 1

1

その形式の参照は正しいです。物事を整理する唯一の方法ではありませんが、私が推奨する方法です。

ただし、スキーマにバグがあります-「プロパティ」内に直接「$ ref」があります。おそらく、データで「$ref」というプロパティを定義していないので、これは別のプロパティ宣言内にあることを意味していますか?

于 2013-09-10T15:39:19.913 に答える