Skip to content

Commit

Permalink
Merge pull request #20 from npo-sites-audio/bugfix/use-configured-col…
Browse files Browse the repository at this point in the history
…umn-name-to-retrieve-example-data

fix: use configured column name instead of key to retrieve example data
  • Loading branch information
JaZo authored Oct 10, 2024
2 parents a20b160 + 9b7352b commit 853052b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
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

0 comments on commit 853052b

Please sign in to comment.