-
Notifications
You must be signed in to change notification settings - Fork 540
Description
Feature Description
When loading external $ref with swagger-parser, the ResolverCache stores only the read string but still deserialize the whole tree which is particuraly slow for big files.
Maybe the Resolver could also store the deserialized tree.
Use Case
We have a big project with 260+ openapi spec file.
We also have a big "dictionary" yaml file which define every field (primitive type mostly) of our application. (with currently more than 1100 fields)
So every spec file reference ($ref) to fields inside that "dictionary" (currently 3300+ ref to that file)
Everytime a ref is parsed by swagger-parser, it get the file contents (String) from the cache but still do the deserialization to JsonNode (see ResolverCache.java#L170)
Suggested Solution (optional)
A suggested solution would be to also (or only) cache the deserialized JsonNode tree.
I have cloned the repo and applied that suggestion and the result help a lot:
My application generate source with the openapi-generator-maven-plugin which use swagger-parsers-v3.
When i clean package the application without that fix, the total time (generation + other phases and plugin used for my build) is around 4m49s
With that fix, my application is now built in 58s.
I know that the time above is not focused on the swagger-parsers part alone, but it still a huge gap and benefice to enhance that cache.
I can contribute if needed with a PR.
Alternatives Considered
Additional Context
Checklist
- I have searched the existing issues to ensure this is not a duplicate.
- This feature would be useful to more than just my use case.
- I have provided enough detail for the maintainers to understand the scope of the request.