go-jsonschema icon indicating copy to clipboard operation
go-jsonschema copied to clipboard

Advise on "open enums"

Open codefromthecrypt opened this issue 4 years ago • 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?

codefromthecrypt avatar May 22 '21 06:05 codefromthecrypt

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: https://github.com/json-schema-org/json-schema-spec/issues/665

jdimeo avatar Aug 12 '21 19:08 jdimeo