From 028a624812b07c3b85b0b5ad153a02a81a2783c4 Mon Sep 17 00:00:00 2001 From: Thibaudeau Pierre Date: Tue, 7 Sep 2021 15:16:59 +0200 Subject: [PATCH] fix: text_inconsistencies _api_operation_name snake to camel case operations --- core/content-negotiation.md | 6 +-- core/controllers.md | 13 +++--- core/errors.md | 2 +- core/fosuser-bundle.md | 4 +- core/graphql.md | 2 +- core/openapi.md | 4 +- core/operations.md | 83 ++++--------------------------------- core/pagination.md | 2 +- core/performance.md | 2 +- core/security.md | 4 +- core/serialization.md | 2 +- 11 files changed, 29 insertions(+), 95 deletions(-) diff --git a/core/content-negotiation.md b/core/content-negotiation.md index dbfcdaebda5..c24709e6914 100644 --- a/core/content-negotiation.md +++ b/core/content-negotiation.md @@ -94,10 +94,10 @@ api_platform: ## Configuring Formats For a Specific Resource or Operation -Support for specific formats can also be configured at resource and operation level using the `input_formats` and `output_formats` attributes. -`input_formats` controls the formats accepted in request bodies while `output_formats` controls formats available for responses. +Support for specific formats can also be configured at resource and operation level using the `inputFormats` and `outputFormats` attributes. +`inputFormats` controls the formats accepted in request bodies while `outputFormats` controls formats available for responses. -The `format` attribute can be used as a shortcut, it sets both the `input_formats` and `output_formats` in one time. +The `format` attribute can be used as a shortcut, it sets both the `inputFormats` and `outputFormats` in one time. ```php Book::class, - '_api_item_operation_name' => 'post_publication', + '_api_operation_name' => '_api_/books/{id}/publication_post', ], )] public function __invoke(Book $book): Book @@ -403,8 +403,7 @@ class CreateBookPublication extends AbstractController } ``` -It is mandatory to set `_api_resource_class` and `_api_item_operation_name` (or `_api_collection_operation_name` for a collection -operation) in the parameters of the route (`defaults` key). It allows API Platform to work with the Symfony routing system. +It is mandatory to set `_api_resource_class` and `_api_operation_name` in the parameters of the route (`defaults` key). It allows API Platform to work with the Symfony routing system. Alternatively, you can also use a traditional Symfony controller and YAML or XML route declarations. The following example does the same thing as the previous example: diff --git a/core/errors.md b/core/errors.md index a02033e9561..043d583e124 100644 --- a/core/errors.md +++ b/core/errors.md @@ -110,7 +110,7 @@ In any other cases, your exception message will be sent to end users. ## Fine-grained Configuration -The `exception_to_status` configuration can be set on resources and operations: +The `exceptionToStatus` configuration can be set on resources and operations: ```php - - - - - - - - - - GET - - - - -``` - -[/codeSelector] - API Platform Core is smart enough to automatically register the applicable Symfony route referencing a built-in CRUD action just by specifying the method name as key, or by checking the explicitly configured HTTP method. @@ -195,7 +136,7 @@ use ApiPlatform\Metadata\ApiResource; read: false, output: false )] -#[GetCollection] +#[GetCollection] class Book { // ... @@ -336,13 +277,11 @@ App\Entity\Book: [/codeSelector] -In all these examples, the `method` attribute is omitted because it matches the operation name. - ## Prefixing All Routes of All Operations Sometimes it's also useful to put a whole resource into its own "namespace" regarding the URI. Let's say you want to put everything that's related to a `Book` into the `library` so that URIs become `library/book/{id}`. In that case -you don't need to override all the operations to set the path but configure the `route_prefix` attribute for the whole entity instead: +you don't need to override all the operations to set the path but configure the `routePrefix` attribute for the whole entity instead: [codeSelector] @@ -394,8 +333,6 @@ App\Entity\Book: [/codeSelector] -Alternatively, the more verbose attribute syntax can be used: `#[ApiResource(routePrefix: "/library")]`. - API Platform will automatically map this `post_publication` operation to the route `book_post_publication`. Let's create a custom action and its related route using annotations: @@ -422,7 +359,7 @@ class CreateBookPublication extends AbstractController name: 'book_post_publication', defaults: [ '_api_resource_class' => Book::class, - '_api_item_operation_name' => 'post_publication', + '_api_operation_name' => '_api_/books/{id}/publication_post', ], methods: ['POST'], )] @@ -435,8 +372,7 @@ class CreateBookPublication extends AbstractController } ``` -It is mandatory to set `_api_resource_class` and `_api_item_operation_name` (or `_api_collection_operation_name` for a collection -operation) in the parameters of the route (`defaults` key). It allows API Platform to work with the Symfony routing system. +It is mandatory to set `_api_resource_class` and `_api_operation_name`in the parameters of the route (`defaults` key). It allows API Platform to work with the Symfony routing system. Alternatively, you can also use a traditional Symfony controller and YAML or XML route declarations. The following example does the exact same thing as the previous example: @@ -609,7 +545,6 @@ Then, remove the route from the decorator: ```php