From 26d2b0a577ccda64974db2a80a1778a49fc7ac83 Mon Sep 17 00:00:00 2001 From: Maxcastel Date: Mon, 30 Nov 2026 15:40:22 +0100 Subject: [PATCH 1/4] docs: use the real Laravel configuration in the reference --- core/configuration.md | 419 ++++++++++++++++-------------------------- 1 file changed, 161 insertions(+), 258 deletions(-) diff --git a/core/configuration.md b/core/configuration.md index a7be08eb722..2635611d180 100644 --- a/core/configuration.md +++ b/core/configuration.md @@ -386,268 +386,118 @@ api_platform: ## Laravel Configuration -Here's the complete configuration of [API Platform for Laravel](../laravel/index.md) including -default values: +Here's the configuration of [API Platform for Laravel](../laravel/index.md) with its default values, +as published in `config/api-platform.php` by `php artisan api-platform:install` (or +`php artisan vendor:publish --tag=api-platform-config`): ```php 'API title', - - // The description of the API. - 'description' => 'API description', - - // The version of the API. - 'version' => '0.0.0', - - // Set this to false if you want Webby to disappear. + 'title' => 'API Platform', + 'description' => 'My awesome API', + 'version' => '1.0.0', 'show_webby' => true, - // Specify a name converter to use. - 'name_converter' => null, - - // Specify an asset package name to use. - 'asset_package' => null, - - // Specify a path name generator to use. - 'path_segment_name_generator' => 'api_platform.path_segment_name_generator.underscore', - - 'validator' => [ - // Enable the serialization of payload fields when a validation error is thrown. - // If you want to serialize only some payload fields, define them like this: [ severity, anotherPayloadField ] - 'serialize_payload_fields' => [], - ], - - 'eager_loading' => [ - // To enable or disable eager loading. - 'enabled' => true, - - // Fetch only partial data according to serialization groups. - // If enabled, Doctrine ORM entities will not work as expected if any of the other fields are used. - 'fetch_partial' => false, - - // Max number of joined relations before EagerLoading throws a RuntimeException. - 'max_joins' => 30, - - // Force join on every relation. - // If disabled, it will only join relations having the EAGER fetch mode. - 'force_eager' => true, - ], - - // Enable the Swagger documentation and export. - 'enable_swagger' => true, - - // Enable Swagger UI. - 'enable_swagger_ui' => true, - - // Enable ReDoc. - 'enable_re_doc' => true, - - // Enable the entrypoint. - 'enable_entrypoint' => true, - - // Enable the docs. - 'enable_docs' => true, - - // Skip response body construction on HEAD requests so collections are not iterated. - // Disable to process HEAD identically to GET. - 'enable_head_request_optimization' => true, - - // Enable the data collector and the WebProfilerBundle integration. - 'enable_profiler' => true, - - 'collection' => [ - // The name of the query parameter to filter nullable results (with the ExistsFilter). - 'exists_parameter_name' => 'exists', - - // The default order of results. - 'order' => 'ASC', - - // The name of the query parameter to order results (with the OrderFilter). - 'order_parameter_name' => 'order', - - 'pagination' => [ - // The default name of the parameter handling the page number. - 'page_parameter_name' => 'page', - - // The name of the query parameter to enable or disable pagination. - 'enabled_parameter_name' => 'pagination', - - // The name of the query parameter to set the number of items per page. - 'items_per_page_parameter_name' => 'itemsPerPage', - - // The name of the query parameter to enable or disable the partial pagination. - 'partial_parameter_name' => 'partial', - ], + 'routes' => [ + 'domain' => null, + // Global middleware applied to every API Platform routes + // 'middleware' => [], ], - 'mapping' => [ - // The list of paths with files or directories where the bundle will look for additional resource files. - 'paths' => [], + 'resources' => [ + app_path('Models'), + app_path('ApiResource'), ], - 'doctrine' => [ - // To enable or disable Doctrine ORM support. - 'enabled' => true, + 'formats' => [ + 'jsonld' => ['application/ld+json'], + 'json' => ['application/json'], + // 'jsonapi' => ['application/vnd.api+json'], + // 'csv' => ['text/csv'], ], - 'doctrine_mongodb_odm' => [ - // To enable or disable Doctrine MongoDB ODM support. - 'enabled' => false, + 'patch_formats' => [ + 'json' => ['application/merge-patch+json'], ], - 'oauth' => [ - // To enable or disable OAuth. - 'enabled' => false, - - // The OAuth client ID. - 'clientId' => '', - - // The OAuth client secret. - 'clientSecret' => '', - - // The OAuth type. - 'type' => 'oauth2', + // When true, 'required' validation rules are replaced with 'sometimes' + // on PATCH operations, allowing partial updates without requiring all fields. + 'partial_patch_validation' => false, - // The OAuth flow grant type. - 'flow' => 'application', - - // The OAuth token URL. Make sure to check the specification tokenUrl is not needed for an implicit flow. - 'tokenUrl' => '', - - // The OAuth authentication URL. - 'authorizationUrl' => '', + // When true (default), HEAD requests skip response body construction so + // collections are not iterated. Set to false to process HEAD like GET. + 'enable_head_request_optimization' => true, - // The OAuth scopes. - 'scopes' => [], + 'docs_formats' => [ + 'jsonld' => ['application/ld+json'], + // 'jsonapi' => ['application/vnd.api+json'], + 'jsonopenapi' => ['application/vnd.openapi+json'], + 'html' => ['text/html'], ], - 'graphql' => [ - // Enabled by default with installed api-platform/graphql. - 'enabled' => false, - - // The default IDE (graphiql or graphql-playground) used when going to the GraphQL endpoint. False to disable. - 'default_ide' => 'graphiql', - - 'graphiql' => [ - // Enabled by default with installed api-platform/graphql. - 'enabled' => false, - ], - - 'introspection' => [ - // Enabled by default with installed api-platform/graphql. - 'enabled' => true, - ], - - // The nesting separator used in the filter names. - 'nesting_separator' => '_', - - 'collection' => [ - 'pagination' => [ - 'enabled' => true, - ], - ], + 'error_formats' => [ + 'jsonproblem' => ['application/problem+json'], ], - 'swagger' => [ - // The active versions of OpenAPI to be exported or used in the swagger_ui. The first value is the default. - 'versions' => [2, 3], - - // The swagger API keys. - 'api_keys' => [], - - 'swagger_ui_extra_configuration' => [ - // Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing). - 'docExpansion' => 'list', - - // If set, enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. - 'filter' => false, - - // If set to true, it persists authorization data and it would not be lost on browser close/refresh - 'persistAuthorization' => true, - - // You can use any other configuration parameters too. - ], + 'defaults' => [ + 'pagination_enabled' => true, + 'pagination_partial' => false, + 'pagination_client_enabled' => false, + 'pagination_client_items_per_page' => false, + 'pagination_client_partial' => false, + 'pagination_items_per_page' => 30, + 'pagination_maximum_items_per_page' => 30, + 'route_prefix' => '/api', + 'middleware' => [], ], - 'openapi' => [ - // The contact information for the exposed API. - 'contact' => [ - // The identifying name of the contact person/organization. - 'name' => null, - - // The URL pointing to the contact information. MUST be in the format of a URL. - 'url' => null, - - // The email address of the contact person/organization. MUST be in the format of an email address. - 'email' => null, - ], - - // A URL to the Terms of Service for the API. MUST be in the format of a URL. - 'termsOfService' => null, - - // The license information for the exposed API. - 'license' => [ - // The license name used for the API. - 'name' => null, - - // URL to the license used for the API. MUST be in the format of a URL. - 'url' => null, - ], + 'pagination' => [ + 'page_parameter_name' => 'page', + 'enabled_parameter_name' => 'pagination', + 'items_per_page_parameter_name' => 'itemsPerPage', + 'partial_parameter_name' => 'partial', ], - 'http_cache' => [ - // To make all responses public by default. - 'public' => null, - - 'invalidation' => [ - // To enable the tags-based cache invalidation system. - 'enabled' => false, - - // URLs of the Varnish servers to purge using cache tags when a resource is updated. - 'urls' => [], - - // To pass options to the client charged with the request. - 'request_options' => [], + 'jsonapi' => [ + // When false (default), the JSON:API `data.id` uses the resource scalar + // identifier and a `data.links.self` IRI is added. When true, `data.id` + // is the resource IRI. + 'use_iri_as_id' => false, - // Use another service as the purger for example "api_platform.http_cache.purger.varnish.xkey" - 'purger' => 'api_platform.http_cache.purger.varnish.ban', - ], + // Allow client-generated IDs on JSON:API POST per + // https://jsonapi.org/format/#crud-creating-client-ids. Off by default + // to avoid id spoofing on public endpoints. + 'allow_client_generated_id' => false, ], - 'mercure' => [ - // Enabled by default with installed symfony/mercure-bundle. + 'graphql' => [ 'enabled' => false, - - // The URL sent in the Link HTTP header. If not set, will default to MercureBundle's default hub URL. - 'hub_url' => null, + 'nesting_separator' => '__', + 'introspection' => ['enabled' => true], + 'max_query_complexity' => 500, + 'max_query_depth' => 200, + // 'middleware' => null, ], - 'messenger' => [ - // Enabled by default with installed symfony/messenger and not installed symfony/symfony. - 'enabled' => false, + 'graphiql' => [ + // 'enabled' => true, + // 'domain' => null, + // 'middleware' => null, ], - 'elasticsearch' => [ - // To enable or disable Elasticsearch support. - 'enabled' => false, - - // The hosts to the Elasticsearch nodes. - 'hosts' => [], - - // The mapping between resource classes and indexes. - 'mapping' => [], - ], + // set to null if you want to keep snake_case + 'name_converter' => SnakeCaseToCamelCaseNameConverter::class, - // The list of exceptions mapped to their HTTP status code. 'exception_to_status' => [ AuthenticationException::class => 401, AuthorizationException::class => 403, @@ -655,54 +505,107 @@ return [ InvalidArgumentException::class => 400, ], - // The list of routes. - 'routes' => [ - // Global middleware applied to every API Platform routes - // 'middleware' => [] + 'redoc' => [ + 'enabled' => true, ], - // The list of resources. - 'resources' => [ - app_path('Models'), + 'scalar' => [ + 'enabled' => true, + 'extra_configuration' => [], ], - // The list of enabled patch formats. The first one will be the default. - 'formats' => [ - 'jsonld' => ['mime_types' => ['application/ld+json']], - 'json' => ['mime_types' => ['application/json']], - 'html' => ['mime_types' => ['text/html']], + 'swagger_ui' => [ + 'enabled' => true, + // 'apiKeys' => [ + // 'api' => [ + // 'name' => 'Authorization', + // 'type' => 'header', + // ], + // ], + // 'oauth' => [ + // 'enabled' => true, + // 'type' => 'oauth2', + // 'flow' => 'authorizationCode', + // 'tokenUrl' => '', + // 'authorizationUrl' =>'', + // 'refreshUrl' => '', + // 'scopes' => ['scope1' => 'Description scope 1'], + // 'pkce' => true, + // ], + // 'license' => [ + // 'name' => 'Apache 2.0', + // 'url' => 'https://www.apache.org/licenses/LICENSE-2.0.html', + // ], + // 'contact' => [ + // 'name' => 'API Support', + // 'url' => 'https://www.example.com/support', + // 'email' => 'support@example.com', + // ], + // 'http_auth' => [ + // 'Personal Access Token' => [ + // 'scheme' => 'bearer', + // 'bearerFormat' => 'JWT', + // ], + // ], + // + // 'with_credentials' => true, ], - // The list of enabled patch formats. The first one will be the default. - 'patch_formats' => [ - 'json' => ['application/merge-patch+json'], - ], + // 'openapi' => [ + // 'tags' => [], + // ], - // The list of enabled docs formats. The first one will be the default. - 'docs_formats' => [ - 'jsonld' => ['application/ld+json'], - //'jsonapi' => ['application/vnd.api+json'], - 'jsonopenapi' => ['application/vnd.openapi+json'], - 'html' => ['text/html'], - ], + 'url_generation_strategy' => UrlGeneratorInterface::ABS_PATH, - // The list of enabled error formats. The first one will be the default. - 'error_formats' => [ - 'jsonproblem' => ['mime_types' => ['application/problem+json']], + // Class implementing PathSegmentNameGeneratorInterface used to derive route + // segments from resource short names (e.g. `ProductOrder` -> `product_orders`). + // Set to DashPathSegmentNameGenerator::class for dasherized segments + // (e.g. `product-orders`). + 'path_segment_name_generator' => UnderscorePathSegmentNameGenerator::class, + + 'serializer' => [ + 'hydra_prefix' => false, + // 'datetime_format' => \DateTimeInterface::RFC3339, ], - // Global resources defaults, see in the next section. - 'defaults' => [ - 'pagination_enabled' => true, - 'pagination_partial' => false, - 'pagination_client_enabled' => false, - 'pagination_client_items_per_page' => false, - 'pagination_client_partial' => false, - 'pagination_items_per_page' => 30, - 'pagination_maximum_items_per_page' => 30, - 'route_prefix' => '/api', + // we recommend using "file" or "acpu" + 'cache' => 'file', + + // Path to an Eloquent model metadata file produced by `php artisan api-platform:metadata:dump`. + // When set (and APP_DEBUG is false), the model attributes and relations are read from this file + // at boot instead of being introspected from the database, allowing the app to boot without a + // live DB (e.g. during `docker build`, `composer install`, or static analysis in CI). Commit the + // file to VCS or bake it into your image, and re-run the command when your models change. Leave + // null to disable. + 'metadata_dump' => null, + + // MCP (Model Context Protocol) configuration + 'mcp' => [ + 'enabled' => true, 'middleware' => [], ], + + // install `api-platform/http-cache` + // 'http_cache' => [ + // 'etag' => false, + // 'max_age' => null, + // 'shared_max_age' => null, + // 'vary' => null, + // 'public' => null, + // 'stale_while_revalidate' => null, + // 'stale_if_error' => null, + // 'invalidation' => [ + // 'urls' => [], + // 'scoped_clients' => [], + // 'max_header_length' => 7500, + // 'request_options' => [], + // 'purger' => ApiPlatform\HttpCache\SouinPurger::class, + // ], + // ], + + 'error_handler' => [ + 'extend_laravel_handler' => true, + ], ]; ``` From c7cf3d3cd77f51abcbd53f4ff4dc3d6b5b76f5fe Mon Sep 17 00:00:00 2001 From: Maxcastel Date: Mon, 30 Nov 2026 15:40:22 +0100 Subject: [PATCH 2/4] docs: fix the Scalar extra configuration example for Symfony --- core/openapi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/openapi.md b/core/openapi.md index 21ff6265376..8ad4ffd548f 100644 --- a/core/openapi.md +++ b/core/openapi.md @@ -645,7 +645,7 @@ With Symfony: ```yaml # api/config/packages/api_platform.yaml api_platform: - swagger: + openapi: scalar_extra_configuration: theme: "purple" darkMode: true From c0a035ac500d444c329dc6f758f311bc9fe33f35 Mon Sep 17 00:00:00 2001 From: Maxcastel Date: Mon, 30 Nov 2026 15:40:22 +0100 Subject: [PATCH 3/4] docs: fix the NotFoundAction namespace --- core/operations.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/operations.md b/core/operations.md index e56442e600f..7af031d2720 100644 --- a/core/operations.md +++ b/core/operations.md @@ -612,7 +612,7 @@ For example: // api/src/Entity/Book.php namespace App\Entity; -use ApiPlatform\Action\NotFoundAction; +use ApiPlatform\Symfony\Action\NotFoundAction; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\Post; @@ -645,7 +645,7 @@ resources: status: 301 ApiPlatform\Metadata\Get: uriTemplate: "/grimoire/{id}" - controller: ApiPlatform\Action\NotFoundAction + controller: ApiPlatform\Symfony\Action\NotFoundAction read: false output: false ``` @@ -662,7 +662,7 @@ resources: + controller="ApiPlatform\Symfony\Action\NotFoundAction" read="false" output="false" /> From e744da206cc180dc053efdf3e7f5e5d36d870aee Mon Sep 17 00:00:00 2001 From: Maxcastel Date: Mon, 30 Nov 2026 15:56:21 +0100 Subject: [PATCH 4/4] docs: fix formatting and empty GraphQL selection sets --- core/filters.md | 9 +++++---- core/graphql.md | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/core/filters.md b/core/filters.md index e3fd3997b58..481266b3d89 100644 --- a/core/filters.md +++ b/core/filters.md @@ -755,10 +755,11 @@ The `IriConverterParameterProvider` supports the following options in `extraProp - **`fetch_data`**: Boolean (default: `false`) - When `true`, forces the IRI converter to fetch the actual entity data instead of just creating a reference. - **`throw_invalid_argument`**: Boolean (default: `false`) - When `true`, propagate invalid IRI - exceptions instead of logging them. With the default Symfony exception mapping, this returns HTTP - 400. This applies to both single IRIs and arrays. -- **`throw_not_found`**: Boolean (default: `false`) - When `true`, propagate exceptions for resources - that cannot be found. Use `fetch_data: true` when the converter must check that the resource exists. + exceptions instead of logging them. With the default Symfony exception mapping, this returns + HTTP 400. This applies to both single IRIs and arrays. +- **`throw_not_found`**: Boolean (default: `false`) - When `true`, propagate exceptions for + resources that cannot be found. Use `fetch_data: true` when the converter must check that the + resource exists. For example, to reject malformed IRIs in an `IriFilter` parameter: diff --git a/core/graphql.md b/core/graphql.md index 8f7110a8d8e..1807226aa81 100644 --- a/core/graphql.md +++ b/core/graphql.md @@ -1343,8 +1343,13 @@ To get the next page, you would add the `endCursor` from the current page as the ```graphql { - offers(first: 10, after: "endCursor") { - } + offers(first: 10, after: "endCursor") { + edges { + node { + id + } + } + } } ``` @@ -1353,8 +1358,13 @@ parameter. ```graphql { - offers(last: 10, before: "startCursor") { - } + offers(last: 10, before: "startCursor") { + edges { + node { + id + } + } + } } ```