Open heldersepu opened 6 years ago
I think the best approach for this is to add a depth
option to the subtree resolver, which would limit how many levels of $refs are resolved.
For example, depth: 1
would prevent resolution of any data that was placed as a result of an earlier resolution cycle.
This will be challenging: Swagger-Client will need some reworking in order to keep up with depth (we can't encode that metadata into the definition as we go, since that data may be used as base data for a later call to the resolver), and Swagger-UI will need to be able to tell when a subtree needs further resolution (currently it just checks to see if data for a given path exists at all).
how to set content type in swagger?
Profiling the expanding action:
Rendering the whole model property tree takes half of the time; and converting the model tree to an immutable map takes the other half.
Profiling the folding action:
It's worth mentioning that, lazy loading model properties should only delay the performance degradation, because the more properties loaded the less it could be efficient and fluent.
Storing the spec with a plain json object in the state can avoid the conversion; but is error-prone without enforcing a code convention and code review. And it also requires a lot of changes to the existing code.
Is it possible to delay the subtree resolving process to the render function? Other than lazy loading, delay resolving also improves the performance. Resolving includes:
There's no need to load/resolve/render unless necessary.
I've also noticed that unnecessary re-rendering happens.
But I'm not sure how much it is slowing down.
We have similar problem, where many of our models have more properties and each property and it sub properties takes lot of time to expand and browser hangs some time to load its properties. It would be helpful if we have a lazy load option for the properties. may be by setting some depth option. Thanks in advance.
Demonstration API definition
petstore.swagger.io/...&url=https://heldersepu.github.io/hs-scripts/swagger/4248_swagger.json
Expected Behavior
Fast expansion of model properties
Current Behavior
Very slow expansion of model properties
Possible Solution
Lazy load model properties like we do the models
Context
Looking at the current implementation, the collapsed models show right away (big thanks 2 @shockey)
Expanding small models is quick, but the largest models (such as
Patrimonio
) takes quite a while, once it fully expands, expanding child models takes no time... I believe that is because we are loading the entire tree of the model.