AddClassSchema.schema.json 4.4 KB

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