diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8df4d3c..7d61e49 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -30,8 +30,8 @@ jobs:
api-platform:
# Only API Platform supported versions
- '^2.6'
- - '^2.7@rc'
- - '^3.0@rc'
+ - '^2.7'
+ - '^3.0'
include:
- php: '8.1'
symfony: '5.4.*'
@@ -49,15 +49,15 @@ jobs:
- symfony: '6.1.*'
php: '8.0'
# API Platform 3.0 requires PHP >= 8.1 and Symfony >= 6.1.*
- - api-platform: '^3.0@rc'
+ - api-platform: '^3.0'
php: '7.4'
- - api-platform: '^3.0@rc'
+ - api-platform: '^3.0'
php: '8.0'
- - api-platform: '^3.0@rc'
+ - api-platform: '^3.0'
symfony: '4.4.*'
- - api-platform: '^3.0@rc'
+ - api-platform: '^3.0'
symfony: '5.4.*'
- - api-platform: '^3.0@rc'
+ - api-platform: '^3.0'
symfony: '6.0.*'
fail-fast: false
env:
diff --git a/config/api_platform.xml b/config/api_platform.xml
index 5cca60f..8d2ff73 100644
--- a/config/api_platform.xml
+++ b/config/api_platform.xml
@@ -16,6 +16,8 @@
class="CoopTilleuls\ForgotPasswordBundle\Bridge\ApiPlatform\OpenApi\OpenApiFactory">
+ %coop_tilleuls_forgot_password.user_authorized_fields%
+ %coop_tilleuls_forgot_password.user_password_field%
diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php
index fc2458a..b7a3b6b 100644
--- a/features/bootstrap/FeatureContext.php
+++ b/features/bootstrap/FeatureContext.php
@@ -485,7 +485,10 @@ public function iShouldGetAnOpenApiDocumentationUpdated(): void
'required' => ['email'],
'properties' => [
'email' => [
- 'type' => 'string',
+ 'oneOf' => [
+ ['type' => 'string'],
+ ['type' => 'integer'],
+ ],
],
],
],
diff --git a/src/Bridge/ApiPlatform/OpenApi/AbstractOpenApiFactory.php b/src/Bridge/ApiPlatform/OpenApi/AbstractOpenApiFactory.php
index c2cc3b8..be68a91 100644
--- a/src/Bridge/ApiPlatform/OpenApi/AbstractOpenApiFactory.php
+++ b/src/Bridge/ApiPlatform/OpenApi/AbstractOpenApiFactory.php
@@ -30,14 +30,18 @@ abstract class AbstractOpenApiFactory
{
protected $decorated;
protected $router;
+ protected $authorizedFields;
+ protected $passwordField;
/**
* @param LegacyOpenApiFactoryInterface|OpenApiFactoryInterface $decorated
*/
- public function __construct($decorated, RouterInterface $router)
+ public function __construct($decorated, RouterInterface $router, array $authorizedFields, string $passwordField)
{
$this->decorated = $decorated;
$this->router = $router;
+ $this->authorizedFields = $authorizedFields;
+ $this->passwordField = $passwordField;
}
public function __invoke(array $context = [])
@@ -49,9 +53,9 @@ public function __invoke(array $context = [])
$schemas['ForgotPassword:reset'] = new \ArrayObject([
'type' => 'object',
- 'required' => ['password'],
+ 'required' => [$this->passwordField],
'properties' => [
- 'password' => [
+ $this->passwordField => [
'type' => 'string',
],
],
@@ -63,10 +67,13 @@ public function __invoke(array $context = [])
$schemas['ForgotPassword:request'] = new \ArrayObject([
'type' => 'object',
- 'required' => ['email'],
+ 'required' => [$this->authorizedFields[0]], // get the first authorized field for reference
'properties' => [
- 'email' => [
- 'type' => 'string',
+ $this->authorizedFields[0] => [
+ 'oneOf' => [
+ ['type' => 'string'],
+ ['type' => 'integer'],
+ ],
],
],
]);
diff --git a/src/Bridge/ApiPlatform/OpenApi/OpenApiFactory.php b/src/Bridge/ApiPlatform/OpenApi/OpenApiFactory.php
index 8516c79..c6db7b5 100644
--- a/src/Bridge/ApiPlatform/OpenApi/OpenApiFactory.php
+++ b/src/Bridge/ApiPlatform/OpenApi/OpenApiFactory.php
@@ -22,9 +22,9 @@
if (interface_exists(OpenApiFactoryInterface::class)) {
final class OpenApiFactory extends AbstractOpenApiFactory implements OpenApiFactoryInterface
{
- public function __construct(OpenApiFactoryInterface $decorated, RouterInterface $router)
+ public function __construct(OpenApiFactoryInterface $decorated, RouterInterface $router, array $authorizedFields, string $passwordField)
{
- parent::__construct($decorated, $router);
+ parent::__construct($decorated, $router, $authorizedFields, $passwordField);
}
public function __invoke(array $context = []): OpenApi
@@ -35,9 +35,9 @@ public function __invoke(array $context = []): OpenApi
} else {
final class OpenApiFactory extends AbstractOpenApiFactory implements LegacyOpenApiFactoryInterface
{
- public function __construct(LegacyOpenApiFactoryInterface $decorated, RouterInterface $router)
+ public function __construct(LegacyOpenApiFactoryInterface $decorated, RouterInterface $router, array $authorizedFields, string $passwordField)
{
- parent::__construct($decorated, $router);
+ parent::__construct($decorated, $router, $authorizedFields, $passwordField);
}
public function __invoke(array $context = []): LegacyOpenApi