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

fix: use configured column name instead of key to retrieve example data #20

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Descriptors/Schema/Filters/Where.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@
use GoldSpecDigital\ObjectOrientedOAS\Objects\Example;
use GoldSpecDigital\ObjectOrientedOAS\Objects\Parameter;
use GoldSpecDigital\ObjectOrientedOAS\Objects\Schema as OASchema;
use LaravelJsonApi\Contracts\Schema\Filter;

class Where extends FilterDescriptor
{
/**
* @var \LaravelJsonApi\Eloquent\Filters\Where
*/
protected Filter $filter;

/**
* @todo Pay attention to isSingular
*/
public function filter(): array
{
$key = $this->filter->key();
$examples = collect($this->generator->resources()
->resources($this->route->schema()::model()))
->pluck($key)
->pluck($this->filter->column())
->filter()
->map(function ($f) {
if (function_exists('enum_exists') && $f instanceof \UnitEnum) {
Expand Down
9 changes: 7 additions & 2 deletions src/Descriptors/Schema/Filters/WhereIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@
use GoldSpecDigital\ObjectOrientedOAS\Objects\Example;
use GoldSpecDigital\ObjectOrientedOAS\Objects\Parameter;
use GoldSpecDigital\ObjectOrientedOAS\Objects\Schema;
use LaravelJsonApi\Contracts\Schema\Filter;
use LaravelJsonApi\Eloquent\Filters\WhereNotIn;
use LaravelJsonApi\Eloquent\Filters\WherePivotNotIn;

class WhereIn extends FilterDescriptor
{
/**
* @var \LaravelJsonApi\Eloquent\Filters\WhereIn
*/
protected Filter $filter;

/**
* @todo Pay attention to delimiter
*/
public function filter(): array
{
$key = $this->filter->key();
$examples = collect($this->generator->resources()
->resources($this->route->schema()::model()))
->pluck($key)
->pluck($this->filter->column())
->filter()
->map(function ($f) {
if (function_exists('enum_exists') && $f instanceof \UnitEnum) {
Expand Down
Loading