Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content en param filter #366

Open
oussaka opened this issue Feb 23, 2021 · 2 comments
Open

content en param filter #366

oussaka opened this issue Feb 23, 2021 · 2 comments

Comments

@oussaka
Copy link
Contributor

oussaka commented Feb 23, 2021

Bonjour,

Dans l'operation GET /api/comments ,dans swagger, il manque le parameter Filter content.

Exemple de code qui l'ajoute dans swagger :

/**
 * @ApiResource(
 * )
 * @ApiFilter(CommentFilter::class, properties={"content"})
 */
class CommentResource extends CommentData
{
}
<?php

namespace App\Http\Api\Filter;

use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\AbstractFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;

class CommentFilter extends AbstractFilter
{
    public function __construct(ManagerRegistry $managerRegistry, array $properties = [], NameConverterInterface $nameConverter = null)
    {
        parent::__construct($managerRegistry, null, null, $properties, $nameConverter);
    }

    protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null)
    {
    }

    public function getDescription(string $resourceClass): array
    {
        if (!$this->properties) {
            return [];
        }

        return [
            'content' => [
                'property' => 'content',
                'type' => 'string',
                'required' => true,
                'openapi' => [
                    'description' => 'Content id',
                ],
            ],
        ];
    }
}
@Grafikart
Copy link
Owner

Normalement ce n'est pas nécessaire car on n'envoie que le strict nécessaire lors de la modification.
https://github.com/Grafikart/Grafikart.fr/blob/master/src/Http/Api/DataPersister/CommentPersister.php#L53

@oussaka
Copy link
Contributor Author

oussaka commented Feb 24, 2021

C'est tout simplement de ce champ (dans parameters Filters) dont je parle. Il est require pour GET /api/comments , on doit donc l'ajouter dans Swagger.

Capture du 2021-02-24 06-27-16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants