diff --git a/core/openapi.md b/core/openapi.md index 0f829740688..c29b020ed5d 100644 --- a/core/openapi.md +++ b/core/openapi.md @@ -924,6 +924,32 @@ return [ > **must** be set according to the > [OpenID Connect specification](https://openid.net/specs/openid-connect-core-1_0.html). +## Sending Credentials with Swagger UI Requests + +When your API is deployed behind a proxy that uses cookie-based authentication (e.g. Cloudflare +Access), Swagger UI's requests may be rejected because the authentication cookie is not forwarded by +default. Enabling `withCredentials` adds a `requestInterceptor` to SwaggerUIBundle that sets +`credentials: 'include'` on every outgoing request, ensuring cookies are sent alongside token and +CORS requests. + +### Sending Credentials with Swagger UI Requests using Symfony + +> [!NOTE] This feature is only available with Laravel. You're welcome to contribute the Symfony +> implementation [on GitHub](https://github.com/api-platform/core). + +### Sending Credentials with Swagger UI Requests using Laravel + +```php + [ + 'with_credentials' => true, + ], +]; +``` + ## Info Object The [info object](https://swagger.io/specification/#info-object) provides metadata about the API diff --git a/core/serialization.md b/core/serialization.md index 82f21619a1f..7da6c3ba4c0 100644 --- a/core/serialization.md +++ b/core/serialization.md @@ -675,6 +675,93 @@ App\ApiResource\Person: +### Collection Getters and readableLink + +When `readableLink: false` is set on a property whose getter returns a bare `array` (no element type), +the Symfony PropertyInfo component resolves the type as `array`. Because the element class is +unknown, API Platform cannot determine that the items are API resources and falls back to embedding +them instead of serializing them as IRIs. + +This is a configuration issue, not a bug. Provide the element type using one of the following +approaches. + +**PHPDoc `@return` annotation** + +```php +cars->getValues(); + } +} +``` + +**`ApiProperty` `nativeType` parameter (API Platform >= 4.2)** + +```php +cars->getValues(); + } +} +``` + +**Typed Doctrine collection** + +Return `Collection` instead of a plain `array`. PropertyInfo reads the generic type parameter +and resolves the element class automatically. + +```php +cars; + } +} +``` + +For more details see [#8179](https://github.com/api-platform/core/issues/8179). + ### Plain Identifiers for Symfony Instead of sending an IRI to set a relation, you may want to send a plain identifier. To do so, you