cebe / php-openapi

Read and write OpenAPI yaml/json files and make the content accessible in PHP objects.
MIT License
466 stars 88 forks source link

Improve resolving references, cache loaded files in current context #13

Closed cebe closed 3 years ago

cebe commented 5 years ago

To avoid multiple requests to the same file, loaded files can be cached in current context.

cebe commented 5 years ago

https://github.com/cebe/php-openapi/blob/4a4892dbee51d9578b72d6c42645b5e89473d252/src/spec/Reference.php#L107

coatesap commented 4 years ago

I have a feeling this lack of caching is the biggest performance burden when reading API files. As an experiment, I ran Speccy's resolve command over my API file first (which took ~1 sec). Using the resolved output from Speccy dropped the time of Reader::readFromYamlFile() down from 24 seconds to 10 seconds, which is fairly significant.