How do I simulate a key / value for which the key is not known in Swagger

I have a simple JSON object that can contain key / values ​​for which exact values ​​are not known in advance. They depend on some server-side process. How do I simulate this in Swagger?

An example of JSON would be:

... 
,message: "invalid length. Must be in between {min} and {max}" 
,attributes: {
  min: 0
  ,max: 6
}
...

Another example:

... 
,message: "You must fill out this field as well because {field} has a value" 
,attributes: {
  field: "age"
}
...
+5
source share
1 answer

The following solution will only work with Swagger 2.0.

Define the model as described below:

{
    "type": "object",
    "properties": {
        "message": {
            "type": "string"
        },
        "attributes": {
            "type": "object",
            "additionalProperties": {}
        }
    }
}

It describes it attributesas a property map, where the value can be anything (a string, number, array, or even an object).

+7
source

All Articles