Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Api Platform to 3.2 #325

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ext-ctype": "*",
"ext-dom": "*",
"ext-iconv": "*",
"api-platform/core": "^2.7",
"api-platform/core": "^3.2",
"discord-php/http": "^10.3",
"doctrine/doctrine-bundle": "^2.11",
"doctrine/doctrine-fixtures-bundle": "^3.4",
Expand Down
142 changes: 69 additions & 73 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 17 additions & 15 deletions config/api_platform/resources/Attendance.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
App\Entity\Attendance\Attendance:
attributes:
input: 'App\Api\Input\Attendance\AttendanceInput'
output: 'App\Api\Output\Attendance\AttendanceOutput'
resources:
App\Entity\Attendance\Attendance:
operations:
ApiPlatform\Metadata\GetCollection:
provider: 'App\Api\Provider\Attendance\AttendanceDataProvider'
output: 'App\Api\Output\Attendance\AttendanceOutput'
filters:
- 'attendance.search_filter'
- 'attendance.date_filter'
- 'attendance.order_filter'

itemOperations:
get: ~
ApiPlatform\Metadata\Get:
provider: 'App\Api\Provider\Attendance\AttendanceDataProvider'
output: 'App\Api\Output\Attendance\AttendanceOutput'

collectionOperations:
get:
filters:
- 'attendance.search_filter'
- 'attendance.date_filter'
- 'attendance.order_filter'

post:
input: 'App\Api\Input\Attendance\AttendanceInput'
ApiPlatform\Metadata\Post:
input: 'App\Api\Input\Attendance\AttendanceInput'
processor: 'App\Api\Processor\Attendance\AttendanceProcessor'
output: 'App\Api\Output\Attendance\AttendanceOutput'
42 changes: 23 additions & 19 deletions config/api_platform/resources/ModList.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
App\Entity\ModList\ModList:
attributes:
output: 'App\Api\Output\ModList\ModListOutput'
resources:
App\Entity\ModList\ModList:
operations:
ApiPlatform\Metadata\GetCollection:
provider: 'App\Api\Provider\ModList\ModListDataProvider'
output: 'App\Api\Output\ModList\ModListOutput'
filters:
- 'mod_list.search_filter'
- 'mod_list.date_filter'
- 'mod_list.order_filter'

itemOperations:
get:
output: 'App\Api\Output\ModList\ModListDetailsOutput'
ApiPlatform\Metadata\Get:
provider: 'App\Api\Provider\ModList\ModListDetailsDataProvider'
output: 'App\Api\Output\ModList\ModListDetailsOutput'

get_by_name:
method: 'GET'
path: '/mod-lists/by-name/{name}'
controller: 'App\Api\Controller\GetModListByNameAction'
output: 'App\Api\Output\ModList\ModListDetailsOutput'
read: false

collectionOperations:
get:
filters:
- 'mod_list.search_filter'
- 'mod_list.date_filter'
- 'mod_list.order_filter'
get_by_name:
output: 'App\Api\Output\ModList\ModListDetailsOutput'
class: 'ApiPlatform\Metadata\Get'
uriTemplate: '/mod-lists/by-name/{name}'
uriVariables:
name:
fromClass: 'App\Entity\ModList\ModList'
fromProperty: 'name'
controller: 'App\Api\Controller\ModList\GetModListByNameOperation'
read: false
2 changes: 1 addition & 1 deletion config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
KnpU\OAuth2ClientBundle\KnpUOAuth2ClientBundle::class => ['all' => true],
FOS\JsRoutingBundle\FOSJsRoutingBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
];
32 changes: 19 additions & 13 deletions config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,33 @@ api_platform:
title: "%app.api.name%"
version: "%app.api.version%"
show_webby: false

swagger:
versions: [3]
versions: [ 3 ]
api_keys:
apiKey:
name: '%env(APP_SECURITY_API_KEY_HEADER_NAME)%'
type: header

path_segment_name_generator: api_platform.path_segment_name_generator.dash

mapping:
paths: ['%kernel.project_dir%/config/api_platform/resources']
patch_formats:
json: ['application/merge-patch+json']
paths: [ '%kernel.project_dir%/config/api_platform/resources' ]

formats:
json: ['application/json']
html: ['text/html']
json: [ 'application/json' ]

docs_formats:
html: [ 'text/html' ]

defaults:
pagination_enabled: true
pagination_maximum_items_per_page: 50
pagination_client_items_per_page: true
collection:
pagination:
items_per_page_parameter_name: limit
page_parameter_name: page
stateless: true
cache_headers:
vary: [ 'Content-Type', 'Authorization', 'Origin' ]
extra_properties:
standard_put: true
rfc_7807_compliant_errors: true
normalization_context:
skip_null_values: false
event_listeners_backward_compatibility_layer: false
keep_legacy_inflector: false
2 changes: 1 addition & 1 deletion config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ security:
lazy: true
stateless: true
pattern: ^/api/attendances
methods: ['POST']
methods: [ 'POST' ]
custom_authenticators:
- App\Security\Authenticator\ApiKeyAuthenticator

Expand Down
4 changes: 0 additions & 4 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ services:
resource: '../src/Controller/'
tags: [ 'controller.service_arguments' ]

App\Api\Controller\:
resource: '../src/Api/Controller/'
tags: [ 'controller.service_arguments' ]

# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
App\Security\Authenticator\DiscordAuthenticator:
Expand Down
Loading
Loading