'$id' property usage in JSON Schema

前端 未结 2 707
礼貌的吻别
礼貌的吻别 2021-01-17 22:04

I\'m using JSON Schema for validating data.

I think that I may have a mistake on my schema by using the reserved keywords $id. The intention of this field was to des

2条回答
  •  情深已故
    2021-01-17 22:59

    $id is a reserved keyword.

    It serves for:

    • Declaring an identifier for the schema or subschema
    • Declaring a base URL against which $ref URLs are resolved

    You can identify a schema, or a part of your schema (a subschema) by using $id, and then you can reuse it somewhere else by using the $ref keyword. The most simple way of seeing this, is that the $ref would be replaced by the schema with the corresponding id.

    • https://tools.ietf.org/html/draft-wright-json-schema-01#section-9.2

提交回复
热议问题