1) All references in schemas of source Swagger documents will be present in the JSON Schema found inside a parse result. This can compact the size of large schemas which have duplicate references as they will no longer be flattened.
2) We now work on the non-dereferenced tree if possible for converting the schema to JSON Schema which means we can prevent redundant conversions by converting all of the definitions upfront and caching the result for future use.
With one of my large test documents, I am seeing significant parse time improvements with this changeset, in particular the second commit which adds caching of the converted definitions. Previously for each time the same referenced definition was used, we would be converting it to JSON Schema. This can add up and cause a lot of redundant work to be done.
I parsed the same large document 4 times over both this branch and master and here are the timing results:
this branch: 4s 951ms, 5s 33ms, 4s 862ms, 5s 201ms
master: 20s 970ms, 22s 567ms, DNF (JavaScript heap out of memory), 21s 141ms
The DNF was likely caused by JSON Schema Faker producing a a collection of extremely large JSON bodies hitting the memory limits.
This pull request achieves a couple of things:
1) All references in schemas of source Swagger documents will be present in the JSON Schema found inside a parse result. This can compact the size of large schemas which have duplicate references as they will no longer be flattened. 2) We now work on the non-dereferenced tree if possible for converting the schema to JSON Schema which means we can prevent redundant conversions by converting all of the definitions upfront and caching the result for future use.
With one of my large test documents, I am seeing significant parse time improvements with this changeset, in particular the second commit which adds caching of the converted definitions. Previously for each time the same referenced definition was used, we would be converting it to JSON Schema. This can add up and cause a lot of redundant work to be done.
I parsed the same large document 4 times over both this branch and master and here are the timing results:
The DNF was likely caused by JSON Schema Faker producing a a collection of extremely large JSON bodies hitting the memory limits.
Counterpart PR: https://github.com/apiaryio/swagger-zoo/pull/71