nbformat.v4.0.schema.json 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. {
  2. "$schema": "http://json-schema.org/draft-04/schema#",
  3. "description": "IPython Notebook v4.0 JSON schema.",
  4. "type": "object",
  5. "additionalProperties": false,
  6. "required": ["metadata", "nbformat_minor", "nbformat", "cells"],
  7. "properties": {
  8. "metadata": {
  9. "description": "Notebook root-level metadata.",
  10. "type": "object",
  11. "additionalProperties": true,
  12. "properties": {
  13. "kernelspec": {
  14. "description": "Kernel information.",
  15. "type": "object",
  16. "required": ["name", "display_name"],
  17. "properties": {
  18. "name": {
  19. "description": "Name of the kernel specification.",
  20. "type": "string"
  21. },
  22. "display_name": {
  23. "description": "Name to display in UI.",
  24. "type": "string"
  25. }
  26. }
  27. },
  28. "language_info": {
  29. "description": "Kernel information.",
  30. "type": "object",
  31. "required": ["name"],
  32. "properties": {
  33. "name": {
  34. "description": "The programming language which this kernel runs.",
  35. "type": "string"
  36. },
  37. "codemirror_mode": {
  38. "description": "The codemirror mode to use for code in this language.",
  39. "oneOf": [{ "type": "string" }, { "type": "object" }]
  40. },
  41. "file_extension": {
  42. "description": "The file extension for files in this language.",
  43. "type": "string"
  44. },
  45. "mimetype": {
  46. "description": "The mimetype corresponding to files in this language.",
  47. "type": "string"
  48. },
  49. "pygments_lexer": {
  50. "description": "The pygments lexer to use for code in this language.",
  51. "type": "string"
  52. }
  53. }
  54. },
  55. "orig_nbformat": {
  56. "description": "Original notebook format (major number) before converting the notebook between versions. This should never be written to a file.",
  57. "type": "integer",
  58. "minimum": 1
  59. }
  60. }
  61. },
  62. "nbformat_minor": {
  63. "description": "Notebook format (minor number). Incremented for backward compatible changes to the notebook format.",
  64. "type": "integer",
  65. "minimum": 0
  66. },
  67. "nbformat": {
  68. "description": "Notebook format (major number). Incremented between backwards incompatible changes to the notebook format.",
  69. "type": "integer",
  70. "minimum": 4,
  71. "maximum": 4
  72. },
  73. "cells": {
  74. "description": "Array of cells of the current notebook.",
  75. "type": "array",
  76. "items": { "$ref": "#/definitions/cell" }
  77. }
  78. },
  79. "definitions": {
  80. "cell": {
  81. "type": "object",
  82. "oneOf": [
  83. { "$ref": "#/definitions/raw_cell" },
  84. { "$ref": "#/definitions/markdown_cell" },
  85. { "$ref": "#/definitions/code_cell" }
  86. ]
  87. },
  88. "raw_cell": {
  89. "description": "Notebook raw nbconvert cell.",
  90. "type": "object",
  91. "additionalProperties": false,
  92. "required": ["cell_type", "metadata", "source"],
  93. "properties": {
  94. "cell_type": {
  95. "description": "String identifying the type of cell.",
  96. "enum": ["raw"]
  97. },
  98. "metadata": {
  99. "description": "Cell-level metadata.",
  100. "type": "object",
  101. "additionalProperties": true,
  102. "properties": {
  103. "format": {
  104. "description": "Raw cell metadata format for nbconvert.",
  105. "type": "string"
  106. },
  107. "name": { "$ref": "#/definitions/misc/metadata_name" },
  108. "tags": { "$ref": "#/definitions/misc/metadata_tags" }
  109. }
  110. },
  111. "attachments": { "$ref": "#/definitions/misc/attachments" },
  112. "source": { "$ref": "#/definitions/misc/source" }
  113. }
  114. },
  115. "markdown_cell": {
  116. "description": "Notebook markdown cell.",
  117. "type": "object",
  118. "additionalProperties": false,
  119. "required": ["cell_type", "metadata", "source"],
  120. "properties": {
  121. "cell_type": {
  122. "description": "String identifying the type of cell.",
  123. "enum": ["markdown"]
  124. },
  125. "metadata": {
  126. "description": "Cell-level metadata.",
  127. "type": "object",
  128. "properties": {
  129. "name": { "$ref": "#/definitions/misc/metadata_name" },
  130. "tags": { "$ref": "#/definitions/misc/metadata_tags" }
  131. },
  132. "additionalProperties": true
  133. },
  134. "attachments": { "$ref": "#/definitions/misc/attachments" },
  135. "source": { "$ref": "#/definitions/misc/source" }
  136. }
  137. },
  138. "code_cell": {
  139. "description": "Notebook code cell.",
  140. "type": "object",
  141. "additionalProperties": false,
  142. "required": [
  143. "cell_type",
  144. "metadata",
  145. "source",
  146. "outputs",
  147. "execution_count"
  148. ],
  149. "properties": {
  150. "cell_type": {
  151. "description": "String identifying the type of cell.",
  152. "enum": ["code"]
  153. },
  154. "metadata": {
  155. "description": "Cell-level metadata.",
  156. "type": "object",
  157. "additionalProperties": true,
  158. "properties": {
  159. "collapsed": {
  160. "description": "Whether the cell is collapsed/expanded.",
  161. "type": "boolean"
  162. },
  163. "scrolled": {
  164. "description": "Whether the cell's output is scrolled, unscrolled, or autoscrolled.",
  165. "enum": [true, false, "auto"]
  166. },
  167. "name": { "$ref": "#/definitions/misc/metadata_name" },
  168. "tags": { "$ref": "#/definitions/misc/metadata_tags" }
  169. }
  170. },
  171. "source": { "$ref": "#/definitions/misc/source" },
  172. "outputs": {
  173. "description": "Execution, display, or stream outputs.",
  174. "type": "array",
  175. "items": { "$ref": "#/definitions/output" }
  176. },
  177. "execution_count": {
  178. "description": "The code cell's prompt number. Will be null if the cell has not been run.",
  179. "type": ["integer", "null"],
  180. "minimum": 0
  181. }
  182. }
  183. },
  184. "unrecognized_cell": {
  185. "description": "Unrecognized cell from a future minor-revision to the notebook format.",
  186. "type": "object",
  187. "additionalProperties": true,
  188. "required": ["cell_type", "metadata"],
  189. "properties": {
  190. "cell_type": {
  191. "description": "String identifying the type of cell.",
  192. "not": {
  193. "enum": ["markdown", "code", "raw"]
  194. }
  195. },
  196. "metadata": {
  197. "description": "Cell-level metadata.",
  198. "type": "object",
  199. "properties": {
  200. "name": { "$ref": "#/definitions/misc/metadata_name" },
  201. "tags": { "$ref": "#/definitions/misc/metadata_tags" }
  202. },
  203. "additionalProperties": true
  204. }
  205. }
  206. },
  207. "output": {
  208. "type": "object",
  209. "oneOf": [
  210. { "$ref": "#/definitions/execute_result" },
  211. { "$ref": "#/definitions/display_data" },
  212. { "$ref": "#/definitions/stream" },
  213. { "$ref": "#/definitions/error" }
  214. ]
  215. },
  216. "execute_result": {
  217. "description": "Result of executing a code cell.",
  218. "type": "object",
  219. "additionalProperties": false,
  220. "required": ["output_type", "data", "metadata", "execution_count"],
  221. "properties": {
  222. "output_type": {
  223. "description": "Type of cell output.",
  224. "enum": ["execute_result"]
  225. },
  226. "execution_count": {
  227. "description": "A result's prompt number.",
  228. "type": ["integer", "null"],
  229. "minimum": 0
  230. },
  231. "data": { "$ref": "#/definitions/misc/mimebundle" },
  232. "metadata": { "$ref": "#/definitions/misc/output_metadata" }
  233. }
  234. },
  235. "display_data": {
  236. "description": "Data displayed as a result of code cell execution.",
  237. "type": "object",
  238. "additionalProperties": false,
  239. "required": ["output_type", "data", "metadata"],
  240. "properties": {
  241. "output_type": {
  242. "description": "Type of cell output.",
  243. "enum": ["display_data"]
  244. },
  245. "data": { "$ref": "#/definitions/misc/mimebundle" },
  246. "metadata": { "$ref": "#/definitions/misc/output_metadata" }
  247. }
  248. },
  249. "stream": {
  250. "description": "Stream output from a code cell.",
  251. "type": "object",
  252. "additionalProperties": false,
  253. "required": ["output_type", "name", "text"],
  254. "properties": {
  255. "output_type": {
  256. "description": "Type of cell output.",
  257. "enum": ["stream"]
  258. },
  259. "name": {
  260. "description": "The name of the stream (stdout, stderr).",
  261. "type": "string"
  262. },
  263. "text": {
  264. "description": "The stream's text output, represented as an array of strings.",
  265. "$ref": "#/definitions/misc/multiline_string"
  266. }
  267. }
  268. },
  269. "error": {
  270. "description": "Output of an error that occurred during code cell execution.",
  271. "type": "object",
  272. "additionalProperties": false,
  273. "required": ["output_type", "ename", "evalue", "traceback"],
  274. "properties": {
  275. "output_type": {
  276. "description": "Type of cell output.",
  277. "enum": ["error"]
  278. },
  279. "ename": {
  280. "description": "The name of the error.",
  281. "type": "string"
  282. },
  283. "evalue": {
  284. "description": "The value, or message, of the error.",
  285. "type": "string"
  286. },
  287. "traceback": {
  288. "description": "The error's traceback, represented as an array of strings.",
  289. "type": "array",
  290. "items": { "type": "string" }
  291. }
  292. }
  293. },
  294. "unrecognized_output": {
  295. "description": "Unrecognized output from a future minor-revision to the notebook format.",
  296. "type": "object",
  297. "additionalProperties": true,
  298. "required": ["output_type"],
  299. "properties": {
  300. "output_type": {
  301. "description": "Type of cell output.",
  302. "not": {
  303. "enum": ["execute_result", "display_data", "stream", "error"]
  304. }
  305. }
  306. }
  307. },
  308. "misc": {
  309. "metadata_name": {
  310. "description": "The cell's name. If present, must be a non-empty string.",
  311. "type": "string",
  312. "pattern": "^.+$"
  313. },
  314. "metadata_tags": {
  315. "description": "The cell's tags. Tags must be unique, and must not contain commas.",
  316. "type": "array",
  317. "uniqueItems": true,
  318. "items": {
  319. "type": "string",
  320. "pattern": "^[^,]+$"
  321. }
  322. },
  323. "attachments": {
  324. "description": "Media attachments (e.g. inline images), stored as mimebundle keyed by filename.",
  325. "type": "object",
  326. "patternProperties": {
  327. ".*": {
  328. "description": "The attachment's data stored as a mimebundle.",
  329. "$ref": "#/definitions/misc/mimebundle"
  330. }
  331. }
  332. },
  333. "source": {
  334. "description": "Contents of the cell, represented as an array of lines.",
  335. "$ref": "#/definitions/misc/multiline_string"
  336. },
  337. "execution_count": {
  338. "description": "The code cell's prompt number. Will be null if the cell has not been run.",
  339. "type": ["integer", "null"],
  340. "minimum": 0
  341. },
  342. "mimebundle": {
  343. "description": "A mime-type keyed dictionary of data",
  344. "type": "object",
  345. "additionalProperties": {
  346. "description": "mimetype output (e.g. text/plain), represented as either an array of strings or a string.",
  347. "$ref": "#/definitions/misc/multiline_string"
  348. },
  349. "patternProperties": {
  350. "^application/(.*\\+)?json$": {
  351. "description": "Mimetypes with JSON output, can be any type"
  352. }
  353. }
  354. },
  355. "output_metadata": {
  356. "description": "Cell output metadata.",
  357. "type": "object",
  358. "additionalProperties": true
  359. },
  360. "multiline_string": {
  361. "oneOf": [
  362. { "type": "string" },
  363. {
  364. "type": "array",
  365. "items": { "type": "string" }
  366. }
  367. ]
  368. }
  369. }
  370. }
  371. }