diff --git a/src/AutoDocServiceProvider.php b/src/AutoDocServiceProvider.php index ec4a2764..f985f9d0 100644 --- a/src/AutoDocServiceProvider.php +++ b/src/AutoDocServiceProvider.php @@ -7,7 +7,7 @@ class AutoDocServiceProvider extends ServiceProvider { - public function boot() + public function boot(): void { $this->mergeConfigFrom(__DIR__ . '/../config/auto-doc.php', 'auto-doc'); diff --git a/src/Drivers/BaseDriver.php b/src/Drivers/BaseDriver.php index ddd18797..7fd70a09 100644 --- a/src/Drivers/BaseDriver.php +++ b/src/Drivers/BaseDriver.php @@ -6,7 +6,7 @@ abstract class BaseDriver implements SwaggerDriverInterface { - protected $tempFilePath; + protected string $tempFilePath; public function __construct() { diff --git a/src/Drivers/LocalDriver.php b/src/Drivers/LocalDriver.php index c2801563..128adc80 100755 --- a/src/Drivers/LocalDriver.php +++ b/src/Drivers/LocalDriver.php @@ -7,7 +7,7 @@ class LocalDriver extends BaseDriver { - protected $prodFilePath; + protected string $prodFilePath; public function __construct() { diff --git a/src/Drivers/RemoteDriver.php b/src/Drivers/RemoteDriver.php index c7605463..ca92166d 100755 --- a/src/Drivers/RemoteDriver.php +++ b/src/Drivers/RemoteDriver.php @@ -7,8 +7,8 @@ class RemoteDriver extends BaseDriver { - protected $key; - protected $remoteUrl; + protected string $key; + protected string $remoteUrl; public function __construct() { diff --git a/src/Drivers/StorageDriver.php b/src/Drivers/StorageDriver.php index b0b142f9..0166f2f6 100755 --- a/src/Drivers/StorageDriver.php +++ b/src/Drivers/StorageDriver.php @@ -3,13 +3,14 @@ namespace RonasIT\Support\AutoDoc\Drivers; use Illuminate\Contracts\Filesystem\FileNotFoundException; +use Illuminate\Contracts\Filesystem\Filesystem; use Illuminate\Support\Facades\Storage; use RonasIT\Support\AutoDoc\Exceptions\MissedProductionFilePathException; class StorageDriver extends BaseDriver { - protected $disk; - protected $prodFilePath; + protected Filesystem $disk; + protected string $prodFilePath; public function __construct() { diff --git a/src/Http/Controllers/AutoDocController.php b/src/Http/Controllers/AutoDocController.php index 6b23f483..33807873 100644 --- a/src/Http/Controllers/AutoDocController.php +++ b/src/Http/Controllers/AutoDocController.php @@ -2,15 +2,18 @@ namespace RonasIT\Support\AutoDoc\Http\Controllers; +use Illuminate\Contracts\View\View; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Illuminate\Http\Response; use Illuminate\Routing\Controller as BaseController; use RonasIT\Support\AutoDoc\Services\SwaggerService; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class AutoDocController extends BaseController { - protected $service; - protected $documentationViewer; + protected SwaggerService $service; + protected string $documentationViewer; public function __construct() { @@ -18,14 +21,14 @@ public function __construct() $this->documentationViewer = config('auto-doc.documentation_viewer'); } - public function documentation() + public function documentation(): JsonResponse { $documentation = $this->service->getDocFileContent(); return response()->json($documentation); } - public function index() + public function index(): View|Response { $currentEnvironment = config('app.env'); @@ -36,7 +39,7 @@ public function index() return response('Forbidden.', 403); } - public function getFile(Request $request, $file) + public function getFile(Request $request, $file): Response { $filePath = __DIR__ . "/../../../resources/assets/{$this->documentationViewer}/" . $file; diff --git a/src/Http/Middleware/AutoDocMiddleware.php b/src/Http/Middleware/AutoDocMiddleware.php index a048448d..e0472113 100644 --- a/src/Http/Middleware/AutoDocMiddleware.php +++ b/src/Http/Middleware/AutoDocMiddleware.php @@ -16,7 +16,7 @@ public function handle($request, Closure $next) { $response = $next($request); - if ((config('app.env') == 'testing') && !self::$skipped && !empty($request->route())) { + if ((config('app.env') === 'testing') && !self::$skipped && !empty($request->route())) { app(SwaggerService::class)->addData($request, $response); } diff --git a/src/Interfaces/SwaggerDriverInterface.php b/src/Interfaces/SwaggerDriverInterface.php index 45ba0fc7..f0e18408 100644 --- a/src/Interfaces/SwaggerDriverInterface.php +++ b/src/Interfaces/SwaggerDriverInterface.php @@ -6,20 +6,18 @@ interface SwaggerDriverInterface { /** * Save temporary data - * - * @param array $data */ - public function saveTmpData($data); + public function saveTmpData(array $data): void; /** * Get temporary data */ - public function getTmpData(); + public function getTmpData(): void; /** * Save production data */ - public function saveData(); + public function saveData(): void; /** * Get production documentation diff --git a/src/Services/SwaggerService.php b/src/Services/SwaggerService.php index f295b50b..c7c669a3 100755 --- a/src/Services/SwaggerService.php +++ b/src/Services/SwaggerService.php @@ -31,22 +31,22 @@ class SwaggerService public const SWAGGER_VERSION = '2.0'; - protected $driver; - protected $openAPIValidator; - - protected $data; - protected $config; - protected $container; - private $uri; - private $method; /** - * @var Request + * @var SwaggerDriverInterface|mixed */ - private $request; - private $item; - private $security; - - protected $ruleToTypeMap = [ + protected $driver; + protected SwaggerSpecValidator $openAPIValidator; + + protected ?array $data; + protected array $config; + protected Container $container; + private string $uri; + private string $method; + private Request $request; + private array $item; + private string $security; + + protected array $ruleToTypeMap = [ 'array' => 'object', 'boolean' => 'boolean', 'date' => 'date', @@ -57,7 +57,7 @@ class SwaggerService 'int' => 'integer' ]; - protected $booleanAnnotations = [ + protected array $booleanAnnotations = [ 'deprecated' ]; @@ -66,10 +66,9 @@ public function __construct(Container $container) $this->openAPIValidator = app(SwaggerSpecValidator::class); $this->initConfig(); - $this->setDriver(); - if (config('app.env') == 'testing') { + if (config('app.env') === 'testing') { $this->container = $container; $this->security = $this->config['security']; @@ -84,7 +83,7 @@ public function __construct(Container $container) } } - protected function initConfig() + protected function initConfig(): void { $this->config = config('auto-doc'); @@ -107,7 +106,7 @@ protected function initConfig() } } - protected function setDriver() + protected function setDriver(): void { $driver = $this->config['driver']; $className = Arr::get($this->config, "drivers.{$driver}.class"); @@ -168,40 +167,35 @@ protected function generateSecurityDefinition(): ?array ]; } - protected function generateSecurityDefinitionObject($type): array + protected function generateSecurityDefinitionObject(string $type): array { - switch ($type) { - case 'jwt': - return [ - 'type' => 'apiKey', - 'name' => 'authorization', - 'in' => 'header' - ]; - - case 'laravel': - return [ - 'type' => 'apiKey', - 'name' => 'Cookie', - 'in' => 'header' - ]; - default: - throw new WrongSecurityConfigException(); - } + return match ($type) { + 'jwt' => [ + 'type' => 'apiKey', + 'name' => 'authorization', + 'in' => 'header' + ], + 'laravel' => [ + 'type' => 'apiKey', + 'name' => 'Cookie', + 'in' => 'header' + ], + default => throw new WrongSecurityConfigException(), + }; } - public function addData(Request $request, $response) + public function addData(Request $request, $response): void { $this->request = $request; $this->prepareItem(); - $this->parseRequest(); $this->parseResponse($response); $this->driver->saveTmpData($this->data); } - protected function prepareItem() + protected function prepareItem(): void { $this->uri = "/{$this->getUri()}"; $this->method = strtolower($this->request->getMethod()); @@ -221,7 +215,7 @@ protected function prepareItem() $this->item = &$this->data['paths'][$this->uri][$this->method]; } - protected function getUri() + protected function getUri(): string { $uri = $this->request->route()->uri(); $basePath = preg_replace("/^\//", '', $this->config['basePath']); @@ -255,7 +249,7 @@ protected function getPathParams(): array return $result; } - protected function parseRequest() + protected function parseRequest(): void { $this->saveConsume(); $this->saveTags(); @@ -276,62 +270,68 @@ protected function parseRequest() $this->saveDescription($concreteRequest, $annotations); } - protected function markAsDeprecated(array $annotations) + protected function markAsDeprecated(array $annotations): void { $this->item['deprecated'] = Arr::get($annotations, 'deprecated', false); } - protected function saveResponseSchema(?array $content, int $code) + protected function saveResponseSchema(?array $content, string $definition): void { if (empty($content)) { return; } $schemaProperties = []; - $action = Str::ucfirst($this->getActionName($this->uri)); $schemaType = 'object'; if (array_is_list($content)) { - $schemaType = 'array'; - $types = []; + $this->saveListResponseDefinition($content, $schemaProperties); - foreach ($content as $value) { - $type = gettype($value); - if (!in_array($type, $types)) { - $types[] = $type; - $schemaProperties['items']['allOf'][]['type'] = $type; - } - } + $schemaType = 'array'; } else { - $properties = Arr::get( - $this->data['definitions'], - "{$this->method}{$action}{$code}ResponseObject.properties", - [] - ); + $this->saveObjectResponseDefinitions($definition, $content, $schemaProperties); + } - foreach ($content as $name => $value) { - $property = Arr::get($properties, $name, []); + $this->data['definitions'][$definition] = [ + 'type' => $schemaType, + 'properties' => $schemaProperties + ]; + } - if (is_null($value)) { - $property['nullable'] = true; - } else { - $property['type'] = gettype($value); - } + protected function saveObjectResponseDefinitions(string $definition, array $content, array &$schemaProperties): void + { + $properties = Arr::get($this->data['definitions'], "{$definition}.properties", []); - $schemaProperties[$name] = $property; + foreach ($content as $name => $value) { + $property = Arr::get($properties, $name, []); + + if (is_null($value)) { + $property['nullable'] = true; + } else { + $property['type'] = gettype($value); } + + $schemaProperties[$name] = $property; } + } - $this->data['definitions']["{$this->method}{$action}{$code}ResponseObject"] = [ - 'type' => $schemaType, - 'properties' => $schemaProperties - ]; + protected function saveListResponseDefinition(array $content, array &$schemaProperties): void + { + $types = []; + + foreach ($content as $value) { + $type = gettype($value); + + if (!in_array($type, $types)) { + $types[] = $type; + $schemaProperties['items']['allOf'][]['type'] = $type; + } + } } - protected function parseResponse($response) + protected function parseResponse($response): void { $produceList = $this->data['paths'][$this->uri][$this->method]['produces']; - $produce = $response->headers->get('Content-type'); if (is_null($produce)) { @@ -343,23 +343,18 @@ protected function parseResponse($response) } $responses = $this->item['responses']; - $responseExampleLimitCount = config('auto-doc.response_example_limit_count'); - $content = json_decode($response->getContent(), true); - if (!empty($responseExampleLimitCount)) { - if (!empty($content['data'])) { - $limitedResponseData = array_slice($content['data'], 0, $responseExampleLimitCount, true); - $content['data'] = $limitedResponseData; - $content['to'] = count($limitedResponseData); - $content['total'] = count($limitedResponseData); - } + if (!empty($responseExampleLimitCount) && !empty($content['data'])) { + $limitedResponseData = array_slice($content['data'], 0, $responseExampleLimitCount, true); + $content['data'] = $limitedResponseData; + $content['to'] = count($limitedResponseData); + $content['total'] = count($limitedResponseData); } if (!empty($content['exception'])) { $uselessKeys = array_keys(Arr::except($content, ['message'])); - $content = Arr::except($content, $uselessKeys); } @@ -373,25 +368,25 @@ protected function parseResponse($response) ); } - $this->saveResponseSchema($content, $code); + $action = Str::ucfirst($this->getActionName($this->uri)); + $definition = "#/definitions/{$this->method}{$action}{$code}ResponseObject"; - if (is_array($this->item['responses'][$code])) { - $action = Str::ucfirst($this->getActionName($this->uri)); - $definition = "#/definitions/{$this->method}{$action}{$code}ResponseObject"; + $this->saveResponseSchema($content, $definition); + if (is_array($this->item['responses'][$code])) { $this->item['responses'][$code]['schema']['$ref'] = $definition; } } - protected function saveExample($code, $content, $produce) + protected function saveExample(int $code, string $content, string $produce): void { $description = $this->getResponseDescription($code); + $explodedContentType = explode('/', $produce); $availableContentTypes = [ 'application', 'text', 'image', ]; - $explodedContentType = explode('/', $produce); if (in_array($explodedContentType[0], $availableContentTypes)) { $this->item['responses'][$code] = $this->makeResponseExample($content, $produce, $description); @@ -400,7 +395,7 @@ protected function saveExample($code, $content, $produce) } } - protected function makeResponseExample($content, $mimeType, $description = ''): array + protected function makeResponseExample(string $content, string $mimeType, string $description = ''): array { $responseExample = ['description' => $description]; @@ -415,14 +410,13 @@ protected function makeResponseExample($content, $mimeType, $description = ''): return $responseExample; } - protected function saveParameters($request, array $annotations) + protected function saveParameters($request, array $annotations): void { $formRequest = new $request(); $formRequest->setUserResolver($this->request->getUserResolver()); $formRequest->setRouteResolver($this->request->getRouteResolver()); $rules = method_exists($formRequest, 'rules') ? $this->prepareRules($formRequest->rules()) : []; $attributes = method_exists($formRequest, 'attributes') ? $formRequest->attributes() : []; - $actionName = $this->getActionName($this->uri); if (in_array($this->method, ['get', 'delete'])) { @@ -451,7 +445,7 @@ protected function prepareRules(array $rules): array return $preparedRules; } - protected function getRuleAsString($rule): string + protected function getRuleAsString(object|string $rule): string { if (is_object($rule)) { if (method_exists($rule, '__toString')) { @@ -459,7 +453,6 @@ protected function getRuleAsString($rule): string } $shortName = Str::afterLast(get_class($rule), '\\'); - $ruleName = preg_replace('/Rule$/', '', $shortName); return Str::snake($ruleName); @@ -468,11 +461,10 @@ protected function getRuleAsString($rule): string return $rule; } - protected function saveGetRequestParameters($rules, array $attributes, array $annotations) + protected function saveGetRequestParameters(array $rules, array $attributes, array $annotations): void { foreach ($rules as $parameter => $rule) { $validation = explode('|', $rule); - $description = Arr::get($annotations, $parameter); if (empty($description)) { @@ -480,7 +472,7 @@ protected function saveGetRequestParameters($rules, array $attributes, array $an } $existedParameter = Arr::first($this->item['parameters'], function ($existedParameter) use ($parameter) { - return $existedParameter['name'] == $parameter; + return $existedParameter['name'] === $parameter; }); if (empty($existedParameter)) { @@ -490,6 +482,7 @@ protected function saveGetRequestParameters($rules, array $attributes, array $an 'description' => $description, 'type' => $this->getParameterType($validation) ]; + if (in_array('required', $validation)) { $parameterDefinition['required'] = true; } @@ -499,7 +492,12 @@ protected function saveGetRequestParameters($rules, array $attributes, array $an } } - protected function savePostRequestParameters($actionName, $rules, array $attributes, array $annotations) + protected function savePostRequestParameters( + string $actionName, + array $rules, + array $attributes, + array $annotations + ): void { if ($this->requestHasMoreProperties($actionName)) { if ($this->requestHasBody()) { @@ -518,7 +516,7 @@ protected function savePostRequestParameters($actionName, $rules, array $attribu } } - protected function saveDefinitions($objectName, $rules, $attributes, array $annotations) + protected function saveDefinitions(string $objectName, array $rules, array $attributes, array $annotations): void { $data = [ 'type' => 'object', @@ -550,7 +548,6 @@ protected function getParameterType(array $validation): string { $validationRules = $this->ruleToTypeMap; $validationRules['email'] = 'string'; - $parameterType = 'string'; foreach ($validation as $item) { @@ -562,14 +559,20 @@ protected function getParameterType(array $validation): string return $parameterType; } - protected function saveParameterType(&$data, $parameter, $parameterType) + protected function saveParameterType(array &$data, string $parameter, string $parameterType): void { $data['properties'][$parameter] = [ 'type' => $parameterType ]; } - protected function saveParameterDescription(&$data, $parameter, array $rulesArray, array $attributes, array $annotations) + protected function saveParameterDescription( + array &$data, + string $parameter, + array $rulesArray, + array $attributes, + array $annotations + ): void { $description = Arr::get($annotations, $parameter); @@ -580,7 +583,7 @@ protected function saveParameterDescription(&$data, $parameter, array $rulesArra $data['properties'][$parameter]['description'] = $description; } - protected function requestHasMoreProperties($actionName): bool + protected function requestHasMoreProperties(string $actionName): bool { $requestParametersCount = count($this->request->all()); @@ -598,28 +601,25 @@ protected function requestHasBody(): bool $parameters = $this->data['paths'][$this->uri][$this->method]['parameters']; $bodyParamExisted = Arr::where($parameters, function ($value) { - return $value['name'] == 'body'; + return $value['name'] === 'body'; }); return empty($bodyParamExisted); } - public function getConcreteRequest() + public function getConcreteRequest(): mixed { $controller = $this->request->route()->getActionName(); - if ($controller == 'Closure') { + if ($controller === 'Closure') { return null; } $explodedController = explode('@', $controller); - $class = $explodedController[0]; $method = $explodedController[1]; - $instance = app($class); $route = $this->request->route(); - $parameters = $this->resolveClassMethodDependencies( $route->parametersWithoutNulls(), $instance, @@ -631,7 +631,7 @@ public function getConcreteRequest() }); } - public function saveConsume() + public function saveConsume(): void { $consumeList = $this->data['paths'][$this->uri][$this->method]['consumes']; $consume = $this->request->header('Content-Type'); @@ -641,18 +641,16 @@ public function saveConsume() } } - public function saveTags() + public function saveTags(): void { $tagIndex = 1; - $explodedUri = explode('/', $this->uri); - $tag = Arr::get($explodedUri, $tagIndex); $this->item['tags'] = [$tag]; } - public function saveDescription($request, array $annotations) + public function saveDescription($request, array $annotations): void { $this->item['summary'] = $this->getSummary($request, $annotations); @@ -663,14 +661,14 @@ public function saveDescription($request, array $annotations) } } - protected function saveSecurity() + protected function saveSecurity(): void { if ($this->requestSupportAuth()) { $this->addSecurityToOperation(); } } - protected function addSecurityToOperation() + protected function addSecurityToOperation(): void { $security = &$this->data['paths'][$this->uri][$this->method]['security']; @@ -681,7 +679,7 @@ protected function addSecurityToOperation() } } - protected function getSummary($request, array $annotations) + protected function getSummary($request, array $annotations): ?string { $summary = Arr::get($annotations, 'summary'); @@ -706,21 +704,19 @@ protected function requestSupportAuth(): bool return !empty($header); } - protected function parseRequestName($request) + protected function parseRequestName($request): string { $explodedRequest = explode('\\', $request); $requestName = array_pop($explodedRequest); $summaryName = str_replace('Request', '', $requestName); - $underscoreRequestName = $this->camelCaseToUnderScore($summaryName); return preg_replace('/[_]/', ' ', $underscoreRequestName); } - protected function getResponseDescription($code) + protected function getResponseDescription(int $code): string { $defaultDescription = Response::$statusTexts[$code]; - $request = $this->getConcreteRequest(); if (empty($request)) { @@ -728,7 +724,6 @@ protected function getResponseDescription($code) } $annotations = $this->getClassAnnotations($request); - $localDescription = Arr::get($annotations, "_{$code}"); if (!empty($localDescription)) { @@ -738,7 +733,7 @@ protected function getResponseDescription($code) return Arr::get($this->config, "defaults.code-descriptions.{$code}", $defaultDescription); } - protected function getActionName($uri): string + protected function getActionName(string $uri): string { $action = preg_replace('[\/]', '', $uri); @@ -749,7 +744,7 @@ protected function getActionName($uri): string * @deprecated method is not in use * @codeCoverageIgnore */ - protected function saveTempData() + protected function saveTempData(): void { $exportFile = Arr::get($this->config, 'files.temporary'); $data = json_encode($this->data); @@ -757,12 +752,12 @@ protected function saveTempData() file_put_contents($exportFile, $data); } - public function saveProductionData() + public function saveProductionData(): void { $this->driver->saveData(); } - public function getDocFileContent() + public function getDocFileContent(): array { $documentation = $this->driver->getDocumentation(); @@ -791,7 +786,7 @@ protected function camelCaseToUnderScore($input): string $ret = $matches[0]; foreach ($ret as &$match) { - $match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match); + $match = ($match === strtoupper($match)) ? strtolower($match) : lcfirst($match); } return implode('_', $ret); @@ -807,19 +802,17 @@ protected function generateExample($properties): array return $example; } - protected function replaceObjectValues($parameters): array + protected function replaceObjectValues(array $parameters): array { + $parameters = Arr::dot($parameters); + $returnParameters = []; $classNamesValues = [ File::class => '[uploaded_file]', ]; - $parameters = Arr::dot($parameters); - $returnParameters = []; - foreach ($parameters as $parameter => $value) { if (is_object($value)) { $class = get_class($value); - $value = Arr::get($classNamesValues, $class, $class); } @@ -832,11 +825,8 @@ protected function replaceObjectValues($parameters): array protected function getClassAnnotations($class): array { $reflection = new ReflectionClass($class); - $annotations = $reflection->getDocComment(); - $blocks = explode("\n", $annotations); - $result = []; foreach ($blocks as $block) { @@ -844,7 +834,6 @@ protected function getClassAnnotations($class): array $index = strpos($block, '@'); $block = substr($block, $index); $exploded = explode(' ', $block); - $paramName = str_replace('@', '', array_shift($exploded)); $paramValue = implode(' ', $exploded); @@ -864,7 +853,7 @@ protected function getClassAnnotations($class): array * this issue: https://github.com/OAI/OpenAPI-Specification/issues/229 * We hope swagger developers will resolve this problem in next release of Swagger OpenAPI * */ - protected function replaceNullValues($parameters, $types, &$example) + protected function replaceNullValues(array $parameters, array $types, array &$example): void { foreach ($parameters as $parameter => $value) { if (is_null($value) && array_key_exists($parameter, $types)) { @@ -877,7 +866,7 @@ protected function replaceNullValues($parameters, $types, &$example) } } - protected function getDefaultValueByType($type) + protected function getDefaultValueByType(string $type): mixed { $values = [ 'object' => 'null', diff --git a/src/Tests/AutoDocTestCaseTrait.php b/src/Tests/AutoDocTestCaseTrait.php index 77d3e6b3..317d8073 100644 --- a/src/Tests/AutoDocTestCaseTrait.php +++ b/src/Tests/AutoDocTestCaseTrait.php @@ -9,7 +9,7 @@ trait AutoDocTestCaseTrait /** * Disabling documentation collecting on current test */ - public function skipDocumentationCollecting() + public function skipDocumentationCollecting(): void { AutoDocMiddleware::$skipped = true; } diff --git a/src/Traits/GetDependenciesTrait.php b/src/Traits/GetDependenciesTrait.php index 8a049781..884c4c6b 100644 --- a/src/Traits/GetDependenciesTrait.php +++ b/src/Traits/GetDependenciesTrait.php @@ -11,7 +11,7 @@ trait GetDependenciesTrait { - protected function resolveClassMethodDependencies(array $parameters, $instance, $method) + protected function resolveClassMethodDependencies(array $parameters, object $instance, string $method): array { if (!method_exists($instance, $method)) { return $parameters; @@ -22,14 +22,14 @@ protected function resolveClassMethodDependencies(array $parameters, $instance, ); } - public function getDependencies(ReflectionFunctionAbstract $reflector) + public function getDependencies(ReflectionFunctionAbstract $reflector): array { return array_map(function ($parameter) { return $this->transformDependency($parameter); }, $reflector->getParameters()); } - protected function transformDependency(ReflectionParameter $parameter) + protected function transformDependency(ReflectionParameter $parameter): ?string { $class = $parameter->getClass(); @@ -40,7 +40,7 @@ protected function transformDependency(ReflectionParameter $parameter) return interface_exists($class->name) ? $this->getClassByInterface($class->name) : $class->name; } - protected function getClassByInterface($interfaceName) + protected function getClassByInterface(string $interfaceName): ?string { $bindings = Container::getInstance()->getBindings(); diff --git a/src/Validators/SwaggerSpecValidator.php b/src/Validators/SwaggerSpecValidator.php index 968a4193..f1e22108 100644 --- a/src/Validators/SwaggerSpecValidator.php +++ b/src/Validators/SwaggerSpecValidator.php @@ -20,9 +20,6 @@ use RonasIT\Support\AutoDoc\Exceptions\SpecValidation\MissingRefFileException; use RonasIT\Support\AutoDoc\Services\SwaggerService; -/** - * @property array $doc - */ class SwaggerSpecValidator { public const SCHEMA_TYPES = [ @@ -77,7 +74,7 @@ class SwaggerSpecValidator public const MIME_TYPE_MULTIPART_FORM_DATA = 'multipart/form-data'; public const MIME_TYPE_APPLICATION_URLENCODED = 'application/x-www-form-urlencoded'; - protected $doc; + protected array $doc; public function validate(array $doc): void { @@ -125,7 +122,6 @@ protected function validatePaths(): void $this->validateFieldsPresent(self::REQUIRED_FIELDS['operation'], $operationId); $this->validateFieldValue("{$operationId}.schemes", self::ALLOWED_VALUES['schemes']); - $this->validateParameters($operation, $path, $operationId); foreach ($operation['responses'] as $statusCode => $response) { @@ -154,7 +150,6 @@ protected function validateSecurityDefinitions(): void $parentId = "securityDefinitions.{$index}"; $this->validateFieldsPresent(self::REQUIRED_FIELDS['security_definition'], $parentId); - $this->validateFieldValue("{$parentId}.type", self::ALLOWED_VALUES['security_definition_type']); $this->validateFieldValue("{$parentId}.in", self::ALLOWED_VALUES['security_definition_in']); $this->validateFieldValue("{$parentId}.flow", self::ALLOWED_VALUES['security_definition_flow']);