Comments (6)
As workaround, I rewrite decorator
<?php
declare(strict_types=1);
namespace App\OpenApi;
use ApiPlatform\Core\OpenApi\Factory\OpenApiFactoryInterface;
use ApiPlatform\Core\OpenApi\OpenApi;
use ApiPlatform\Core\OpenApi\Model;
final class ForgotPasswordDecorator implements OpenApiFactoryInterface
{
public function __construct(
private OpenApiFactoryInterface $decorated
) {}
public function __invoke(array $context = []): OpenApi
{
$openApi = ($this->decorated)($context);
$schemas = $openApi->getComponents()->getSchemas();
$schemas['ForgotPassword:reset'] = new \ArrayObject([
'type' => 'object',
'required' => ['password'],
'properties' => [
'password' => [
'type' => 'string',
],
],
]);
$schemas['ForgotPassword:validate'] = new \ArrayObject([
'type' => 'object',
]);
$schemas['ForgotPassword:request'] = new \ArrayObject([
'type' => 'object',
'required' => ['email'],
'properties' => [
'email' => [
'type' => 'string',
],
],
]);
$pathItem = new Model\PathItem(
ref: 'ForgotPassword',
post: new Model\Operation(
operationId: 'postForgotPassword',
tags: ['Forgot password'],
responses: [
204 => [
'description' => 'Valid email address, no matter if user exists or not',
],
400 => [
'description' => 'Missing email parameter or invalid format',
],
],
summary: 'Generates a token and send email',
requestBody: new Model\RequestBody(
description: 'Request a new password',
content: new \ArrayObject([
'application/json' => [
'schema' => [
'$ref' => '#/components/schemas/ForgotPassword:request',
],
],
]),
),
),
);
$openApi->getPaths()->addPath('/forgot-password/', $pathItem);
$pathItem = new Model\PathItem(
ref: 'ForgotPassword',
get: new Model\Operation(
operationId: 'getForgotPassword',
tags: ['Forgot password'],
responses: [
200 => [
'description' => 'Authenticated user',
'content' => [
'application/json' => [
'schema' => [
'$ref' => '#/components/schemas/ForgotPassword:validate',
],
],
],
],
404 => [
'description' => 'Token not found or expired',
],
],
summary: 'Validates token',
parameters: [
[
'name' => 'token',
'in' => 'path',
'required' => true,
'schema' => [
'type' => 'string',
],
],
]
),
post: new Model\Operation(
operationId: 'postForgotPasswordToken',
tags: ['Forgot password'],
responses: [
204 => [
'description' => 'Email address format valid, no matter if user exists or not',
],
400 => [
'description' => 'Missing password parameter',
],
404 => [
'description' => 'Token not found',
],
],
summary: 'Resets user password from token',
parameters: [
[
'name' => 'token',
'in' => 'path',
'required' => true,
'schema' => [
'type' => 'string',
],
],
],
requestBody: new Model\RequestBody(
description: 'Reset password',
content: new \ArrayObject([
'application/json' => [
'schema' => [
'$ref' => '#/components/schemas/ForgotPassword:reset',
],
],
]),
),
),
);
$openApi->getPaths()->addPath('/forgot-password/{token}', $pathItem);
return $openApi;
}
}
`
Documentation is well generated
from cooptilleulsforgotpasswordbundle.
from cooptilleulsforgotpasswordbundle.
Thanks @acassan,
Could you open a PR to fix it on dev-main, please? But be careful: the code is still compatible with PHP7
from cooptilleulsforgotpasswordbundle.
PR Opened, let me know, I tried to write with PHP7 compat
from cooptilleulsforgotpasswordbundle.
Thank you @acassan, I've merged your PR on main. Could you try it on your project and tell me it's working as expected, please?
from cooptilleulsforgotpasswordbundle.
Tagged as v1.3.5
Thank you @acassan!
from cooptilleulsforgotpasswordbundle.
Related Issues (20)
- Issue with naming of token and tokenValue parameter HOT 6
- Follow Symfony Bundles best practices
- Release 1.4.5 has BC breaks HOT 3
- Dispatches an event when the user is not found
- overriding post forgot password doesn't work HOT 1
- Not work with PHP 8.2 HOT 2
- Method setUser() is not compatible with method HOT 1
- Can the endpoint documentation be overwritten? HOT 3
- [Documentation] Wrong call from Kernel Request Event HOT 1
- How can we perform password validation? HOT 2
- Getting a 204 without a response or any other logs HOT 3
- Minutes of expiry date fixed to numeric representation of the current month HOT 1
- Why does `GET /forgot_password/{tokenValue}` return the entire user? HOT 3
- JSON validation on `POST /forgot_password/{tokenValue}` is incorrect
- 204 Return on inexisting user HOT 2
- Cannot autowire service "App\EventSubscriber\ForgotPasswordEventSubscriber": argument "$userManager" HOT 2
- Encode password HOT 1
- Symfony 6 compatibility HOT 2
- Hardcoded paths HOT 2
- API Platform 3.0 compatibility
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cooptilleulsforgotpasswordbundle.