Skip to content

Commit

Permalink
Merge pull request #84 from maikschneider/patch-1
Browse files Browse the repository at this point in the history
Make OpenApi specification file valid
  • Loading branch information
kszymukowicz authored Apr 28, 2024
2 parents d89ff99 + 203e32f commit f7b3c1e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Classes/Service/OpenApiBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Exception;
use GoldSpecDigital\ObjectOrientedOAS\Exceptions\InvalidArgumentException as OasInvalidArgumentException;
use GoldSpecDigital\ObjectOrientedOAS\Objects\Components;
use GoldSpecDigital\ObjectOrientedOAS\Objects\Info;
use GoldSpecDigital\ObjectOrientedOAS\Objects\MediaType;
use GoldSpecDigital\ObjectOrientedOAS\Objects\Operation;
use GoldSpecDigital\ObjectOrientedOAS\Objects\Parameter;
Expand Down Expand Up @@ -63,12 +64,23 @@ public static function build(array $apiResources): OpenApi

return OpenApi::create()
->openapi(OpenApi::OPENAPI_3_0_2)
->info(self::getInfo())
->servers(...self::getServers())
->tags(...self::getTags($apiResources))
->paths(...self::getPaths($apiResources))
->components(self::$components);
}

private static function getInfo(): Info
{
$siteConfig = SiteService::getCurrent()->getConfiguration();
$info = new Info();
return $info
->title($siteConfig['routeEnhancers']['T3api']['title'] ?? '')
->description($siteConfig['routeEnhancers']['T3api']['description'] ?? '')
->version($siteConfig['routeEnhancers']['T3api']['version'] ?? '');
}

/**
* @return array
*/
Expand Down Expand Up @@ -229,10 +241,12 @@ protected static function getFilterParametersForOperation(OperationInterface $op

/** @var Parameter $filterParameter */
foreach ($filterParameters as $filterParameter) {
$parameters[] = $filterParameter->in(Parameter::IN_QUERY);
$parameters[$filterParameter->name] = $filterParameter->in(Parameter::IN_QUERY);
}
}

sort($parameters);

return $parameters;
}

Expand Down

0 comments on commit f7b3c1e

Please sign in to comment.