json-schema-spec icon indicating copy to clipboard operation
json-schema-spec copied to clipboard

The value of the examples annotation should be an object or an array

Open K-Adam opened this issue 4 years ago • 9 comments

Json schema has examples annotation, which comes handy, when I would like to run a mock server for my api.

Unfortunately the spec states, that the value of examples keyword MUST be an array:

{
  "title" : "Match anything",
  "description" : "This is a schema that matches anything.",
  "default" : "Default value",
  "examples" : [
    "Anything",
    4035
  ]
}

I suggest to enable objects as well, so each example could be referenced by name:

{
  "title" : "Match anything",
  "description" : "This is a schema that matches anything.",
  "default" : "Default value",
  "examples" : {
    "stringValue": "Anything",
    "integerValue": 4035
  }
}

This change could make the construction of complex examples ( like a list ) much simpler.

K-Adam avatar Feb 08 '21 20:02 K-Adam