apiaryio / fury-adapter-swagger

Swagger 2.0 parser adapter for Fury.js
MIT License
11 stars 12 forks source link

Handling Schema Referencing #215

Closed kylef closed 6 years ago

kylef commented 6 years ago

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