Yurik has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/324860

Change subject: Switching to a more standard compliant schema
......................................................................

Switching to a more standard compliant schema

* all schema information is now part of the top level "schema" element:

    "schema": {
        "fields": [
            {
                "name": "col1",
                "type": "string"
            }, ...

* Optional "title" inside the above schema-fields allows for column labeling
* Top level "description" instead of "info"
* Top level "data" instead of "rows"

See https://github.com/frictionlessdata/specs/issues/265#issuecomment-264264230

Change-Id: I2dc08940cf9e314d5d822dce8c7cb97052aee99b
---
A tests/phpunit/tabular-bad/bad-fields.json
A tests/phpunit/tabular-bad/bad-fields2.json
M tests/phpunit/tabular-bad/bad-header-symbol.json
M tests/phpunit/tabular-bad/bad-license.json
A tests/phpunit/tabular-bad/bad-schema.json
M tests/phpunit/tabular-bad/bad-summary.json
M tests/phpunit/tabular-bad/bad-summary2.json
M tests/phpunit/tabular-bad/empty-license.json
A tests/phpunit/tabular-bad/extra-field.json
A tests/phpunit/tabular-bad/extra-schema.json
A tests/phpunit/tabular-bad/extra-top.json
D tests/phpunit/tabular-bad/header-bad-type.json
A tests/phpunit/tabular-bad/no-field-name.json
A tests/phpunit/tabular-bad/no-field-type.json
A tests/phpunit/tabular-bad/no-fields.json
D tests/phpunit/tabular-bad/no-headers.json
M tests/phpunit/tabular-bad/no-license.json
M tests/phpunit/tabular-bad/no-rows.json
A tests/phpunit/tabular-bad/no-schema.json
D tests/phpunit/tabular-bad/no-types.json
M tests/phpunit/tabular-bad/row-count-mismatch.json
M tests/phpunit/tabular-bad/row-vals-count.json
M tests/phpunit/tabular-bad/type-mismatch.json
D tests/phpunit/tabular-bad/types-headers-count.json
M tests/phpunit/tabular-bad/unknown-license.json
M tests/phpunit/tabular-bad/unknown-type.json
M tests/phpunit/tabular-good/01.json
M tests/phpunit/tabular-good/02.json
M tests/phpunit/tabular-good/03.json
M tests/phpunit/tabular-good/04.json
M tests/phpunit/tabular-good/05.json
M tests/phpunit/tabular-good/06.json
M tests/phpunit/tabular-good/07.json
M tests/phpunit/tabular-good/08.json
34 files changed, 271 insertions(+), 94 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/JsonConfig 
refs/changes/60/324860/1

diff --git a/tests/phpunit/tabular-bad/bad-fields.json 
b/tests/phpunit/tabular-bad/bad-fields.json
new file mode 100644
index 0000000..e9e8cb2
--- /dev/null
+++ b/tests/phpunit/tabular-bad/bad-fields.json
@@ -0,0 +1,7 @@
+{
+    "license": "CC0-1.0",
+    "schema": {
+        "fields": {}
+    },
+    "data": []
+}
diff --git a/tests/phpunit/tabular-bad/bad-fields2.json 
b/tests/phpunit/tabular-bad/bad-fields2.json
new file mode 100644
index 0000000..b8c2227
--- /dev/null
+++ b/tests/phpunit/tabular-bad/bad-fields2.json
@@ -0,0 +1,9 @@
+{
+    "license": "CC0-1.0",
+    "schema": {
+        "fields": [
+            []
+        ]
+    },
+    "data": []
+}
diff --git a/tests/phpunit/tabular-bad/bad-header-symbol.json 
b/tests/phpunit/tabular-bad/bad-header-symbol.json
index 7ca880d..acf5611 100644
--- a/tests/phpunit/tabular-bad/bad-header-symbol.json
+++ b/tests/phpunit/tabular-bad/bad-header-symbol.json
@@ -1,6 +1,12 @@
 {
     "license": "CC0-1.0",
-    "headers": ["a-b"],
-    "types": ["string"],
-    "rows": []
+    "schema": {
+        "fields": [
+            {
+                "name": "a-b",
+                "type": "string"
+            }
+        ]
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-bad/bad-license.json 
b/tests/phpunit/tabular-bad/bad-license.json
index dad424a..0bc6533 100644
--- a/tests/phpunit/tabular-bad/bad-license.json
+++ b/tests/phpunit/tabular-bad/bad-license.json
@@ -1,6 +1,14 @@
 {
-    "license": {"en": "blah"},
-    "headers": ["col1"],
-    "types": ["string"],
-    "rows": []
+    "license": {
+        "en": "blah"
+    },
+    "schema": {
+        "fields": [
+            {
+                "name": "col1",
+                "type": "string"
+            }
+        ]
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-bad/bad-schema.json 
b/tests/phpunit/tabular-bad/bad-schema.json
new file mode 100644
index 0000000..9521273
--- /dev/null
+++ b/tests/phpunit/tabular-bad/bad-schema.json
@@ -0,0 +1,5 @@
+{
+    "license": "CC0-1.0",
+    "schema": "",
+    "data": []
+}
diff --git a/tests/phpunit/tabular-bad/bad-summary.json 
b/tests/phpunit/tabular-bad/bad-summary.json
index b60c8c5..9b3e118 100644
--- a/tests/phpunit/tabular-bad/bad-summary.json
+++ b/tests/phpunit/tabular-bad/bad-summary.json
@@ -1,7 +1,10 @@
 {
-    "sources": ["a"],
+    "sources": [
+        "a"
+    ],
     "license": "CC0-1.0",
-    "headers": [],
-    "types": [],
-    "rows": []
+    "schema": {
+        "fields": []
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-bad/bad-summary2.json 
b/tests/phpunit/tabular-bad/bad-summary2.json
index 61fd134..574b006 100644
--- a/tests/phpunit/tabular-bad/bad-summary2.json
+++ b/tests/phpunit/tabular-bad/bad-summary2.json
@@ -1,7 +1,8 @@
 {
     "sources": {"en":"nope"},
     "license": "CC0-1.0",
-    "headers": [],
-    "types": [],
-    "rows": []
+    "schema": {
+        "fields": []
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-bad/empty-license.json 
b/tests/phpunit/tabular-bad/empty-license.json
index 7ee35e3..c01b3ec 100644
--- a/tests/phpunit/tabular-bad/empty-license.json
+++ b/tests/phpunit/tabular-bad/empty-license.json
@@ -1,6 +1,7 @@
 {
     "license": "",
-    "headers": ["col1"],
-    "types": ["string"],
-    "rows": []
+    "schema": {
+        "fields": []
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-bad/extra-field.json 
b/tests/phpunit/tabular-bad/extra-field.json
new file mode 100644
index 0000000..7ec26f1
--- /dev/null
+++ b/tests/phpunit/tabular-bad/extra-field.json
@@ -0,0 +1,13 @@
+{
+    "license": "CC0-1.0",
+    "schema": {
+        "fields": [
+            {
+                "name": "a",
+                "type": "string",
+                "extra": ""
+            }
+        ]
+    },
+    "data": []
+}
diff --git a/tests/phpunit/tabular-bad/extra-schema.json 
b/tests/phpunit/tabular-bad/extra-schema.json
new file mode 100644
index 0000000..7dbe51c
--- /dev/null
+++ b/tests/phpunit/tabular-bad/extra-schema.json
@@ -0,0 +1,8 @@
+{
+    "license": "CC0-1.0",
+    "schema": {
+        "fields": [],
+        "extra": ""
+    },
+    "data": []
+}
diff --git a/tests/phpunit/tabular-bad/extra-top.json 
b/tests/phpunit/tabular-bad/extra-top.json
new file mode 100644
index 0000000..8010adc
--- /dev/null
+++ b/tests/phpunit/tabular-bad/extra-top.json
@@ -0,0 +1,8 @@
+{
+    "license": "CC0-1.0",
+    "schema": {
+        "fields": []
+    },
+    "data": [],
+    "extra": ""
+}
diff --git a/tests/phpunit/tabular-bad/header-bad-type.json 
b/tests/phpunit/tabular-bad/header-bad-type.json
deleted file mode 100644
index 7a4a3c8..0000000
--- a/tests/phpunit/tabular-bad/header-bad-type.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
-    "license": "CC0-1.0",
-    "headers": [10],
-    "types": ["string"],
-    "rows": []
-}
diff --git a/tests/phpunit/tabular-bad/no-field-name.json 
b/tests/phpunit/tabular-bad/no-field-name.json
new file mode 100644
index 0000000..b669193
--- /dev/null
+++ b/tests/phpunit/tabular-bad/no-field-name.json
@@ -0,0 +1,9 @@
+{
+    "license": "CC0-1.0",
+    "schema": {
+        "fields": [{
+            "type": "string"
+        }]
+    },
+    "data": []
+}
diff --git a/tests/phpunit/tabular-bad/no-field-type.json 
b/tests/phpunit/tabular-bad/no-field-type.json
new file mode 100644
index 0000000..d96c436
--- /dev/null
+++ b/tests/phpunit/tabular-bad/no-field-type.json
@@ -0,0 +1,9 @@
+{
+    "license": "CC0-1.0",
+    "schema": {
+        "fields": [{
+            "name": "a"
+        }]
+    },
+    "data": []
+}
diff --git a/tests/phpunit/tabular-bad/no-fields.json 
b/tests/phpunit/tabular-bad/no-fields.json
new file mode 100644
index 0000000..92f993e
--- /dev/null
+++ b/tests/phpunit/tabular-bad/no-fields.json
@@ -0,0 +1,5 @@
+{
+    "license": "CC0-1.0",
+    "schema": {},
+    "data": []
+}
diff --git a/tests/phpunit/tabular-bad/no-headers.json 
b/tests/phpunit/tabular-bad/no-headers.json
deleted file mode 100644
index 437f426..0000000
--- a/tests/phpunit/tabular-bad/no-headers.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-    "license": "CC0-1.0",
-    "types": ["string"],
-    "rows": []
-}
diff --git a/tests/phpunit/tabular-bad/no-license.json 
b/tests/phpunit/tabular-bad/no-license.json
index ead3932..22f98d9 100644
--- a/tests/phpunit/tabular-bad/no-license.json
+++ b/tests/phpunit/tabular-bad/no-license.json
@@ -1,5 +1,6 @@
 {
-    "headers": ["col1"],
-    "types": ["string"],
-    "rows": []
+    "schema": {
+        "fields": []
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-bad/no-rows.json 
b/tests/phpunit/tabular-bad/no-rows.json
index 225ea2f..da6859a 100644
--- a/tests/phpunit/tabular-bad/no-rows.json
+++ b/tests/phpunit/tabular-bad/no-rows.json
@@ -1,5 +1,6 @@
 {
     "license": "CC0-1.0",
-    "types": ["string"],
-    "headers": ["col1"]
+    "schema": {
+        "fields": []
+    }
 }
diff --git a/tests/phpunit/tabular-bad/no-schema.json 
b/tests/phpunit/tabular-bad/no-schema.json
new file mode 100644
index 0000000..231524e
--- /dev/null
+++ b/tests/phpunit/tabular-bad/no-schema.json
@@ -0,0 +1,4 @@
+{
+    "license": "CC0-1.0",
+    "data": []
+}
diff --git a/tests/phpunit/tabular-bad/no-types.json 
b/tests/phpunit/tabular-bad/no-types.json
deleted file mode 100644
index 054521c..0000000
--- a/tests/phpunit/tabular-bad/no-types.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-    "license": "CC0-1.0",
-    "headers": ["col1"],
-    "rows": []
-}
diff --git a/tests/phpunit/tabular-bad/row-count-mismatch.json 
b/tests/phpunit/tabular-bad/row-count-mismatch.json
index a8aea34..e4d278b 100644
--- a/tests/phpunit/tabular-bad/row-count-mismatch.json
+++ b/tests/phpunit/tabular-bad/row-count-mismatch.json
@@ -1,8 +1,14 @@
 {
     "license": "CC0-1.0",
-    "headers": ["col1"],
-    "types": ["string"],
-    "rows": [
-       []
+    "schema": {
+        "fields": [
+            {
+                "name": "col1",
+                "type": "string"
+            }
+        ]
+    },
+    "data": [
+        []
     ]
 }
diff --git a/tests/phpunit/tabular-bad/row-vals-count.json 
b/tests/phpunit/tabular-bad/row-vals-count.json
index 56b19ac..e882a1e 100644
--- a/tests/phpunit/tabular-bad/row-vals-count.json
+++ b/tests/phpunit/tabular-bad/row-vals-count.json
@@ -1,6 +1,12 @@
 {
     "license": "CC0-1.0",
-    "headers": ["col1"],
-    "types": ["string"],
-    "rows": [["a","b"]]
+    "schema": {
+        "fields": [
+            {
+                "name": "col1",
+                "type": "string"
+            }
+        ]
+    },
+    "data": [["a","b"]]
 }
diff --git a/tests/phpunit/tabular-bad/type-mismatch.json 
b/tests/phpunit/tabular-bad/type-mismatch.json
index ec2e1af..8b62c51 100644
--- a/tests/phpunit/tabular-bad/type-mismatch.json
+++ b/tests/phpunit/tabular-bad/type-mismatch.json
@@ -1,6 +1,12 @@
 {
     "license": "CC0-1.0",
-    "headers": ["col1"],
-    "types": ["string"],
-    "rows": [[10]]
+    "schema": {
+        "fields": [
+            {
+                "name": "col1",
+                "type": "string"
+            }
+        ]
+    },
+    "data": [[10]]
 }
diff --git a/tests/phpunit/tabular-bad/types-headers-count.json 
b/tests/phpunit/tabular-bad/types-headers-count.json
deleted file mode 100644
index 301ff28..0000000
--- a/tests/phpunit/tabular-bad/types-headers-count.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
-    "license": "CC0-1.0",
-    "headers": ["col1"],
-    "types": ["string","boolean"],
-    "rows": []
-}
diff --git a/tests/phpunit/tabular-bad/unknown-license.json 
b/tests/phpunit/tabular-bad/unknown-license.json
index 466b421..a6073b9 100644
--- a/tests/phpunit/tabular-bad/unknown-license.json
+++ b/tests/phpunit/tabular-bad/unknown-license.json
@@ -1,6 +1,7 @@
 {
     "license": "aaaaaaaaa",
-    "headers": ["col1"],
-    "types": ["string"],
-    "rows": []
+    "schema": {
+        "fields": []
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-bad/unknown-type.json 
b/tests/phpunit/tabular-bad/unknown-type.json
index 2e386cd..93efd8e 100644
--- a/tests/phpunit/tabular-bad/unknown-type.json
+++ b/tests/phpunit/tabular-bad/unknown-type.json
@@ -1,6 +1,12 @@
 {
     "license": "CC0-1.0",
-    "headers": ["col1"],
-    "types": ["foo"],
-    "rows": []
+    "schema": {
+        "fields": [
+            {
+                "name": "col1",
+                "type": "foo"
+            }
+        ]
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-good/01.json 
b/tests/phpunit/tabular-good/01.json
index 2d3c8b6..853610f 100644
--- a/tests/phpunit/tabular-good/01.json
+++ b/tests/phpunit/tabular-good/01.json
@@ -1,6 +1,12 @@
 {
     "license": "CC0-1.0",
-    "headers": ["col1"],
-    "types": ["string"],
-    "rows": []
+    "schema": {
+        "fields": [
+            {
+                "name": "col1",
+                "type": "string"
+            }
+        ]
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-good/02.json 
b/tests/phpunit/tabular-good/02.json
index 8aa5b4a..ce1cb66 100644
--- a/tests/phpunit/tabular-good/02.json
+++ b/tests/phpunit/tabular-good/02.json
@@ -1,8 +1,18 @@
 {
     "license": "CC0-1.0",
-    "info": {"en": "data info"},
-    "headers": ["col1"],
-    "types": ["string"],
-    "titles": [{"en": "column 1" }],
-    "rows": []
+    "description": {
+        "en": "data info"
+    },
+    "schema": {
+        "fields": [
+            {
+                "name": "col1",
+                "type": "string",
+                "title": {
+                    "en": "column 1"
+                }
+            }
+        ]
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-good/03.json 
b/tests/phpunit/tabular-good/03.json
index 7e5cf7b..d06323f 100644
--- a/tests/phpunit/tabular-good/03.json
+++ b/tests/phpunit/tabular-good/03.json
@@ -1,7 +1,15 @@
 {
     "license": "CC0-1.0",
-    "info": {"en": "data info"},
-    "headers": ["col1"],
-    "types": ["string"],
-    "rows": []
+    "description": {
+        "en": "data info"
+    },
+    "schema": {
+        "fields": [
+            {
+                "name": "col1",
+                "type": "string"
+            }
+        ]
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-good/04.json 
b/tests/phpunit/tabular-good/04.json
index 8aa5b4a..ce1cb66 100644
--- a/tests/phpunit/tabular-good/04.json
+++ b/tests/phpunit/tabular-good/04.json
@@ -1,8 +1,18 @@
 {
     "license": "CC0-1.0",
-    "info": {"en": "data info"},
-    "headers": ["col1"],
-    "types": ["string"],
-    "titles": [{"en": "column 1" }],
-    "rows": []
+    "description": {
+        "en": "data info"
+    },
+    "schema": {
+        "fields": [
+            {
+                "name": "col1",
+                "type": "string",
+                "title": {
+                    "en": "column 1"
+                }
+            }
+        ]
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-good/05.json 
b/tests/phpunit/tabular-good/05.json
index f4d592d..2a3f279 100644
--- a/tests/phpunit/tabular-good/05.json
+++ b/tests/phpunit/tabular-good/05.json
@@ -1,10 +1,23 @@
 {
     "license": "CC0-1.0",
-    "info": {"en": "data info", "fr": ""},
-    "headers": ["col1"],
-    "types": ["string"],
-    "titles": [{"en": "column 1" }],
-    "rows": [
-       ["val 1"]
+    "description": {
+        "en": "data info",
+        "fr": ""
+    },
+    "schema": {
+        "fields": [
+            {
+                "name": "col1",
+                "type": "string",
+                "title": {
+                    "en": "column 1"
+                }
+            }
+        ]
+    },
+    "data": [
+        [
+            "val 1"
+        ]
     ]
 }
diff --git a/tests/phpunit/tabular-good/06.json 
b/tests/phpunit/tabular-good/06.json
index 1dadfa0..9d8018c 100644
--- a/tests/phpunit/tabular-good/06.json
+++ b/tests/phpunit/tabular-good/06.json
@@ -1,9 +1,36 @@
 {
     "license": "CC0-1.0",
-    "info": {"en": "data info"},
-    "headers": ["_1", "col_2", "Col3", "__col4__"],
-    "types": ["string", "number", "boolean", "localized"],
-    "rows": [
-       ["a", 10.2, true, {"en": "foo"}]
+    "description": {
+        "en": "data info"
+    },
+    "schema": {
+        "fields": [
+            {
+                "name": "_1",
+                "type": "string"
+            },
+            {
+                "name": "col_2",
+                "type": "number"
+            },
+            {
+                "name": "Col3",
+                "type": "boolean"
+            },
+            {
+                "name": "__col4__",
+                "type": "localized"
+            }
+        ]
+    },
+    "data": [
+        [
+            "a",
+            10.2,
+            true,
+            {
+                "en": "foo"
+            }
+        ]
     ]
 }
diff --git a/tests/phpunit/tabular-good/07.json 
b/tests/phpunit/tabular-good/07.json
index c1a2b50..2d97157 100644
--- a/tests/phpunit/tabular-good/07.json
+++ b/tests/phpunit/tabular-good/07.json
@@ -1,6 +1,7 @@
 {
     "license": "CC0-1.0",
-    "headers": [],
-    "types": [],
-    "rows": []
+    "schema": {
+        "fields": []
+    },
+    "data": []
 }
diff --git a/tests/phpunit/tabular-good/08.json 
b/tests/phpunit/tabular-good/08.json
index 82dff5b..0b244b9 100644
--- a/tests/phpunit/tabular-good/08.json
+++ b/tests/phpunit/tabular-good/08.json
@@ -1,7 +1,8 @@
 {
     "sources": "Something [http://example.com with a link]",
     "license": "CC0-1.0",
-    "headers": [],
-    "types": [],
-    "rows": []
+    "schema": {
+        "fields": []
+    },
+    "data": []
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/324860
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2dc08940cf9e314d5d822dce8c7cb97052aee99b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/JsonConfig
Gerrit-Branch: master
Gerrit-Owner: Yurik <yu...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to