nbformat.v4.2.schema.json 13 KB

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