AddClassSchema.schema.json 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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": 49
  54. },
  55. "PropertyDescription": {
  56. "type": "string",
  57. "minLength": 1,
  58. "maxLength": 500,
  59. "default": ""
  60. },
  61. "SinglePropertyType": {
  62. "oneOf": [
  63. { "$ref": "#/definitions/PrimitiveProperty", "description": "Primitive property (bool/integer)" },
  64. { "$ref": "#/definitions/TextProperty" },
  65. { "$ref": "#/definitions/HashProperty" },
  66. { "$ref": "#/definitions/ReferenceProperty" }
  67. ]
  68. },
  69. "SinglePropertyVariant": {
  70. "type": "object",
  71. "additionalProperties": false,
  72. "required": ["Single"],
  73. "properties": {
  74. "Single": { "$ref": "#/definitions/SinglePropertyType" }
  75. }
  76. },
  77. "VecPropertyType": {
  78. "type": "object",
  79. "additionalProperties": false,
  80. "required": ["vec_type", "max_length"],
  81. "properties": {
  82. "vec_type": { "$ref": "#/definitions/SinglePropertyType" },
  83. "max_length": { "$ref": "#/definitions/MaxVecItems" }
  84. }
  85. },
  86. "VecPropertyVariant": {
  87. "type": "object",
  88. "additionalProperties": false,
  89. "required": ["Vector"],
  90. "properties": {
  91. "Vector": { "$ref": "#/definitions/VecPropertyType" }
  92. }
  93. },
  94. "PrimitiveProperty": {
  95. "type": "string",
  96. "enum": ["Bool", "Uint16", "Uint32", "Uint64", "Int16", "Int32", "Int64"]
  97. },
  98. "TextProperty": {
  99. "type": "object",
  100. "additionalProperties": false,
  101. "required": ["Text"],
  102. "properties": {
  103. "Text": { "$ref": "#/definitions/MaxTextLength" }
  104. }
  105. },
  106. "HashProperty": {
  107. "type": "object",
  108. "additionalProperties": false,
  109. "required": ["Hash"],
  110. "properties": {
  111. "Hash": { "$ref": "#/definitions/MaxTextLength" }
  112. }
  113. },
  114. "MaxTextLength": {
  115. "type": "integer",
  116. "minimum": 1,
  117. "maximum": 65535
  118. },
  119. "MaxVecItems": {
  120. "type": "integer",
  121. "minimum": 1,
  122. "maximum": 65535
  123. },
  124. "ReferenceProperty": {
  125. "type": "object",
  126. "additionalProperties": false,
  127. "required": ["Reference"],
  128. "properties": {
  129. "Reference": {
  130. "type": "object",
  131. "additionalProperties": false,
  132. "required": ["className"],
  133. "properties": {
  134. "className": {
  135. "type": "string",
  136. "description": "Referenced class name"
  137. },
  138. "sameOwner": {
  139. "$ref": "#/definitions/DefaultBoolean",
  140. "description": "Whether same owner (controller) is required"
  141. }
  142. }
  143. }
  144. }
  145. },
  146. "LockingPolicy": {
  147. "type": "object",
  148. "additionalProperties": false,
  149. "properties": {
  150. "is_locked_from_maintainer": { "$ref": "#/definitions/DefaultBoolean" },
  151. "is_locked_from_controller": { "$ref": "#/definitions/DefaultBoolean" }
  152. }
  153. }
  154. }
  155. }