Skip to content

Cache breaks in 0.12 #56

@mauricius

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.

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