registration: Validate AutoloadNamespaces keys have trailing \
authorKunal Mehta <legoktm@member.fsf.org>
Sun, 20 May 2018 19:13:05 +0000 (12:13 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Sun, 20 May 2018 19:13:05 +0000 (12:13 -0700)
The PSR-4 autoloader requires "AutoloadNamespaces" keys to have a
trailing \ (\\ in JSON), so add a validation check for that.

Unfortunately the validation error isn't great, since it checks to see
if the property matches patternProperties, and when it doesn't, it
claims the property isn't defined since additionalProperties is false.
But it's still better than not failing when they are missing.

Bug: T189136
Change-Id: If01bd06cdd767fb704a8ff85cdf1c143e53fa4ca

docs/extension.schema.v1.json
docs/extension.schema.v2.json

index 0763e7d..bcfd2aa 100644 (file)
                },
                "AutoloadNamespaces": {
                        "type": "object",
-                       "description": "Mapping of PSR-4 compliant namespace to directory for autoloading"
+                       "description": "Mapping of PSR-4 compliant namespace to directory for autoloading",
+                       "patternProperties": {
+                               "^[A-Za-z0-9\\\\]+\\\\$": {
+                                       "type": "string"
+                               }
+                       },
+                       "additionalProperties": false
                },
                "AutoloadClasses": {
                        "type": "object"
index e13129b..31edbd0 100644 (file)
                },
                "AutoloadNamespaces": {
                        "type": "object",
-                       "description": "Mapping of PSR-4 compliant namespace to directory for autoloading"
+                       "description": "Mapping of PSR-4 compliant namespace to directory for autoloading",
+                       "patternProperties": {
+                               "^[A-Za-z0-9\\\\]+\\\\$": {
+                                       "type": "string"
+                               }
+                       },
+                       "additionalProperties": false
                },
                "AutoloadClasses": {
                        "type": "object"