From 15d684c6665cc5cda100f21fede0a4fd11b388f1 Mon Sep 17 00:00:00 2001 From: Polo M2B Date: Wed, 20 Sep 2023 19:15:37 +0200 Subject: [PATCH] Remove some operations Book can not be updated (no Patch) Review can not be destroyed (no Destroy) OpenAPI file is modified, two operations should be modified. --- api/src/Entity/Book.php | 16 +++++- api/src/Entity/Review.php | 16 +++++- docs/openapi.json | 101 -------------------------------------- 3 files changed, 30 insertions(+), 103 deletions(-) diff --git a/api/src/Entity/Book.php b/api/src/Entity/Book.php index 850b654..5f359e8 100644 --- a/api/src/Entity/Book.php +++ b/api/src/Entity/Book.php @@ -2,11 +2,25 @@ // api/src/Entity/Book.php namespace App\Entity; use ApiPlatform\Metadata\ApiResource; +use ApiPlatform\Metadata\Get; +use ApiPlatform\Metadata\Put; +use ApiPlatform\Metadata\Delete; +use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\Post; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; /** A book. */ #[ORM\Entity] -#[ApiResource] +#[ApiResource( + operations: [ + new Get(), + new Put(), + new Delete(), + new GetCollection(), + new Post(), + ] +)] + class Book { /** The ID of this book. */ diff --git a/api/src/Entity/Review.php b/api/src/Entity/Review.php index d263947..c645421 100644 --- a/api/src/Entity/Review.php +++ b/api/src/Entity/Review.php @@ -2,10 +2,24 @@ // api/src/Entity/Review.php namespace App\Entity; use ApiPlatform\Metadata\ApiResource; +use ApiPlatform\Metadata\Get; +use ApiPlatform\Metadata\Put; +use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\Post; +use ApiPlatform\Metadata\Patch; use Doctrine\ORM\Mapping as ORM; /** A review of a book. */ #[ORM\Entity] -#[ApiResource] +#[ApiResource( + operations: [ + new Get(), + new Put(), + new GetCollection(), + new Post(), + new Patch(), + ] +)] + class Review { /** The ID of this review. */ diff --git a/docs/openapi.json b/docs/openapi.json index ad094e7..7ad6714 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -377,74 +377,6 @@ ], "deprecated": false }, - "patch": { - "operationId": "api_books_id_patch", - "tags": [ - "Book" - ], - "responses": { - "200": { - "description": "Book resource updated", - "content": { - "application/ld+json": { - "schema": { - "$ref": "#/components/schemas/Book.jsonld" - } - }, - "application/json": { - "schema": { - "$ref": "#/components/schemas/Book" - } - }, - "text/html": { - "schema": { - "$ref": "#/components/schemas/Book" - } - } - }, - "links": {} - }, - "400": { - "description": "Invalid input" - }, - "404": { - "description": "Resource not found" - }, - "422": { - "description": "Unprocessable entity" - } - }, - "summary": "Updates the Book resource.", - "description": "Updates the Book resource.", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "Book identifier", - "required": true, - "deprecated": false, - "allowEmptyValue": false, - "schema": { - "type": "string" - }, - "style": "simple", - "explode": false, - "allowReserved": false - } - ], - "requestBody": { - "description": "The updated Book resource", - "content": { - "application/merge-patch+json": { - "schema": { - "$ref": "#/components/schemas/Book" - } - } - }, - "required": true - }, - "deprecated": false - }, "parameters": [] }, "/reviews": { @@ -779,39 +711,6 @@ }, "deprecated": false }, - "delete": { - "operationId": "api_reviews_id_delete", - "tags": [ - "Review" - ], - "responses": { - "204": { - "description": "Review resource deleted" - }, - "404": { - "description": "Resource not found" - } - }, - "summary": "Removes the Review resource.", - "description": "Removes the Review resource.", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "Review identifier", - "required": true, - "deprecated": false, - "allowEmptyValue": false, - "schema": { - "type": "string" - }, - "style": "simple", - "explode": false, - "allowReserved": false - } - ], - "deprecated": false - }, "patch": { "operationId": "api_reviews_id_patch", "tags": [