Ask a Question

Automate put body content based on OpenApi

SOLVED
LennSar
Contributor

Automate put body content based on OpenApi

Hi there,

 

I'm evaluating whether ReadyApi fullfills our needs to be our Rest api testing tool of choice. I realised that ReadyApi does a really good job on generating a simple body for a put request based on the schema in the OpenApi documentation. Realising this, I was wondering whether there is a possibility that it automatically runs the put command with randomized values for the objects in the body.

 

For example we have a put request which sets the current date and the body that ReadyApi generated from the OpenApi looks like this:

{
"year" : 2022,
"month" : 3,
"day" : 7
}

 

now it would be awesome if instead of entering numbers it could enter some sort of variable that could be randomized using the Data Source Loops or is that a step that I would have to do manually? Theoretically all the information for the allowed values would be in the OpenApi. 

 

Thanks,

 

Lennart

4 REPLIES 4
MConneely
Staff

Hi @LennSar ,

I hope I understand your question so this might help.
Have you looked at the Data Generator option in the DataSource test step? You could set up your properties, and generate randomized day, month and year.

MConneely_1-1646921180152.png

 

Then, in your body you can reference the properties from the DataSource

{
	"year" : ${Data Source#year},
	"month" : ${Data Source#month},
	"day" : ${Data Source#day}
}

  

Hi MConneely,

 

thanks for the hint. I previously did take a look at the data source feature and it definetelly is doing what I would expect at the end. What I would love to have though is that this data source and the body as you described it would be generated automatically based on the information given in the OpenApi documentation. But I guess ReadyApi isn't capable of doing that (yet) is it?

@LennSar
The ReadyAPI request will contain whatever Request Body example is defined in the OpenAPI spec. But as for generating a datasource from that, currently its not available.

Allright. Thanks for clarifying and showing how to do it manually! Much appreciate it.

cancel
Showing results for 
Search instead for 
Did you mean: