Fixed issue where collection generation took very large time. #735
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR fixes issue where certain definition were taking very large amount of time to generate collection. Specifically this was happening when
parametersResolution
option is set toSchema
. When set toSchema
conversion was taking >4 mins or so, meanwhile usingexample
only took ~4 sec to convert.RCA
Upon further debugging, I found out that all time taken was by
json-schema-faker
library. And also, that too when corresponding schema that was being faked containeduniqueItems: true
constraint.When
uniqueItems
set to true,json-schema-faker
library goes through faked data and tries to compare all items in array and only adds unique items to array. And in cases of very large and complex arrays, this process of comparison takes large amount of times especially whenSchema
as value to the optionparametersResolution
is used because essentially all items in array would be same and this comparison has to go through all data in the array.As for
Example
value this process doesn't take long because at very starting of any array, some value will be unique due to random faked data. So process doesn't go through all elements of item.Fix
We'll be not going through the process of determining all items to be unique in case when
parametersResolution
is set toSchema
.