AddClassSchema.schema.json 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. {
  2. "$schema": "http://json-schema.org/draft-07/schema",
  3. "$id": "https://joystream.org/AddClassSchema.schema.json",
  4. "title": "AddClassSchema",
  5. "description": "JSON schema to describe a new schema for a certain class in Joystream network",
  6. "type": "object",
  7. "additionalProperties": false,
  8. "required": ["className", "newProperties"],
  9. "properties": {
  10. "className": { "type": "string" },
  11. "existingProperties": {
  12. "type": "array",
  13. "uniqueItems": true,
  14. "items": { "$ref": "#/definitions/PropertyInSchemIndex" }
  15. },
  16. "newProperties": {
  17. "type": "array",
  18. "uniqueItems": true,
  19. "items": { "$ref": "#/definitions/Property" }
  20. }
  21. },
  22. "definitions": {
  23. "ClassId": {
  24. "type": "integer",
  25. "minimum": 1
  26. },
  27. "PropertyInSchemIndex": {
  28. "type": "integer",
  29. "minimum": 0
  30. },
  31. "DefaultBoolean": {
  32. "type": "boolean",
  33. "default": false
  34. },
  35. "Property": {
  36. "type": "object",
  37. "additionalProperties": false,
  38. "required": ["name", "property_type"],
  39. "properties": {
  40. "property_type": {
  41. "oneOf": [{ "$ref": "#/definitions/SinglePropertyVariant" }, { "$ref": "#/definitions/VecPropertyVariant" }]
  42. },
  43. "name": { "$ref": "#/definitions/PropertyName" },
  44. "description": { "$ref": "#/definitions/PropertyDescription" },
  45. "required": { "$ref": "#/definitions/DefaultBoolean" },
  46. "unique": { "$ref": "#/definitions/DefaultBoolean" },
  47. "locking_policy": { "$ref": "#/definitions/LockingPolicy" }
  48. }
  49. },
  50. "PropertyName": {
  51. "type": "string",
  52. "minLength": 1,
  53. "maxLength": 100
  54. },
  55. "PropertyDescription": {
  56. "type": "string",
  57. "minLength": 0,
  58. "default": ""
  59. },
  60. "SinglePropertyType": {
  61. "oneOf": [
  62. { "$ref": "#/definitions/PrimitiveProperty", "description": "Primitive property (bool/integer)" },
  63. { "$ref": "#/definitions/TextProperty" },
  64. { "$ref": "#/definitions/HashProperty" },
  65. { "$ref": "#/definitions/ReferenceProperty" }
  66. ]
  67. },
  68. "SinglePropertyVariant": {
  69. "type": "object",
  70. "additionalProperties": false,
  71. "required": ["Single"],
  72. "properties": {
  73. "Single": { "$ref": "#/definitions/SinglePropertyType" }
  74. }
  75. },
  76. "VecPropertyType": {
  77. "type": "object",
  78. "additionalProperties": false,
  79. "required": ["vec_type", "max_length"],
  80. "properties": {
  81. "vec_type": { "$ref": "#/definitions/SinglePropertyType" },
  82. "max_length": { "$ref": "#/definitions/MaxVecItems" }
  83. }
  84. },
  85. "VecPropertyVariant": {
  86. "type": "object",
  87. "additionalProperties": false,
  88. "required": ["Vector"],
  89. "properties": {
  90. "Vector": { "$ref": "#/definitions/VecPropertyType" }
  91. }
  92. },
  93. "PrimitiveProperty": {
  94. "type": "string",
  95. "enum": ["Bool", "Uint16", "Uint32", "Uint64", "Int16", "Int32", "Int64"]
  96. },
  97. "TextProperty": {
  98. "type": "object",
  99. "additionalProperties": false,
  100. "required": ["Text"],
  101. "properties": {
  102. "Text": { "$ref": "#/definitions/MaxTextLength" }
  103. }
  104. },
  105. "HashProperty": {
  106. "type": "object",
  107. "additionalProperties": false,
  108. "required": ["Hash"],
  109. "properties": {
  110. "Hash": { "$ref": "#/definitions/MaxTextLength" }
  111. }
  112. },
  113. "MaxTextLength": {
  114. "type": "integer",
  115. "minimum": 1,
  116. "maximum": 65535
  117. },
  118. "MaxVecItems": {
  119. "type": "integer",
  120. "minimum": 1,
  121. "maximum": 65535
  122. },
  123. "ReferenceProperty": {
  124. "type": "object",
  125. "additionalProperties": false,
  126. "required": ["Reference"],
  127. "properties": {
  128. "Reference": {
  129. "type": "object",
  130. "additionalProperties": false,
  131. "required": ["className"],
  132. "properties": {
  133. "className": {
  134. "type": "string",
  135. "description": "Referenced class name"
  136. },
  137. "sameOwner": {
  138. "$ref": "#/definitions/DefaultBoolean",
  139. "description": "Whether same owner (controller) is required"
  140. }
  141. }
  142. }
  143. }
  144. },
  145. "LockingPolicy": {
  146. "type": "object",
  147. "additionalProperties": false,
  148. "properties": {
  149. "is_locked_from_maintainer": { "$ref": "#/definitions/DefaultBoolean" },
  150. "is_locked_from_controller": { "$ref": "#/definitions/DefaultBoolean" }
  151. }
  152. }
  153. }
  154. }