1 step: installation
via composer
composer require akiosarkiz/openpapi-attributes
1
2 step: use attributes
Write documentation for your code. For example, simple controller:
use OpenApiGenerator\Attributes\Info;
use OpenApiGenerator\Attributes\Property\Number;
use OpenApiGenerator\Attributes\Response;
use OpenApiGenerator\Attributes\Route\Get;
#[Info('Some title')] // must exists one attribute info in project
class SimpleController
{
#[
Get('users/{id}'),
Number('id'),
Response(200)
]
public function show(): void {
//
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
3 step: create script & run
Run script.
php ./vendor/bin/generate-openapi.php ./tests/Examples/Controller/ .
1