nbformat.v4.schema.json 17 KB

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