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

chore(api): upgrade to api-platform 3.0 #3176

Merged
merged 80 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
b5f224e
convert legacy interfaces/factories
usu Sep 17, 2022
d096e34
run + formatting + clenaup + revert unnecessary changes
usu Sep 17, 2022
62efc19
first working test: testGetSingleDayIsAllowedForMember
usu Sep 17, 2022
2912898
upgrade to api-platform 3 + fix pointers to old ApiPlatcorm\Core name…
usu Sep 17, 2022
79bf687
exclude DataPersister/DataProvider from service discovery (unfixed code)
usu Sep 17, 2022
0f88b0e
fix oauth
usu Sep 17, 2022
2e80944
fix getExamplePayload for testing
usu Sep 18, 2022
b338940
merge devel
usu Oct 21, 2022
35bb88f
upgrade to api-platform 3.0.2
usu Oct 21, 2022
a559b9f
fix TranslationNormalizer and Skolem IRI BC change
usu Oct 21, 2022
87bad65
exampe StateProcessor for Activity
usu Oct 21, 2022
2e88eae
example state processors for CampCollaboration
usu Oct 21, 2022
d0c78b7
abstraction of property changes via AbstractPersistProcessor
usu Oct 21, 2022
cad76dc
merge devel
usu Nov 12, 2022
95dfb34
upgrade to api-platform/core 3.0.3
usu Nov 12, 2022
98b4c52
fix CreateCampCollaborationTest
usu Nov 12, 2022
8d5e56a
bind to abstract class
usu Nov 13, 2022
c169f70
state processors for Camp and Period
usu Nov 13, 2022
9def6d7
state processors for Category
usu Nov 13, 2022
19bfe0f
state processors for Profile
usu Nov 13, 2022
da66674
state processors for User
usu Nov 13, 2022
44def44
state processors for Invitation DTO
usu Nov 13, 2022
be9fd5d
state processors for ResetPassword
usu Nov 13, 2022
7dab5b2
state processors for content nodes
usu Nov 13, 2022
c56335f
remove dead code
usu Nov 13, 2022
8b82874
fix api tests for MaterialNode, MultiSelect and CampCollaboration
usu Nov 14, 2022
d433c5c
fix api tests for Invitation DTO
usu Nov 16, 2022
be369de
fix MaterialItemDenormalizer
usu Nov 16, 2022
1f4ee66
upgrade api-platform/core to 3.0.4
usu Nov 16, 2022
8fd11dc
remove Get operation from the general ContentNode endpoint
usu Nov 16, 2022
fd0505e
fix ValidateDeleteRequestsListener
usu Nov 16, 2022
4022d51
fix tests for ExpressionDateTimeFilter
usu Nov 16, 2022
8553985
downgrade api-platform to 3.0.3
usu Nov 17, 2022
c95957b
fix tests for UriTemplateFactory
usu Nov 19, 2022
f8839dc
fix tests for RelatedCollectionLinkNormalizer
usu Nov 19, 2022
9a47dda
fix tests for UriTemplateNormalizer
usu Nov 19, 2022
6c14137
fix PreventAutomaticEmbeddingPropertyMetadataFactoryTest
usu Nov 19, 2022
9cb51c7
fix MailServiceTest
usu Nov 19, 2022
f1689d8
fix DTO uri
usu Nov 19, 2022
21b8db0
merge devel
usu Nov 19, 2022
2d81cdd
fix reset_password endpoint
usu Nov 19, 2022
ddfc68c
fix various psalm/phpstan/cs-fixer errors
usu Nov 19, 2022
c25e8f9
consistent state processor handling for DTOs
usu Nov 19, 2022
3385806
Use more mocking instead of allowing to override final classes
carlobeltrame Nov 21, 2022
0e91f83
Can't mock final class, just instantiate it
carlobeltrame Nov 22, 2022
6c04fa2
Merge pull request #13 from carlobeltrame/chore/api-platform-3.0
usu Nov 22, 2022
ac5a70b
upgrade to api-platform 3.0.4
usu Nov 23, 2022
dfb0b16
small documentation changes as per PR review
usu Nov 23, 2022
5e83943
rename propertyMetadata to apiProperty
usu Nov 23, 2022
c60aadc
upgrade to api-platform 3.0.5
usu Nov 26, 2022
382ac5d
additional test coverage for RelatedCollectionLinkNormalizer
usu Dec 6, 2022
5485761
add unit test for OperationHelper
usu Dec 6, 2022
7f42c2c
minor cleanups/renamings
usu Dec 6, 2022
1b86282
merge devel
usu Dec 6, 2022
ee5fa83
test for ActivityCreateProcessor
usu Dec 10, 2022
546cc63
CampCollaboration: remove logic from MailSerice + write tests for sta…
usu Dec 11, 2022
ea3d68b
Camp: tests for state processors
usu Dec 11, 2022
6cb35ef
eliminate deprecation + phpstan/pslam warnings
usu Dec 11, 2022
29675a6
Category: state processor tests
usu Dec 11, 2022
a68fba9
Period: tests for state processor
usu Dec 11, 2022
d771ff5
User: tests for state processors
usu Dec 11, 2022
716d7fa
Profile: tests for state processors
usu Dec 11, 2022
854b362
test for ContentNode state processors
usu Dec 11, 2022
5007cd8
tests for DTO state processors
usu Dec 11, 2022
2ff057d
tests for abstract state processors + cleanup
usu Dec 11, 2022
ec8b661
increase test coverage for state processors
usu Dec 11, 2022
2c36fcf
merge devel
usu Dec 11, 2022
ecedc66
upgrade api-platform/core to 3.0.7
usu Dec 11, 2022
83b49cf
revert routePrefix/endpoint splitup
usu Dec 11, 2022
bf6ae18
simplify example payload generation
usu Dec 11, 2022
850b423
remove metadata cache config (resolved with api-platform/core 3.0.7)
usu Dec 11, 2022
e489ad8
remove Get operation from generic /content_nodes endpoint
usu Dec 11, 2022
2a3d2ff
fix root route + fix remaining tests
usu Dec 11, 2022
9b5dd04
fix tests for UriTemplateNormalizer + add new failing test for Conten…
usu Dec 13, 2022
ad53e2f
upgrade api-platform to 3.0.8
usu Dec 17, 2022
57a0995
add back metadata cache config
usu Dec 17, 2022
47a3838
remove usage of ApiProperty:default
usu Dec 17, 2022
b4ae490
merge devel
usu Jan 24, 2023
f13b908
remove dead test code
usu Jan 24, 2023
5b314d4
update composer.lock
usu Jan 24, 2023
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 api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"php": ">=8.1.0",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "2.7.7",
"api-platform/core": "3.0.8",
"composer/package-versions-deprecated": "1.11.99",
"cweagans/composer-patches": "1.7.3",
"doctrine/doctrine-bundle": "2.8.2",
Expand Down
96 changes: 47 additions & 49 deletions api/composer.lock

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

2 changes: 1 addition & 1 deletion api/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Expand Down
55 changes: 47 additions & 8 deletions api/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ services:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.


_instanceof:
App\State\Util\AbstractPersistProcessor:
bind:
$decorated: '@api_platform.doctrine.orm.state.persist_processor'

App\State\Util\AbstractRemoveProcessor:
bind:
$decorated: '@api_platform.doctrine.orm.state.remove_processor'


# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
Expand All @@ -24,9 +35,6 @@ services:
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones

App\DataPersister\Util\DataPersisterObservable:
arguments: [ '@api_platform.doctrine.orm.data_persister' ]

App\Validator\MaterialItemUpdateGroupSequence:
public: true

Expand All @@ -45,14 +53,10 @@ services:
tags:
- 'app.input_filter'

App\Metadata\Resource\Factory\GraphQLSecurityResourceMetadataFactory:
decorates: 'api_platform.metadata.resource.metadata_factory'

App\Serializer\Normalizer\RelatedCollectionLinkNormalizer:
decorates: 'api_platform.hal.normalizer.item'
arguments:
- '@.inner'
- '@api_platform.route_name_resolver'
- '@api_platform.filter_locator'
- '@serializer.name_converter.metadata_aware'
- '@Rize\UriTemplate'
Expand All @@ -78,7 +82,7 @@ services:
decorates: 'api_platform.serializer.context_builder'

App\Serializer\PreventAutomaticEmbeddingPropertyMetadataFactory:
decorates: 'api_platform.metadata.property.metadata_factory.legacy'
decorates: 'api_platform.metadata.property.metadata_factory'
# Priority should be 1 lower than the one of SerializerPropertyMetadataFactory, see
# https://github.com/api-platform/core/blob/main/src/Bridge/Symfony/Bundle/Resources/config/metadata/metadata.xml#L65
decoration_priority: 29
Expand Down Expand Up @@ -167,3 +171,38 @@ services:
# ensure, data coming from API without timezone information is interpreted as UTC
# (e.g. period start '2021-01-01' in POST payload)
datetime_timezone: 'UTC'

# https://github.com/api-platform/core/issues/4975#issuecomment-1253617780
api_platform.cache.metadata.property:
parent: cache.system
usu marked this conversation as resolved.
Show resolved Hide resolved
tags: [ cache.pool ]
api_platform.cache.metadata.resource:
parent: cache.system
tags: [ cache.pool ]
api_platform.cache.metadata.resource_collection:
parent: cache.system
tags: [ cache.pool ]
api_platform.cache.route_name_resolver:
parent: cache.system
tags: [ cache.pool ]
api_platform.cache.identifiers_extractor:
parent: cache.system
tags: [ cache.pool ]
api_platform.elasticsearch.cache.metadata.document:
parent: cache.system
tags: [ cache.pool ]

# https://github.com/api-platform/core/issues/4975#issuecomment-1327620795
# Speeds up api-platform cache build substantially
# May have to be removed soon when api-platform removes these services
# see vendor/api-platform/core/src/Symfony/Bundle/Resources/config/metadata/property.xml:41
api_platform.cache.metadata.identifier:
parent: cache.adapter.array
tags: [ cache.pool ]
api_platform.metadata.property.identifier_metadata_factory.cached:
class: ApiPlatform\Metadata\Property\Factory\CachedPropertyMetadataFactory
decorates: api_platform.metadata.property.identifier_metadata_factory
decoration_priority: 99
arguments:
- '@api_platform.cache.metadata.identifier'
- '@api_platform.metadata.property.identifier_metadata_factory.cached.inner'
86 changes: 40 additions & 46 deletions api/src/DTO/Invitation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

namespace App\DTO;

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use App\State\InvitationAcceptProcessor;
use App\State\InvitationProvider;
use App\State\InvitationRejectProcessor;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;

Expand All @@ -12,51 +18,39 @@
* already have an account.
*/
#[ApiResource(
collectionOperations: [
'get' => [
'security' => 'false',
'path' => '',
'openapi_context' => [
'description' => 'Not implemented. Only needed that we can show this endpoint in /index.jsonhal.',
],
],
operations: [
new Get(
provider: InvitationProvider::class,
uriTemplate: '/invitations/{inviteKey}/find{._format}', // TO DISCUSS: Wouldn't '/{inviteKey}{._format}' be more REST-like
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I agree. And we could use PATCH for accept, and DELETE for reject. Using DELETE will need changes in the frontend as well though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss in the next meeting. Technically, both the accept and reject modify the underlying campCollaboration but delete the invitation (delete in the sense that the invitation is not accessible anymore afterwards).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would not change that in this PR, but save it for a later PR

Copy link
Member

@manuelmeister manuelmeister Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core Meeting Decision

  • remove find
  • at a later point move to delete instead of patch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the /find for the moment, it didn't intervene too much. We can clean up in a separate PR. I will create a master issue with all the remaining points after merging this.

normalizationContext: self::ITEM_NORMALIZATION_CONTEXT,
openapiContext: ['description' => 'Use myInviteKey to find an invitation in the dev environment.']
),
new Patch(
provider: InvitationProvider::class,
processor: InvitationAcceptProcessor::class,
output: Invitation::class,
security: 'is_authenticated()',
uriTemplate: '/invitations/{inviteKey}/'.self::ACCEPT.'{._format}',
denormalizationContext: ['groups' => ['write']],
normalizationContext: self::ITEM_NORMALIZATION_CONTEXT,
openapiContext: ['summary' => 'Accept an Invitation.', 'description' => 'Use myInviteKey2 to accept an invitation in dev environment.'],
validationContext: ['groups' => ['Default', 'accept']]
),
new Patch(
provider: InvitationProvider::class,
processor: InvitationRejectProcessor::class,
output: Invitation::class,
uriTemplate: '/invitations/{inviteKey}/'.self::REJECT.'{._format}',
denormalizationContext: ['groups' => ['write']],
normalizationContext: self::ITEM_NORMALIZATION_CONTEXT,
openapiContext: ['summary' => 'Reject an Invitation.', 'description' => 'Use myInviteKey to reject an invitation in dev environment.']
),
new GetCollection(
provider: InvitationProvider::class,
security: 'false',
openapiContext: ['description' => 'Not implemented. Only needed that we can show this endpoint in /index.jsonhal.']
),
],
itemOperations: [
'get' => [
'path' => '/{inviteKey}/find.{_format}',
'normalization_context' => self::ITEM_NORMALIZATION_CONTEXT,
'openapi_context' => [
'description' => 'Use myInviteKey to find an invitation in the dev environment.',
],
],
self::ACCEPT => [
'security' => 'is_authenticated()',
'method' => 'PATCH',
'path' => '/{inviteKey}/'.self::ACCEPT.'.{_format}',
'denormalization_context' => [
'groups' => ['write'],
],
'normalization_context' => self::ITEM_NORMALIZATION_CONTEXT,
'openapi_context' => [
'summary' => 'Accept an Invitation.',
'description' => 'Use myInviteKey2 to accept an invitation in dev environment.',
],
'validation_groups' => ['Default', 'accept'],
],
self::REJECT => [
'method' => 'PATCH',
'path' => '/{inviteKey}/'.self::REJECT.'.{_format}',
'denormalization_context' => [
'groups' => ['write'],
],
'normalization_context' => self::ITEM_NORMALIZATION_CONTEXT,
'openapi_context' => [
'summary' => 'Reject an Invitation.',
'description' => 'Use myInviteKey to reject an invitation in dev environment.',
],
],
],
routePrefix: '/invitations'
)]
class Invitation {
public const ACCEPT = 'accept';
Expand Down
Loading