apimastery / APISimulator

API Simulator - configuration-driven tool for modeling and running of API simulations
https://apisimulator.io
3 stars 1 forks source link

add multiple result from csv or sql parameter #25

Closed enigmatiqk closed 2 months ago

enigmatiqk commented 3 months ago

hi,

if i use csv or sql parameter, only one line can be returned and it's return null if more than one line must be returned

i can write a body like that :

{ 
elementOne-name: "blabla"
}

but can"t write a body like that :

[{ 
elementOne-name: "blabla"
},{ 
elementTwo-name: "blibli"
}]

i would like have this propertie in simlet configuration : "multiline" or "oneResult" or "onlyOneResult" or anything else ... with value true/false

if i activate this propertie i could parse like file parameter as in your com : https://github.com/apimastery/APISimulator/issues/17#issuecomment-1086445017

in this com, the solution works when i have a file but don't work with a sql datasource ...

thanks

apisim commented 3 months ago

Hi @enigmatiqk,

Let me make sure I understand the question: You would like to use parameters retrieved from a relational database via a SQL statement, where the SQL may return more than one row, and be able to iterate over the rows in the result and use their values to build the body of the response?

enigmatiqk commented 3 months ago

Hi @enigmatiqk,

Let me make sure I understand the question: You would like to use parameters retrieved from a relational database via a SQL statement, where the SQL may return more than one row, and be able to iterate over the rows in the result and use their values to build the body of the response?

Hi @apisim , i confirm

and if it can be done for sql parameter, i hope you can do the same from csv parameter

apisim commented 2 months ago

API Simulator v1.12 now allows Parameter from SQL Data Store and Parameter from CSV Data Sources to return more than one element, if query returns more than one row. Check out the new pick: first | all configuration.

Thanks!