Giter Site home page Giter Site logo

dekaulitz / mockyup Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 2.0 25.22 MB

Mockup Server Request

License: MIT License

HTML 0.12% Dockerfile 0.14% Java 55.27% JavaScript 0.80% Vue 28.67% SCSS 1.56% TypeScript 13.42% Shell 0.01%
mockup api apidocs swagger mockup-contract mockup-server swagger-documentation swagger-ui swagger-spec hacktoberfest2022

mockyup's Introduction

dekaulitz

Simplify The Integration as Fast as You can

MockyUp

MockyUp is an Openapi mock server that allow You to centralize the Openapi collections that can consuming You're Openapi spec and generating the mock as You want by You're own definitions. We are using OpenApi Spesification version 3.x.x and bundled with Swagger UI
For now we only supporting json request and xml request.

Stacks

MockyUp build with SpringBoot and Swagger library and backed with mongodb as database and UI with vue js. For UI referencing you can check Mockup UI Repository. We are creating new extension parameter on OpenApi spec for generating the mock response in this case we adding x-examples properties for set the mock.

Requirements

  • MongoDb 4.x.x.
  • Java at least 1.8.x.
  • Docker (optional).

Features

Yes You can of course You can :

  • You can mock the response base on Path parameter.
  • You can mock the response base on Body request parameter.
  • You can mock the response base on Header request parameter.
  • You can mock the response base on Query string parameter.
  • You can defining the HttpCode response.
  • You can defining the Header properties.

In this case You have full control for the response as You want with You're own definitions base on criterias that You want to mock, and You can create mock user story base on the user properties or request properties that You want to try. This will helping You to try perfect integration before the real integration before You're application ready.

How to use

You can refer the example of OpenApi spec that already including the x-examples properties from here or for more context you can check the documentation about OpenApi here. When the MockyUp running will checks the default account root if account root its not exist will create the new one with password root * youre should change later.

We adding new extension for set mock configuration. They are:

  • x-query-including, it will matching the query string request.
  • x-header-including, it will matching the header request.
  • x-path-including, it will matching the path parameter request
  • x-default, if you defined the x-default if above criterias does'nt matched it will rendering the response by default response.

Since we are supporting multiple media type please make sure you are using the correct accept header. If you are not using the correct value for media type negotiation it can be causing some conflict from response.

x-query-including,x-header-including,x-body-including and x-path-including configurations

         [{
              "property": {
                "name": "client-id",// this is the field property 
                "value": "empty" // this is the field value 
              },
              "response": {
                "httpCode": 200, //http code
                // you can add mock header response
                "headers": {
                  "x-request-id": "this is from mock", //header response added by mock
                },
                // if you want to mock the response body base on media type
                "content": {
                  "application/json": {
                    "response":{
                      // you can mock the response directly
                      "value": "something" 
                    }
                  },
                  "application/xml": {
                    // you can mock the response by the reference
                    "$ref": "#/components/examples/LIST_OF_BOOKS_EMPTY_XML"
                  }
                },
                // if you want add the response body direclty without media type
                "response":{
                  "value": "something"
               }
                // if you want to add the response body by the reference without media type
                "$ref": "#/components/examples/LIST_OF_BOOKS_EMPTY"
              }
            }]

You should defined the configuration if you want to mocking the response base on path parameter,query parameter, header parameter and body request like above. if the property matched with request properties will rendering the response as the response request.

x-default configuration

         {
              "response": {
                "httpCode": 200,//http code
                // you can add mock header response
                "headers": {
                  "x-request-id": "this is from mock",//header response added by mock
                },
                 // if you want to mock the response body base on media type
                "content": {
                  "application/json": {
                    "$ref": "#/components/examples/LIST_OF_BOOKS_EMPTY"
                  },
                  "application/xml": {
                     // you can mock the response by the reference
                    "$ref": "#/components/examples/LIST_OF_BOOKS_EMPTY_XML"
                  }
                },
                // if you want add the response body direclty without media type
                "response":"#/components/examples/LIST_OF_BOOKS_EMPTY"
                 // if you want to add the response body by the reference without media type
                "$ref": "#/components/examples/LIST_OF_BOOKS_EMPTY"
              }
            }

This x-default configuration when the request is not matched with other configuration x-default will rendering the responsse.

How to integrate

MockyUp will running as mock server and mock collection server. MockyUp will check You can directly hit the MockypUp mocking endpoint for test mocking the response.

http://[mockyup_hostname]/mocks/mocking/[mock_id]?path=[contract_endpoint]

Or do test via swagger

http://[mockyup_hostname]/swagger/[mock_id]

Before that you should add new server env on youre spec.

    ...
    "servers":[
        {
              "url": "http://{host}/mocks/mocking/{mock_id}?path=",
              "description": "Testing locally",
              "variables": {
                "host": {
                  "default": "localhost:7070"
                },
                "mock_id": {
                  "description": "mock id from database"
                }
              }
            }
    ...
     ]

You can check the example configuration spec from here

Troubleshoot

  1. If you are facing unexpected response result please make sure you are using expected accept header

Supported

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.