Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding "default" field to JSON schema property definitions. #288

Open
facefunk opened this issue Nov 23, 2022 · 0 comments
Open

Comments

@facefunk
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant