core icon indicating copy to clipboard operation
core copied to clipboard

Mapping paths should allow arbitrary files

Open nesl247 opened this issue 2 years ago • 0 comments

Description
The mapping paths configuration currently only supports directories. This means that it must search all files within the directory for api resources. However, when tests are located next to code (as is done in other languages), this means that tests are also searched for resources. This slows down the container building as there are more files to be searched, as well as invalidates cache whenever a test changes.

It would be great to be able to specify the individual files to be checked instead of the directories that contain them.

Example

    $paths = Finder::create()
        ->in(__DIR__ . '/../src')
        ->notName('/.*Test.php/')
        ->files();

    $apiPlatform
        ->mapping()
        ->paths(array_map(fn ($path) => $path->getRealPath(), iterator_to_array($paths)));

nesl247 avatar Dec 06 '23 17:12 nesl247