Skip to content

Commit

Permalink
implemented path parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
romalytvynenko committed Feb 11, 2025
1 parent 8a0036e commit 5539201
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/Attributes/ParameterAnnotationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Dedoc\Scramble\Attributes\Example;
use Dedoc\Scramble\Attributes\HeaderParameter;
use Dedoc\Scramble\Attributes\Parameter;
use Dedoc\Scramble\Attributes\PathParameter;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;

Expand All @@ -27,6 +28,26 @@ class ParameterController_ParameterAnnotationsTest
public function __invoke() {}
}

it('supports path parameters attributes', function () {
$openApi = generateForRoute(fn (Router $r) => $r->get('api/test/{testId}', ParameterController_PathParameterTest::class));

expect($openApi['paths']['/test/{testId}']['get']['parameters'][0])
->toBe([
'name' => 'testId',
'in' => 'path',
'required' => true,
'description' => 'Nice test ID',
'schema' => [
'type' => 'string',
],
]);
});
class ParameterController_PathParameterTest
{
#[PathParameter('testId', 'Nice test ID')]
public function __invoke(string $testId) {}
}

it('supports simple example for Parameter annotations', function () {
$openApi = generateForRoute(fn (Router $r) => $r->get('api/test', ParameterSimpleExampleController_ParameterAnnotationsTest::class));

Expand Down

0 comments on commit 5539201

Please sign in to comment.