Skip to content

Commit 8fcb307

Browse files
committed
code challenge 10 solution
1 parent 86962ef commit 8fcb307

34 files changed

+1250
-38
lines changed

.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ DATABASE_URL=sqlite:///%kernel.project_dir%/var/data.db
2626
# DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7"
2727
# DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
2828
###< doctrine/doctrine-bundle ###
29+
30+
###> lexik/jwt-authentication-bundle ###
31+
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
32+
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
33+
JWT_PASSPHRASE=959f7ce3e550955002bc425bc1964894
34+
###< lexik/jwt-authentication-bundle ###

.github/workflows/checks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
${{ runner.os }}-php-
2929
- name: Install Dependencies
3030
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
31+
- name: Generate KeyPair
32+
run: php bin/console lexik:jwt:generate-keypair
3133
- name: cs-check
3234
run: make cs-check
3335
- name: tests

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@
2424
/phpunit.xml
2525
.phpunit.result.cache
2626
###< phpunit/phpunit ###
27+
28+
###> lexik/jwt-authentication-bundle ###
29+
/config/jwt/*.pem
30+
###< lexik/jwt-authentication-bundle ###

CODING-CHALLENGE-11.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# RESTful Webservices in Symfony
2+
3+
## Coding Challenge 11 - API Documentation
4+
5+
### Tasks
6+
7+
Let's document our API using the Nelmio API doc bundle.
8+
9+
### Solution
10+
11+
- require Nelmio's ApiDocBundle: `composer req nelmio/api-doc-bundle`
12+
- adjust the bundle's configuration:
13+
14+
```yaml
15+
nelmio_api_doc:
16+
documentation:
17+
info:
18+
title: RESTful Webservices in Symfony
19+
description: "SymfonyWorld Online Winter Edition Workshop: RESTful Webservices in Symfony!"
20+
version: 1.0.0
21+
areas:
22+
path_patterns:
23+
- ^/api(?!/doc$) # Accepts routes under /api except /api/doc
24+
- ^/workshops
25+
- ^/attendees
26+
```
27+
28+
- add some annotation to your controllers, check https://github.com/zircote/swagger-php/tree/master/Examples for examples
29+
- to be able to see the api documentation website, you need to install Twig and the Asset component:
30+
`composer require twig asset` and adjust the routing configuration for the `nelmio/api-doc-bundle` in
31+
`config/routes/nelmio_api_doc.yaml`

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"doctrine/doctrine-bundle": "^2.5",
1313
"doctrine/doctrine-migrations-bundle": "^3.2",
1414
"doctrine/orm": "^2.10",
15+
"lexik/jwt-authentication-bundle": "^2.14",
1516
"phpdocumentor/reflection-docblock": "^5.3",
1617
"ramsey/uuid": "^4.2",
1718
"ramsey/uuid-doctrine": "^1.8",
@@ -26,6 +27,7 @@
2627
"symfony/property-info": "5.4.*",
2728
"symfony/proxy-manager-bridge": "5.4.*",
2829
"symfony/runtime": "5.4.*",
30+
"symfony/security-bundle": "5.4.*",
2931
"symfony/serializer": "5.4.*",
3032
"symfony/string": "5.4.*",
3133
"symfony/validator": "5.4.*",

0 commit comments

Comments
 (0)