mapbox/mapbox-gl-style-spec — pull request #40 by yhahn (2014-06-15 04:16:19+00:00)
Title: Spec schema v2

Adds schema "validation" tests and gets both raw and v2 passing the schema validation.

@kkaefer after having to review v2 through the eyes of a schema reader/validator a few notes:

- `"type": "constant"` for enum options was confusing to me. At first it sounded like it was related to `constants` which it is not (or not any more than any other type). Proposal: `constant => enum` or stick with `type: [ , ]`.
- `"type": "function_value"` is more 'schema generic' but makes the spec harder to read and use as documentation. I prefer the previous format, though it requires more hardcoding by code using the schema:

// raw
"type": "boolean",
"function": true

// v2
"type": "function_value"

if I then go look up `function_value` in the spec, I see it can be one of `[number, boolean, function]`. Not what I wanted to know.

In general I am somewhat skeptical of the amount of indirection and reference hopping in the v2 schema. For users of the schema JSON (documentation, validators, etc.) this is a lot to swallow. I'd rather "render" and "class" were not arrays of references but just inlined definitions in the main array.

Other renames/adjustments we'll want to consistify between raw + v2 schemas:

- [ ] enums in raw are represented by `"type": ["bevel", "miter", "round"]`. I need to see if it's as easy to validate stylesheets using the `type:constant/values` combo that v2 is using now.
- [ ] `default-value` became `default`. We need to consistify this, I don't care which direction we go in but it will require work in mapbox-gl-js to switch.