Local HTTP server made with C#/NancyFx that can store (providing JSON schema verification), modify and return sample mock information (models) specified by loaded RAML document.
Application accept one optional command line argument - path to configuration file in JSON format.
The ApiConfig.json
from startup folder will be loaded by default. Example configuration file is included in the application folder:
{
"MockUri": "http://localhost:52109",
"RAMLFilePath": "ApiDescr.raml",
"MongoConnectionString": "mongodb://localhost:27017",
"DataBaseName": "NancyRAMLMock"
}
MockUri
URI for the Mock service to listenRAMLFilePath
path to RAML file with API definitionMongoConnectionString
MongoDB server connection stringDataBaseName
MongoDB database name that will store JSON models received/modified during by this Mock
Application will start self-hosted NancyFx HTTP server listening for the incoming requests. Mock server can accept Post
, Get
, Put
and Delete
HTTP request defined in loaded RAML specification under following conditions:
- Request path (mixed with the URI received from the RAML spec.) is used as a database collection name basis. To be able to insert, request, modify or delete JSON models in the same collection request group must share similar path. I.e.:
- Post
http://localhost:52109/movies
- Get, Put or Delete
http://localhost:52109/movies/:id
- path is the same as of the Post but ends with one parameter. It's name (taken from RAML spec.) and value will be used to identify record in particular MongoDB collection.
- The
:id
parameter is not the same as_id
that MongoDB assigns to record automatically. It's actual name will be taken from the RAML resources and must comply with the one of the fields of the model because this parameter name and it's received value will be used to find and perform record manipulation. Even if multiple records share the similar field that was used as an id - only one record will me modified, deleted or returned per request.