devtools-protocol
devtools-protocol copied to clipboard
Consider adding "default" field to JSON schema property definitions.
When parsing json/browser_protocol.json to generate API libraries, a strategy for interpreting absent properties and parameters with non-zero defaults cannot be reasonably developed as default values are only specified, somewhat inconsistently, in the description.
For instance:
{
"domains": [
{
"domain": "CSS",
"types": [
{
"id": "CSSProperty",
"description": "CSS property declaration data.",
"type": "object",
"properties": [
{
"name": "parsedOk",
"description": "Whether the property is understood by the browser (implies `true` if absent).",
"optional": true,
"type": "boolean"
}
]
}
]
}
]
}
"parsedOk" is only ever returned when false; and as the zero value for boolean is also false, in statically typed languages like Go at least; the value is always false. If the default value for properties such as this where available in the JSON schema document, we could generate correct API libraries by parsing the schema alone.