Swagger Express Middleware

Swagger 2.0 middlware and mocks for Express.js

The FileDataStore class

This data store persists its data to JSON files, which means the data doesn’t go away when your app restarts, like it does with the MemoryDataStore. This allows you to easily create an API that acts like it has a real database behind it, so you can use the Mock middleware to create some data, and then use that data for a demos and presentations days or weeks later.

NOTE: The FileDataStore is not intended to replace a full-featured database. It does not provide features such as fault-tolerance, transactions, concurrency, etc. However, you can easily integrate with a full-featured database system (such as MySQL, SqlLite, Oracle, etc.) by creating your own class that inherits from the DataStore base class. You simply need to override the __openDataStore and __saveDataStore methods. See the FileDataStore source code for an example.

Constructor

FileDataStore(baseDir)

Methods

The FileDataStore class inherits from the DataStore class, so it has all the same methods for retrieving, saving, and deleting data.