Skip to content

Mockpit: Create dynamic REST API mocks with JavaScript-based response generation. Extract path variables, query parameters, use references, and configure headers. Export, import, and search mocks.

License

Notifications You must be signed in to change notification settings

sranmanpreet/mockpit

Repository files navigation

Mockpit - Dynamic REST API Mock Server

Mockpit is a versatile and user-friendly REST API mock server that empowers developers to create and manage mock APIs effortlessly. With Mockpit, you can dynamically generate response bodies, leverage path variables and query parameters, and define custom response headers to simulate a wide range of API behaviors. Whether you're testing your frontend application, developing a new feature, or need a temporary API for your project, Mockpit has you covered.

Features

  • Dynamic Response Generation: Use JavaScript in ResponseBody evaluation to create dynamic response bodies based on path variables and query parameters.
  • Path Variables and Query Parameters: Mockpit automatically extracts path variables and query parameters from the request URL and makes them available for dynamic response generation.
  • Custom Response Headers: Configure response headers for your mock APIs, allowing you to simulate various scenarios.
  • Mock Search: Quickly locate your mock configurations using Mockpit's search functionality. This feature ensures that you can easily find and work with the mocks you need.
  • Export and Import Mocks: Seamlessly export and import mock configurations to and from Mockpit. Share your mock setups with colleagues and collaborators to ensure consistency across your team's development efforts.
  • Easy-to-Use Configuration: Mockpit's intuitive user interface lets you create, edit, and manage mock APIs effortlessly.
  • Fast and Lightweight: Mockpit is designed to be fast and lightweight, ensuring minimal impact on your development workflow.

Guides

Getting Started

Installation


Pre-requisites:

  • Java 11
  • Maven
  • Node 14.21
  • Angular 15
  • Postgres 15

Steps:

  1. Clone the Mockpit repository:

    git clone https://github.com/sranmanpreet/mockpit.git
    
  2. Install Server:

    cd mockpit/server
    mvn clean install
    
    java -jar target/mockpit-<version>-RELEASE.jar
    

    Server will be deployed on http://localhost:8080 by default. However, port can be changed from application configurations.

  3. Install Client:

    cd mockpit/client
    npm install
    npm start 
    

    Client will be deployed on http://localhost:4200 by default.

Installation using Docker

  • Install Mockpit
docker run -e "SPRING_DATASOURCE_URL=jdbc:postgresql://host.docker.internal:5432/mockpitdb" -e "SPRING_DATASOURCE_USERNAME=postgres" -e "SPRING_DATASOURCE_PASSWORD=postgres" -e "backendUrl=http://localhost:8080" -p 4200:80 -p 8080:8080 sranmanpreet/mockpit:<version>-RELEASE

It will run Mockpit client at http://localhost:4200 and Mockpit server at http://localhost:8080.

Separate images for Mockpit client and server are also available. Follow below steps to install client and server individually.

  • Install Server
docker run -e "SPRING_DATASOURCE_URL=jdbc:postgresql://host.docker.internal:5432/mockpitdb" -e "SPRING_DATASOURCE_USERNAME=postgres" -e "SPRING_DATASOURCE_PASSWORD=postgres" -p 8080:8080 mockpit-server:<version>-RELEASE
  • Install Client
docker run -p 4200:80 -e backendUrl=http://localhost:8080 sranmanpreet/mockpit-server:<version>-RELEASE

Mockpit will be accessible at http://localhost:4200

Installation using Docker Compose

  • Run following command at the root of the project
docker-compose -f docker-compose.yml up -d

Usage

  1. After installation with default configurations, access the Mockpit web interface by navigating to http://localhost:4200 in your web browser.

  2. Create and manage mock APIs using the user-friendly interface. Configure dynamic response bodies, path variables, query parameters, and custom response headers as needed.

Example

Here's a quick example of creating a mock API in Mockpit:

  1. Access the Mockpit web interface at http://localhost:4200. Homepage
  2. Click on "New Mock" to define a new mock API. New Mock New Mock Response
  3. Configure the URL pattern, dynamic response body using JavaScript, and custom response headers. Dynamic Mock
  4. Save the mock and start using it in your application. Dynamic Mock Response
  5. Manage mocks Manage Mocks

Collaboration

Mockpit welcomes collaboration from developers like you! If you'd like to contribute to the project, feel free to open an issue, submit a pull request, or provide feedback.

To contribute:

  1. Fork the Mockpit repository.
  2. Create a new branch for your changes.
  3. Make your changes and test thoroughly.
  4. Submit a pull request with a clear description of your changes.

License

Mockpit is released under the MIT License.


Mockpit empowers you to easily create, manage, and test mock APIs with dynamic response generation and custom headers. Start using Mockpit today to streamline your development and testing workflows!

GitHub Repository

Happy mocking! 🚀

About

Mockpit: Create dynamic REST API mocks with JavaScript-based response generation. Extract path variables, query parameters, use references, and configure headers. Export, import, and search mocks.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published