Ability to generate mock data
Right now, Swagger Express Middleware focuses on providing mock implementations rather than mock data, but there's no reason it couldn't do both. It already does a little bit of mock-data generation to set HTTP headers and to assign unique IDs when new resources are created, but ideally the DataStore class would have the ability to automatically populate itself fully with mock data based on the JSON Schemas defined in the Swagger API.
The current mock-data generation code is far too simplistic and will need to be enhanced.
Currently, it just generates random values based on the data type, min/max length, and min/max values specified in the JSON Schema. This should be enhanced to use a library such as Faker to generate more realistic mock data. This way, a property named "firstName" would have mock data like "John", "David", or "Sarah", rather than a random string like "a9d72jdk1jdhqjd187snd". We should also provide some mechanism for API authors to specify the type of data to generate, since we won't always be able to determine based on the property name.
Also, we need to enhance the code to support complex JSON schemas. Currently, it supports primitive types (string, number, date, etc.), arrays, and objects. But it doesn't support JSON schema values such as oneOf, anyOf, allOf, patternProperties, etc.
Just chiming in with a note that I ran into the lack of oneOf support in the mock middleware today with a Swagger spec from an Oracle API.
I may have time to work on this, but I'm not at all sure about that.
In my case, however, it turns out that every array type is actually just [<supported type>, "null"], so I can work around this limitation by replacing that with just the supported type before passing the schema to the mock middleware. :tada: