subeeshcbabu-zz / swagmock

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

stringMock doesn't limit maxLength #59

Open achinmay opened 5 years ago

achinmay commented 5 years ago

If any of the parameter or object properties of type string has maxLength = 2GB, mock will try to create a large string. There should be a limit on the size of the string being generated. For example:

"account_note": { "type": "string", "maxLength": 2147483647, "example": "" }

SwagMock will try to call Chance.string({ length:2147483647, alpha:true }) which results in a very large alpha string getting created. I provided a workaround by adding following patch:

174a175,179 > if(maxLength > 4096) > { > maxLength = 4096; > }