Giter VIP home page Giter VIP logo

Comments (3)

vincentchalamon avatar vincentchalamon commented on September 27, 2024

Hi @WardVandevoort,

This bundle decorates the OpenApiFactory from API Platform (api_platform.openapi.factory) to document the its routes.

For your use-case, I advise you to decorate it too and add your own behavior: https://github.com/coopTilleuls/CoopTilleulsForgotPasswordBundle/blob/main/src/Bridge/ApiPlatform/OpenApi/AbstractOpenApiFactory.php

from cooptilleulsforgotpasswordbundle.

vincentchalamon avatar vincentchalamon commented on September 27, 2024

Closing as it's not a bug nor related to this bundle, and a solution has been found.

from cooptilleulsforgotpasswordbundle.

WardVandevoort avatar WardVandevoort commented on September 27, 2024

@vincentchalamon That's what I did, yet it is still showing the original documentation. How am I supposed to make my decorator overwrite the package's decorator?

public function __construct(private OpenApiFactoryInterface $decorated)
{
}

/**
 * @psalm-suppress PossiblyNullReference
 */
public function __invoke(array $context = []): OpenApi
{
    $openApi = ($this->decorated)($context);
    $schemas = $openApi->getComponents()->getSchemas();

    $schemas['ForgotPassword:reset'] = new \ArrayObject([
        'type' => 'object',
        'properties' => [
            'password' => [
                'type' => 'string',
                'example' => 'password',
            ],
            'confirm_password' => [
                'type' => 'string',
                'example' => 'password',
            ],
        ],
    ]);

    $pathItem = new Model\PathItem(
        ref: 'ForgotPassword',
        post: new Model\Operation(
            parameters: [new Model\Parameter(
                name: 'tokenValue',
                in: 'path',
                description: 'Token value',
                required: true,
            )],
            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: 'Validates token test',
            requestBody: new Model\RequestBody(
                description: 'Reset password',
                content: new \ArrayObject([
                    'application/json' => [
                        'schema' => [
                            '$ref' => '#/components/schemas/ForgotPassword:reset',
                        ],
                    ],
                ]),
            )
        )
    );
    $openApi->getPaths()->addPath('/api/users/password-reset/{tokenValue}', $pathItem);

    return $openApi;
}

from cooptilleulsforgotpasswordbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.