Skip to content

Commit b6aef2b

Browse files
committed
it works propably
1 parent 56a60eb commit b6aef2b

10 files changed

+359
-23
lines changed

README.md

+32-21
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
1-
# Skeleton #
1+
# Extended Api Doc Bundle #
22

3-
A minimal project that allows you to quickly create a new project based on `Symfony` using useful tools: `standard-version`, `php-cs-fixer`, `phpstan`, `phpunit`, `docker`, `xdebug` and my own `starting script`. It is ready to support debugging with **Visual Studio Code** - just look into .env.local ;).
3+
## Installation
44

5-
### WHY?
6-
Because personally, every time I start a new project, or a library for it, I have to do all this manually. For this, I made application skeletons for different uses: `cli`, `api`, `library`, and `bundle`, to speed up and standardize my own work. These skeletons uses this project.
7-
8-
### How to start
9-
10-
Create directory for your project, get in (`cd {Your directory}`) and run command:
11-
```sh
12-
composer create-project PBaszak/skeleton . --no-interaction
5+
```yaml
6+
# config/routes.yaml
7+
...
8+
extended_api_doc:
9+
resource: '@ExtendedApiDocBundle/Resources/routes/*'
1310
```
1411
15-
(Everytime) Start local environment using this command:
16-
```sh
17-
bash start.sh
12+
```yaml
13+
# config/packages/nelmio_api_doc.yaml
14+
parameters:
15+
app_title: '%env(APP_TITLE)%'
16+
app_description: '%env(APP_DESCRIPTION)%'
17+
app_version: '%env(APP_VERSION)%'
18+
app_commit_sha_short: '%env(APP_COMMIT_SHA_SHORT)%'
19+
20+
nelmio_api_doc:
21+
documentation:
22+
info:
23+
title: '%app_title%'
24+
description: '%app_description%'
25+
version: '%app_version% (%app_commit_sha_short%)'
26+
areas: # to filter documented areas
27+
path_patterns:
28+
- ^/api(?!/doc(.json|.yaml)?$)
1829
```
1930
20-
and remove `CHANGELOG.md` (because it's owned by skeleton project. Your project will be have generated `CHANGELOG.md` after first release):
31+
## Usage
32+
33+
## Development
34+
35+
### How to start
36+
37+
Start local environment using this command:
2138
```sh
22-
rm CHANGELOG.md
39+
bash start.sh
2340
```
24-
and voila! Your local environment is ready to development basic php app with useful tools.
2541

2642
### How to use **Standard Version**
2743

@@ -30,11 +46,6 @@ If You don't have node_modules directory run:
3046
npm install
3147
```
3248

33-
First release:
34-
```sh
35-
npm run version:first-release
36-
```
37-
3849
`Major`, `Minor`, `Patch` version update:
3950
```sh
4051
npm run version:major

composer.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"phpstan/phpdoc-parser": "*",
3939
"phpstan/phpstan": "*",
4040
"phpstan/phpstan-symfony": "*",
41-
"phpunit/phpunit": "*"
41+
"phpunit/phpunit": "*",
42+
"symfony/browser-kit": "^6"
4243
},
4344
"config": {
4445
"allow-plugins": {
@@ -86,6 +87,7 @@
8687
"@code:analyse",
8788
"@phpunit"
8889
],
90+
"test:e2e": "@phpunit --group e2e tests",
8991
"test:unit": "@phpunit --group unit tests"
9092
},
9193
"conflict": {

composer.lock

+203-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/bundles.php

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
66
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
77
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['all' => true],
8+
PBaszak\ExtendedApiDoc\ExtendedApiDocBundle::class => ['all' => true],
89
];

config/packages/nelmio_api_doc.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
nelmio_api_doc:
2+
documentation:
3+
info:
4+
title: Title
5+
description: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
6+
version: '1.0.0'
7+
areas: # to filter documented areas
8+
path_patterns:
9+
- ^/api(?!/doc(.json|.yaml)?$)

config/routes.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
controllers:
2+
resource: ../tests/Assets/
3+
type: attribute
4+
extended_api_doc:
5+
resource: '@ExtendedApiDocBundle/Resources/routes/*'

tests/Assets/.gitignore

Whitespace-only changes.

tests/Assets/Status.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PBaszak\ExtendedApiDoc\Tests\Assets;
6+
7+
use OpenApi\Attributes as OA;
8+
9+
class Status
10+
{
11+
public function __construct(
12+
#[OA\Property(type: 'string', example: 'ok')]
13+
public readonly string $status = 'ok',
14+
) {
15+
}
16+
}

tests/Assets/TestController.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PBaszak\ExtendedApiDoc\Tests\Assets;
6+
7+
use Nelmio\ApiDocBundle\Annotation\Model;
8+
use OpenApi\Attributes as OA;
9+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
10+
use Symfony\Component\HttpFoundation\Response;
11+
use Symfony\Component\Routing\Annotation\Route;
12+
13+
class TestController extends AbstractController
14+
{
15+
/**
16+
* Return the status of the API.
17+
*/
18+
#[OA\Tag(name: 'Status')]
19+
#[OA\Response(
20+
response: 200,
21+
description: 'Status of the API.',
22+
content: new OA\JsonContent(
23+
ref: new Model(
24+
type: Status::class,
25+
)
26+
)
27+
)]
28+
#[Route('/api/status', name: 'api_status', methods: ['GET'])]
29+
public function __invoke(): Response
30+
{
31+
return $this->json(new Status());
32+
}
33+
}

0 commit comments

Comments
 (0)