Skip to content

DeadpoolX7/mockforge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

MockForge

MockForge is a flexible mock data generation API that helps developers create realistic test data using Java Faker field paths.

It provides a simple REST endpoint to generate customized JSON data for development and testing purposes.

Features

  • Dynamic JSON data generation based on field paths
  • Support for nested object structures
  • Configurable number of mock objects
  • OpenAPI/Swagger documentation
  • Docker support
  • Simple REST API interface

Getting Started

Prerequisites

  • Java 17 or higher
  • Maven 3.6+
  • Docker (optional)

Running Locally

  1. Clone the repository:
git clone https://github.com/yourusername/mockforge.git
cd mockforge
  1. Build the project:
./mvnw clean install
  1. Run the application:
./mvnw spring-boot:run

The API will be available at http://localhost:8080/

Using Docker

  1. Build the Docker image:
docker build -t mockforge .
  1. Run the container:
docker run -p 8080:8080 mockforge

API Usage

Generate Mock Data

GET /mock?fields=name.firstName,address.city,phone.cellPhone&count=2

Parameters:

  • fields : Comma-separated list of Java Faker field paths
  • count (optional) : Number of Objects to generate (default : 1)

Example Response:

[
  {
    "name": {
      "firstName": "John"
    },
    "address": {
      "city": "New York"
    },
    "phone": {
      "cellPhone": "1-234-567-8900"
    }
  },
  {
    "name": {
      "firstName": "Jane"
    },
    "address": {
      "city": "Los Angeles"
    },
    "phone": {
      "cellPhone": "1-234-567-8901"
    }
  }
]

Available Field Paths

The API supports all field paths available in Java Faker. Some commonly used paths include:

  • name.firstName
  • name.lastName
  • address.streetAddress
  • address.city
  • address.country
  • internet.email
  • phone.cellPhone
  • company.name
  • commerce.price

For a complete list of available fields, visit the Java Faker Documentation

API Documentation

Access the OpenAPI/Swagger documentation at:

http://localhost:8080/swagger-ui.html

Deployment

The project includes a render.yml configuration for deployment on Render.

To deploy:

  • Fork this repository
  • Connect your fork to Render
  • Create a new Web Service using the repository

Contributing

  • Fork the repository
  • Create your feature branch (git checkout -b feature/AmazingFeature)
  • Commit your changes (git commit -m 'Add some AmazingFeature')
  • Push to the branch (git push origin feature/AmazingFeature)
  • Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

REST Api to serve dummy mock JSON data for development and testing purpose. Built using SpringBoot and Java Faker. Try playground on ๐Ÿ‘‡

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors