From b274c8417a14cddd7433a4b882050be8dda89659 Mon Sep 17 00:00:00 2001 From: BacLuc Date: Mon, 11 Dec 2023 16:48:49 +0100 Subject: [PATCH] api: fix deprecation 'Since api-platform/core 3.1: The "openapiContext" option is deprecated, use "openapi" instead.' --- api/src/DTO/Invitation.php | 10 +++++----- api/src/DTO/ResetPassword.php | 3 ++- api/src/Entity/CampCollaboration.php | 5 +++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/api/src/DTO/Invitation.php b/api/src/DTO/Invitation.php index f0311776902..9978b32f271 100644 --- a/api/src/DTO/Invitation.php +++ b/api/src/DTO/Invitation.php @@ -7,6 +7,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Patch; +use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation; use App\State\InvitationAcceptProcessor; use App\State\InvitationProvider; use App\State\InvitationRejectProcessor; @@ -23,7 +24,7 @@ provider: InvitationProvider::class, uriTemplate: '/invitations/{inviteKey}/find{._format}', // TO DISCUSS: Wouldn't '/{inviteKey}{._format}' be more REST-like normalizationContext: self::ITEM_NORMALIZATION_CONTEXT, - openapiContext: ['description' => 'Use myInviteKey to find an invitation in the dev environment.'] + openapi: new OpenApiOperation(description: 'Use myInviteKey to find an invitation in the dev environment.') ), new Patch( provider: InvitationProvider::class, @@ -33,7 +34,7 @@ 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.'], + openapi: new OpenApiOperation(summary: 'Accept an Invitation.', description: 'Use myInviteKey2 to accept an invitation in dev environment.'), validationContext: ['groups' => ['Default', 'accept']] ), new Patch( @@ -43,13 +44,12 @@ 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.'] + openapi: new OpenApiOperation(summary: 'Reject an Invitation.', description: 'Use myInviteKey to reject an invitation in dev environment.') ), new GetCollection( provider: InvitationProvider::class, security: 'false', - openapi: false, - openapiContext: ['description' => 'Not implemented. Only needed that we can show this endpoint in /index.jsonhal.'] + openapi: false ), ], )] diff --git a/api/src/DTO/ResetPassword.php b/api/src/DTO/ResetPassword.php index eb87d2ed1dc..3445e30fad4 100644 --- a/api/src/DTO/ResetPassword.php +++ b/api/src/DTO/ResetPassword.php @@ -7,6 +7,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Post; +use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation; use App\InputFilter; use App\State\ResetPasswordCreateProcessor; use App\State\ResetPasswordProvider; @@ -36,7 +37,7 @@ output: false, denormalizationContext: ['groups' => ['create']], normalizationContext: ['groups' => ['read']], - openapiContext: ['summary' => 'Request Password-Reset-Mail', 'description' => 'Password-Reset-Link will be sent to the given email'] + openapi: new OpenApiOperation(summary: 'Request Password-Reset-Mail', description: 'Password-Reset-Link will be sent to the given email') ), ], routePrefix: '/auth' diff --git a/api/src/Entity/CampCollaboration.php b/api/src/Entity/CampCollaboration.php index a5a7ec89ce3..fc12c765970 100644 --- a/api/src/Entity/CampCollaboration.php +++ b/api/src/Entity/CampCollaboration.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Post; +use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation; use App\InputFilter; use App\Repository\CampCollaborationRepository; use App\State\CampCollaborationCreateProcessor; @@ -50,7 +51,7 @@ security: '(is_authenticated() && user === object.user) or is_granted("CAMP_MEMBER", object) or is_granted("CAMP_MANAGER", object)', uriTemplate: 'camp_collaborations/{id}/'.self::RESEND_INVITATION, denormalizationContext: ['groups' => ['resend_invitation']], - openapiContext: ['summary' => 'Send the invitation email for this CampCollaboration again. Only possible, if the status is already invited.'], + openapi: new OpenApiOperation(summary: 'Send the invitation email for this CampCollaboration again. Only possible, if the status is already invited.'), validationContext: ['groups' => ['Default', 'resend_invitation']] ), new GetCollection( @@ -61,7 +62,7 @@ processor: CampCollaborationCreateProcessor::class, denormalizationContext: ['groups' => ['write', 'create']], normalizationContext: self::ITEM_NORMALIZATION_CONTEXT, - openapiContext: ['description' => 'Also sends an invitation email to the inviteEmail address, if specified.'], + openapi: new OpenApiOperation(description: 'Also sends an invitation email to the inviteEmail address, if specified.'), securityPostDenormalize: 'is_granted("CAMP_MEMBER", object) or is_granted("CAMP_MANAGER", object)' ), ],