Closed renepardon closed 9 months ago
I'm not sure if this project is still being actively developed however for future reference this appears to be a bug in src/Traits/ApiResourceTrait.php where it doesn't honour the system path separator.
Something similar to the following is likely required - although this fixes the path separator the actual directory itself (being based on the namespace command) doubles up as app/App which doesn't seem correct.
The following "fixes" the issue but I suspect there is almost certainly another helper method i'm unaware of that should be used rather than these functions using getAppNamespace:
diff --git a/src/Traits/ApiResourceTrait.php b/src/Traits/ApiResourceTrait.php
index 286af78..86d6cc4 100644
--- a/src/Traits/ApiResourceTrait.php
+++ b/src/Traits/ApiResourceTrait.php
@@ -136,7 +136,9 @@ trait ApiResourceTrait
$path = Helpers::getAppNamespace(Config::getApiResourcePath(), $path, $this->option('api-version'));
- return Helpers::getPathWithSlash($path);
+ $path = preg_replace('/^(App\\\)/', '', $path);
+
+ return Helpers::getPathWithSlash(Helpers::fixPathSeparator($path));
}
/**
@@ -152,7 +154,11 @@ trait ApiResourceTrait
$path = Helpers::getPathWithSlash($path);
}
- return Helpers::getAppNamespace(Config::getApiResourceCollectionPath(), $path, $this->option('api-version'));
+ $path = Helpers::getAppNamespace(Config::getApiResourceCollectionPath(), $path, $this->option('api-version'));
+
+ $path = preg_replace('/^(App\\\)/', '', $path);
+
+ return Helpers::getPathWithSlash(Helpers::fixPathSeparator($path));
}
/**
@Orteko @renepardon this should be fixed in v3.0 which should be released soon
Environment:
Description:
Generated resources are invalid. The namespaces are not build correctly
Steps/Commands To Reproduce:
After this do a git status and you will receive something like this:
Content Of The Resource-File: