diff --git a/src/Console/RoutesCommand.php b/src/Console/RoutesCommand.php index b5f0028..7384f7c 100644 --- a/src/Console/RoutesCommand.php +++ b/src/Console/RoutesCommand.php @@ -225,7 +225,7 @@ private function outputText(string $specName, array $specOps, array $undocumente $rows[] = [ $op['matched'] ? 'matched' : 'unimplemented', $op['method'], - $op['path'], + $op['resolved'], ]; } @@ -262,7 +262,7 @@ private function outputJson(string $specName, array $specOps, array $undocumente 'filters' => (object) $filters, 'spec_operations' => array_map(fn ($op) => [ 'method' => $op['method'], - 'path' => $op['path'], + 'path' => $op['resolved'], 'status' => $op['matched'] ? 'matched' : 'unimplemented', ], $specOps), 'undocumented_routes' => array_values(array_map(function (string $key) { diff --git a/tests/Console/RoutesCommandTest.php b/tests/Console/RoutesCommandTest.php index 0265236..7183d9d 100644 --- a/tests/Console/RoutesCommandTest.php +++ b/tests/Console/RoutesCommandTest.php @@ -286,6 +286,24 @@ public function test_prefix_filter_does_not_match_partial_path_segment(): void ->doesntExpectOutputToContain('/api/v20/other'); } + #[Test] + public function test_displayed_path_includes_configured_path_prefix(): void + { + config(['spectator.path_prefix' => 'api/v4']); + + Route::get('/api/v4/users', fn () => [])->name('users.index'); + + $this->artisan('spectator:routes', [ + '--spec' => 'Test.v1.yml', + '--prefix' => 'api/v4', + '--format' => 'json', + ]) + ->assertExitCode(0) + ->expectsOutputToContain('"status": "matched"') + ->expectsOutputToContain('"path": "/api/v4/users"') + ->doesntExpectOutputToContain('"path": "/users"'); + } + #[Test] public function test_middleware_filter_matches_parameterized_middleware(): void {