From 392bc3744788c2b223e3a32519e80199c5bc5c25 2014-06-09 18:52:04 From: Jessica B. Hamrick Date: 2014-06-09 18:52:04 Subject: [PATCH] Conform better to JSON schema version 3 --- diff --git a/IPython/nbformat/v4/v4.withref.json b/IPython/nbformat/v4/v4.withref.json index a5e9f9c..d16fd83 100644 --- a/IPython/nbformat/v4/v4.withref.json +++ b/IPython/nbformat/v4/v4.withref.json @@ -1,155 +1,170 @@ { - "description": "custom json structure with references to generate notebook schema", - "notebook": { - "type": "object", - "description": "notebook v4.0 root schema", - "$schema": "http://json-schema.org/draft-03/schema", - "id": "#notebook", - "required": true, - "additionalProperties": false, - "properties": { - "metadata": { - "type": "object", - "id": "metadata", - "required": true, - "description": "the metadata atribute can contain any additionnal information", - "additionalProperties": true, - "properties": { - "language": { - "type": "string", - "required": true - }, - "kernel_info": { - "type": "object", - "required": true, - "description": "kernel information, to be determined" - } + "$schema": "http://json-schema.org/draft-03/schema#", + "description": "IPython Notebook v4.0 JSON schema.", + "type": "object", + "additionalProperties": false, + "properties": { + "metadata": { + "description": "Notebook root-level metadata.", + "type": "object", + "required": true, + "additionalProperties": true, + "properties": { + "language": { + "description": "Language of the notebook's kernel.", + "type": "string", + "required": true + }, + "kernel_info": { + "description": "Other kernel information, to be determined." + "type": "object", + "required": true, + "additionalProperties": true } - }, - "nbformat_minor": { - "description": "Notebook format, minor number. Incremented for slight variation of notebook format.", - "type": "integer", - "minimum": 0, - "id": "nbformat_minor", - "required": true - }, - "nbformat": { - "description": "Notebook format, major number. Incremented between backward incompatible change is introduced.", - "type": "integer", - "minimum": 4, - "id": "nbformat", - "required": true - }, - "orig_nbformat": { - "description": "Original notebook format, major number.", - "type": "integer", - "minimum": 1, - "id": "orig_nbformat", - "required": false - }, - "cells": { - "$schema": "http://json-schema.org/draft-03/schema", - "description": "array of cells of the current notebook", - "type": "array", - "id": "#cells", - "required": true, - "items": {"$ref": "/any_cell"} + } + }, + "nbformat_minor": { + "description": "Notebook format (minor number). Incremented for slight changes to the notebook format.", + "type": "integer", + "required": true, + "minimum": 0 + }, + "nbformat": { + "description": "Notebook format (major number). Incremented between backwards incompatible changes to the notebook format.", + "type": "integer", + "required": true, + "minimum": 4 + }, + "orig_nbformat": { + "description": "Original notebook format (major number) before converting the notebook between versions.", + "type": "integer", + "required": false, + "minimum": 1 + }, + "cells": { + "description": "array of cells of the current notebook", + "type": "array", + "required": true, + "items": { + "type": [ + {"$ref": "#/definitions/text_cell"}, + {"$ref": "#/definitions/heading_cell"}, + {"$ref": "#/definitions/code_cell"} + ] } } }, - "text_cell": { - "type": "object", - "description": "scheme for text cel and childrenm (level only optionnal argument for HEader cell)", - "$schema": "http://json-schema.org/draft-03/schema", - "id": "#cell", - "required": true, - "additionalProperties": false, - "properties": { - "cell_type": { - "type": "string", - "id": "cell_type", - "required": true - }, - "level": { - "type": "integer", - "minimum": 1, - "maximum": 6, - "id": "level", - "required": false - }, - "metadata": { - "type": "object", - "id": "metadata", - "required": false - }, - "source": { - "description": "source text of the cell", - "type": "array", - "id": "source", - "required": true, - "items": { - "type": "string", - "description": "each item represents one line of cell, terminated by \n", + "definitions": { + + "text_cell": { + "description": "Notebook text cell", + "type": "object", + "additionalProperties": false, + "properties": { + "cell_type": { + "description": "String identifying the type of cell", + "enum": ["markdown", "raw"], "required": true + }, + "metadata": { + "description": "Cell-level metadata", + "type": "object", + "required": true, + "additionalProperties": true + }, + "source": { + "description": "Contents of the cell, represented as an array of lines (each terminated by \n)", + "type": "array", + "required": true, + "items": { + "type": "string", + "pattern": "^.*\n$" + } } } - } - - }, - - "any_cell": { - "description": "Meta cell type that match any cell type", - "type": [{"$ref": "/text_cell"}, {"$ref":"/code_cell"}], - "$schema": "http://json-schema.org/draft-03/schema" - }, + }, - "code_cell": { - "type": "object", - "$schema": "http://json-schema.org/draft-03/schema", - "description": "Cell used to execute code", - "id": "#cell", - "required": true, - "additionalProperties": false, - "properties": { - "cell_type": { - "type": "string", - "id": "cell_type", - "required": true - }, - "metadata": { - "type": "object", - "id": "metadata", - "required": false - }, - "collapsed": { - "type": "boolean", - "required": true - }, - "autoscroll": { - "type": "boolean", - "required": true - }, - "source": { - "description": "for code cell source code", - "type": "array", - "id": "source", - "required": true, - "items": { - "type": "string", - "description": "each item represents one line of the source code written, terminated by \n", + "heading_cell": { + "description": "Notebook heading cell", + "type": "object", + "additionalProperties": false, + "properties": { + "cell_type": { + "description": "String identifying the type of cell", + "enum": ["heading"], "required": true + }, + "metadata": { + "description": "Cell-level metadata", + "type": "object", + "required": true, + "additionalProperties": true + }, + "source": { + "description": "Contents of the cell, represented as an array of lines (each terminated by \n)", + "type": "array", + "required": true, + "items": { + "type": "string", + "pattern": "^.*\n$" + } + }, + "level": { + "description": "Level of heading cells", + "type": "integer", + "required": false, + "minimum": 1, + "maximum": 6 } } - "outputs": { - "description": "output for code cell, to be definied", - "required": true, - "type": "array" - }, - "prompt_number": { - "type": ["integer", "null"], - "required": false, - "minimum": 0 + }, + + "code_cell": { + "description": "Notebook code cell", + "type": "object", + "additionalProperties": false, + "properties": { + "cell_type": { + "description": "String identifying the type of cell", + "enum": ["code"], + "required": true + }, + "metadata": { + "description": "Cell-level metadata", + "type": "object", + "required": true, + "additionalProperties": true + }, + "source": { + "description": "Contents of the cell, represented as an array of lines (each terminated by \n)", + "type": "array", + "required": true, + "items": { + "type": "string", + "pattern": "^.*\n$" + } + } + "outputs": { + "description": "Outputs of cell, to be defined", + "type": "array", + "required": true + }, + "collapsed": { + "description": "Whether the cell is collapsed/expanded", + "type": "boolean", + "required": true + }, + "autoscroll": { + "description": "Whether the cell's output should autoscroll", + "type": "boolean", + "required": true + }, + "prompt_number": { + "type": ["integer", "null"], + "required": true, + "minimum": 0 + } } } }