subeeshcbabu-zz / swagmock

Mock data generator for swagger api
MIT License
173 stars 38 forks source link

Mock data for definitions? #60

Open IoannisPetridis opened 4 years ago

IoannisPetridis commented 4 years ago

This is more of a question than an issue really. Let's say I have the following model defined in the definitions of my swagger.json file (among others):

"definitions": {
    "Rate": {
      "type": "object",
      "properties": {
        "fromId": {
          "type": "string"
        },
        "toId": {
          "type": "string"
        },
        "rate": {
          "type": "string"
        },
        "roundedRate": {
          "type": "string"
        },
        "hint": {
          "type": "string"
        }
      },
      "required": [
        "fromId",
        "toId",
        "rate"
      ]
    },
...
}

Is it possible to generate mock data for the definitions as well and not just for parameters, responses or requests as per your documentation? For example would it be able to generate the following for the "Rate" model above in some way:

{
'fromId': 'EUR',
'toId': 'USD',
'rate': '1.12'
'roundedRate': '1.10',
'hint': 'hint hint hint'
}
lubbo commented 2 years ago

Maybe using x-example and x-examples OpenApi feature?