Skip to content

Commit

Permalink
Merge pull request #30 from ensi-platform/task-108364
Browse files Browse the repository at this point in the history
#108364 fix request generating
  • Loading branch information
MsNatali authored Jul 3, 2023
2 parents e4f1ca6 + 20a5ca0 commit 2a5cdfc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Generators/BaseGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ private function formattedGlobalParams(): array
protected function getActualClassNameAndNamespace(?string $className, ?string $namespace): array
{
$parseClassName = explode('/', $className);
if (count($parseClassName) > 1) {

if (str_contains($namespace, '\Request')) {
$namespace = substr($namespace, 0, strpos($namespace, '\Request') + 8);
if (count($parseClassName) > 1) {
if (str_contains($namespace, '\Requests')) {
$namespace = substr($namespace, 0, strpos($namespace, '\Requests') + 9);
} elseif (str_contains($namespace, '\Resources')) {
$namespace = substr($namespace, 0, strpos($namespace, '\Resources') + 10);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/GenerateServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
$this->makeFilePath('/app/Http/Tests/ResourcesComponentTest.php'),
$this->makeFilePath('/app/Http/Requests/TestFooRenameRequest.php'),

$this->makeFilePath('/app/Http/Request/WithDirRequests/Request.php'),
$this->makeFilePath('/app/Http/Requests/WithDirRequests/Request.php'),
$this->makeFilePath('/app/Http/Requests/Foo/TestNamespaceWithDirRequest.php'),
$this->makeFilePath('/app/Http/Requests/LaravelValidationsApplicationJsonRequest.php'),
$this->makeFilePath('/app/Http/Requests/LaravelValidationsMultipartFormDataRequest.php'),
Expand Down Expand Up @@ -161,6 +161,7 @@
assertStringContainsString(
"use App\Http\Controllers\Controller11;\n".
"use App\Http\Controllers\Controller2;\n".
"use App\Http\Controllers\Foo\TestController;\n" .
"use App\Http\Controllers\FooItemsController;\n".
"use App\Http\Controllers\FoosController;\n",
$routes
Expand Down

0 comments on commit 2a5cdfc

Please sign in to comment.