Giter Club home page Giter Club logo

nancy.raml.mock's Introduction

Nancy.RAML.Mock

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.

Usage

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"
}
  1. MockUri URI for the Mock service to listen
  2. RAMLFilePath path to RAML file with API definition
  3. MongoConnectionString MongoDB server connection string
  4. DataBaseName MongoDB database name that will store JSON models received/modified during by this Mock

Details

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:

  1. 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.
  1. 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.