omissis/go-jsonschema

Advise on "open enums"

codefromthecrypt opened this issue · 1 comments

We have a part of our json schema which prescribes values based on what's supported now. ex.

        "os": {
          "title": "OS",
          "description": "OS is the supported operating system (runtime.GOOS)",
          "type": "string",
          "enum": [
            "darwin",
            "linux",
            "windows"
          ]
        },

However, if we added another value later, we would want old code to not fail. Right now enums are validated by default.. We still want to know what the constants should be... Any advise?

I think this is more a question for JSON schemas. I think the "right" way is to use a choice, either a "closed" enum or an open string for future values:
json-schema-org/json-schema-spec#665