Skip to content

Cache breaks in 0.12 #56

Closed
Closed

Description

@mauricius

Package version
^0.12 (it works with 0.11)

Describe the bug
Caching does not work anymore. It fails with the following error:

InvalidArgumentException: Either provide cache key manually or use instance of League\OpenAPIValidation\PSR7\CacheableSchemaFactory

I'm using this code in a Laravel application

ValidatorBuilder::fromYamlFile(
  base_path($attribute->path)
)->setCache(Cache::store('array'));

I believe the issue is caused by these two lines v0.11...v0.12#diff-1f85b5959abc5be7145c8b5b7b5b6ac6890e8c2e3b7d4184052cf7b65d249136R113-R114.

In 0.11 the implementation of the ValidatorBuilder factory is an instance of YamlFileFactory, which implements the CacheableSchemaFactory. However in 0.12 the implementation is a PrecreatedSchemaFactory, which obviously doesn't implement the CacheableSchemaFactory.

To Reproduce
Steps to reproduce the behaviour:

  1. It should happen with any basic implementation (fromYamlFile, fromJsonFile), as long as it uses the cache.

Expected behaviour
The cache should not fail.

Additional context
The League\OpenAPIValidation\PSR7\ValidatorBuilder class has a overrideCacheKey method that could be used to fix this problem.

Activity

  1. osteel commented on Dec 2, 2025

    @osteel
    Owner

    Hi, thanks for the detailed report. That v0.12 update to support URLs is the gift that keeps on giving 🤦‍♂️

    There has to be a way to make it all work, but I'm not sure when I'll have time to look into it. Are you happy to keep on using v0.11 in the meantime?

    P.S.: Nice to see that some people actually use the caching feature! Wasn't sure that was the case

  2. mauricius commented on Dec 2, 2025

    @mauricius
    Author

    Are you happy to keep on using v0.11 in the meantime?

    Absolutely, don't worry about it. I was just randomly upgrading packages and I stumbled in this issue 😉

  3. osteel commented on Dec 2, 2025

    @osteel
    Owner

    Ok cool, I'll keep you posted!

  4. osteel commented on Dec 4, 2025

    @osteel
    Owner

    Should be fixed with #57 (v0.14) – let me know if any issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions