APIDevTools / swagger-cli

Swagger 2.0 and OpenAPI 3.0 command-line tool
https://apitools.dev/swagger-cli
MIT License
515 stars 69 forks source link

Validate taking a really long time - could be recursion related? #49

Open louisl opened 4 years ago

louisl commented 4 years ago

I have a User schema model that references itself with createdByUser/updatedByUser, and pretty much all models have createdByUser/updatedByUser. The validate function works but it's taking longer and longer (over an hour) the bigger my API is getting. I'm suspecting recursion to be the issue. I'm guessing there's a fixed limit to recursion as it doesn't go into an endless loop and eventually passes - where could I take a look at that code I'd like to make it an option variable if possible.

JamesMessinger commented 4 years ago

There's not a setting that controls the recursion depth. But certain recursive structures can result in a logarithmic explosion that takes forever to process. 😕

The problem is actually in the dereferencing step, but the current code requires dereferencing first before validation. I hope to eventually refactor the validation logic so it doesn't require prior dereferencing, which I believe will solve this problem (and others)

louisl commented 4 years ago

Thanks for the reply and explanation. I had a quick look at the code but I think I'd have to sink some time into it to get to grips with it so I don't think I really have time to help at the moment. I'm going to have to keep an eye on this for now.

louisl commented 2 years ago

I've had to reopen the job where I was having this issue to make some changes. I've updated from 2.3.4 to 4.0.4 and the validation time was really fast so I guess this was fixed at some point? If so I think we can close this issue.

mortifia commented 1 year ago

with this openapi spec it's take very long time (public scheme) https://docs.medusajs.com/api/store openapi doc https://docs.medusajs.com/redocusaurus/plugin-redoc-0.yaml