GithubHelp home page GithubHelp logo

ramveer93 / random-json-datagenerator Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 212 KB

it generates random data based on xpath passed by user

Java 100.00%
data-generator json-generator testing-data time-series-data spring-boot java microservice

random-json-datagenerator's Introduction

Random-Json-DataGenerator

A Spring-boot project to generate random json data which can be used to perform load test on an API which again calls an external API and it returns the data in JSON format.

Use case 1

If you want to perform load test on microservice which calls an external API, when external API is not able to handle load test or not allow to perform these tests or doesn't have handle to return n no of records, instead of calling it , you can configure microservice to call this spring-boot project which will returns the JSON data.

Use case 2

You can also generate JSON data of any size and any no of records in it.

Requirements

  • Java 8 or later
  • apache-maven-3.6.0 or later

Building project

Its an standard maven project , which you can open in eclipse or intellij IDE by importing pom.xml file. Once opened in IDE , just build the project using below maven command

mvn clean install

Usage

Once maven build is successfull , the application will run on default port of 8081. You can change it by changing the entry inside resources/application.properties as below

server.port=8081

Once it is done , you can start the application. From here you can either go to swagger documentation or use postman to hit the request. Below is the url for swagger documentation

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

This is how the swagger request looks like

Request explained

Request URL

http://<host>:<port>/v1/dataGenerator/generateData

Query parameters

There are 4 query parameters

  • recordCount : No of requested records of that particular json element
  • dataType : JSON, as of now just json support, later maybe for csv
  • randomValues : If you set it to true, the values of that particular json elements will be random, As of now, it generates just string and numbers random
  • xpath : path of that particular json element which you want to repeat

Request header

Content-Type : application/json
xpath : <path of the particular json element>

Request Body

JSON which you want to repeate no of times. Below is one of the example

{
  "array": [
    {
      "ii": true,
      "name": "rrrr",
      "try": [
        {
          "level": 2,
          "repeat": true,
          "again": [
            {
              "name": "ihh",
              "id": 1,
              "level3":[
                {
                  "name":"dds",
                  "class":"ssdsdsdssddsds"
                }
                
                
                ]
            }
          ],
          "josh": "high"
        }
      ],
      "id": 123
    }
  ]
}

In this JSON if you want to repeat > again element theb xpath will be array.try.again

Contributing

Please raise an issue if you find anything which is not working or want unimplemented functionality.

License

MIT

random-json-datagenerator's People

Contributors

ramveer93 avatar

Watchers

 avatar  avatar

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.