From b71f766760b6cc17ffcbdb8d90be09af9ffbe3d0 Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Sun, 6 Apr 2025 10:28:43 -0400 Subject: [PATCH 1/2] Fix custom array schema --- src/Lib/OpenApi/SchemaProperty.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Lib/OpenApi/SchemaProperty.php b/src/Lib/OpenApi/SchemaProperty.php index 5f5b3fa9..83898c51 100644 --- a/src/Lib/OpenApi/SchemaProperty.php +++ b/src/Lib/OpenApi/SchemaProperty.php @@ -122,6 +122,10 @@ public function toArray(): array $vars['enum'] = array_values($vars['enum']); } + if (isset($vars['items'])) { + $vars['items'] = (object) reset($vars['items']); + } + return $vars; } From 798032e929c33235764d03aee8ce210e834b2064 Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Sun, 6 Apr 2025 10:32:17 -0400 Subject: [PATCH 2/2] lint --- src/Command/CommandTrait.php | 2 +- src/Command/InstallCommand.php | 2 +- .../Attribute/AbstractOpenApiParameter.php | 2 +- src/Lib/Attribute/AbstractSchemaProperty.php | 2 +- src/Lib/Attribute/AttributeFactory.php | 2 +- src/Lib/Attribute/OpenApiHeader.php | 8 ++-- src/Lib/Attribute/OpenApiPaginator.php | 2 +- src/Lib/Attribute/OpenApiPath.php | 2 +- src/Lib/Attribute/OpenApiPathParam.php | 4 +- src/Lib/Attribute/OpenApiQueryParam.php | 8 ++-- src/Lib/Attribute/OpenApiRequestBody.php | 2 +- src/Lib/Attribute/OpenApiResponse.php | 2 +- src/Lib/Attribute/OpenApiSchema.php | 4 +- src/Lib/Attribute/OpenApiSecurity.php | 2 +- src/Lib/Configuration.php | 38 +++++++++---------- src/Lib/Extension/CakeSearch/Extension.php | 10 ++--- src/Lib/MediaType/MediaTypeTrait.php | 4 +- src/Lib/Model/ModelDecorator.php | 2 +- src/Lib/Model/ModelScanner.php | 4 +- src/Lib/OpenApi/Content.php | 2 +- src/Lib/OpenApi/Operation.php | 4 +- src/Lib/OpenApi/OperationExternalDoc.php | 2 +- src/Lib/OpenApi/Parameter.php | 2 +- src/Lib/OpenApi/Path.php | 2 +- src/Lib/OpenApi/PathSecurity.php | 2 +- src/Lib/OpenApi/RequestBody.php | 2 +- src/Lib/OpenApi/Response.php | 2 +- src/Lib/OpenApi/Schema.php | 6 +-- src/Lib/OpenApi/SchemaProperty.php | 8 ++-- src/Lib/OpenApi/SchemaTrait.php | 2 +- src/Lib/OpenApiPathGenerator.php | 4 +- src/Lib/Operation/DtoParser.php | 6 +-- src/Lib/Operation/OperationDocBlock.php | 2 +- .../Operation/OperationFromRouteFactory.php | 8 ++-- src/Lib/Operation/OperationFromYmlFactory.php | 4 +- src/Lib/Operation/OperationPathParameter.php | 8 ++-- src/Lib/Operation/OperationQueryParameter.php | 4 +- src/Lib/Operation/OperationRequestBody.php | 20 +++++----- src/Lib/Operation/OperationResponse.php | 14 +++---- .../OperationResponseAssociation.php | 8 ++-- src/Lib/Operation/OperationSecurity.php | 4 +- src/Lib/Route/RouteDecorator.php | 2 +- src/Lib/Schema/SchemaFactory.php | 4 +- src/Lib/Schema/SchemaFromYamlFactory.php | 6 +-- src/Lib/Schema/SchemaPropertyFactory.php | 4 +- src/Lib/Schema/SchemaPropertyFormat.php | 2 +- src/Lib/Schema/SchemaPropertyValidation.php | 2 +- src/Lib/Service/InstallerService.php | 14 +++---- src/Lib/Swagger.php | 14 +++---- src/Lib/SwaggerFactory.php | 2 +- src/Lib/Utility/NamespaceUtility.php | 2 +- 51 files changed, 135 insertions(+), 135 deletions(-) diff --git a/src/Command/CommandTrait.php b/src/Command/CommandTrait.php index dcca0b8f..22a0a46d 100644 --- a/src/Command/CommandTrait.php +++ b/src/Command/CommandTrait.php @@ -30,7 +30,7 @@ public function loadConfig(Arguments $args): void Configure::load($config, 'default'); } catch (CakeException $e) { throw new SwaggerBakeRunTimeException( - "SwaggerBake config file `$config` is missing or " . get_class($e) . ' ' . $e->getMessage() + "SwaggerBake config file `$config` is missing or " . get_class($e) . ' ' . $e->getMessage(), ); } diff --git a/src/Command/InstallCommand.php b/src/Command/InstallCommand.php index d0710fd9..6788046d 100644 --- a/src/Command/InstallCommand.php +++ b/src/Command/InstallCommand.php @@ -42,7 +42,7 @@ public function execute(Arguments $args, ConsoleIo $io): void $continue = $io->ask( 'If your API exists in a plugin or you have some other non-standard setup, please follow ' . 'the manual installation steps. Do you want to continue?', - 'Y' + 'Y', ); if (strtoupper($continue) !== 'Y') { diff --git a/src/Lib/Attribute/AbstractOpenApiParameter.php b/src/Lib/Attribute/AbstractOpenApiParameter.php index d110f2d9..d518c4c0 100644 --- a/src/Lib/Attribute/AbstractOpenApiParameter.php +++ b/src/Lib/Attribute/AbstractOpenApiParameter.php @@ -83,7 +83,7 @@ public function create(): Parameter (new Schema()) ->setType($this->type) ->setEnum($this->enum) - ->setFormat($this->format) + ->setFormat($this->format), ); return $parameter; diff --git a/src/Lib/Attribute/AbstractSchemaProperty.php b/src/Lib/Attribute/AbstractSchemaProperty.php index 3e0e0eef..9214fd78 100644 --- a/src/Lib/Attribute/AbstractSchemaProperty.php +++ b/src/Lib/Attribute/AbstractSchemaProperty.php @@ -72,7 +72,7 @@ public function __construct( public readonly ?int $minProperties = null, public readonly ?int $maxProperties = null, public readonly array $enum = [], - public readonly array $items = [] + public readonly array $items = [], ) { } diff --git a/src/Lib/Attribute/AttributeFactory.php b/src/Lib/Attribute/AttributeFactory.php index 3ed70ce0..3b9057de 100644 --- a/src/Lib/Attribute/AttributeFactory.php +++ b/src/Lib/Attribute/AttributeFactory.php @@ -14,7 +14,7 @@ final class AttributeFactory */ public function __construct( private Reflector $reflection, - private string $attributeClass + private string $attributeClass, ) { } diff --git a/src/Lib/Attribute/OpenApiHeader.php b/src/Lib/Attribute/OpenApiHeader.php index 48c9a9c4..72c5e654 100644 --- a/src/Lib/Attribute/OpenApiHeader.php +++ b/src/Lib/Attribute/OpenApiHeader.php @@ -43,7 +43,7 @@ public function __construct( public readonly bool $explode = false, public readonly string $style = '', public readonly string|bool|int $example = '', - public readonly bool $allowEmptyValue = false + public readonly bool $allowEmptyValue = false, ) { if (empty($ref) && empty($name)) { throw new SwaggerBakeRunTimeException('One of ref or name must be defined'); @@ -55,8 +55,8 @@ public function __construct( 'Invalid Data Type, given %s for %s but must be one of: %s', $type, $name, - implode(',', OpenApiDataType::TYPES) - ) + implode(',', OpenApiDataType::TYPES), + ), ); } } @@ -81,7 +81,7 @@ public function createParameter(): Parameter (new Schema()) ->setType($this->type) ->setEnum($this->enum) - ->setFormat($this->format) + ->setFormat($this->format), ); } } diff --git a/src/Lib/Attribute/OpenApiPaginator.php b/src/Lib/Attribute/OpenApiPaginator.php index 14d05193..abb5af64 100644 --- a/src/Lib/Attribute/OpenApiPaginator.php +++ b/src/Lib/Attribute/OpenApiPaginator.php @@ -16,7 +16,7 @@ class OpenApiPaginator */ public function __construct( public readonly array $sortEnum = [], - public readonly bool $useSortTextInput = false + public readonly bool $useSortTextInput = false, ) { } } diff --git a/src/Lib/Attribute/OpenApiPath.php b/src/Lib/Attribute/OpenApiPath.php index 3e1f837c..ad8a807a 100644 --- a/src/Lib/Attribute/OpenApiPath.php +++ b/src/Lib/Attribute/OpenApiPath.php @@ -25,7 +25,7 @@ public function __construct( public readonly ?string $ref = null, public readonly ?string $summary = null, public readonly ?string $description = null, - public readonly array $tags = [] + public readonly array $tags = [], ) { } } diff --git a/src/Lib/Attribute/OpenApiPathParam.php b/src/Lib/Attribute/OpenApiPathParam.php index 4855b54d..319ce6c8 100644 --- a/src/Lib/Attribute/OpenApiPathParam.php +++ b/src/Lib/Attribute/OpenApiPathParam.php @@ -43,7 +43,7 @@ public function __construct( description: $description, example: $example, isRequired: $isRequired, - allowReserved: $allowReserved + allowReserved: $allowReserved, ); } @@ -62,7 +62,7 @@ public function createParameter(): Parameter ->setSchema( (new Schema()) ->setType($this->type) - ->setFormat($this->format) + ->setFormat($this->format), ); } } diff --git a/src/Lib/Attribute/OpenApiQueryParam.php b/src/Lib/Attribute/OpenApiQueryParam.php index d8a3be65..146349b9 100644 --- a/src/Lib/Attribute/OpenApiQueryParam.php +++ b/src/Lib/Attribute/OpenApiQueryParam.php @@ -43,7 +43,7 @@ public function __construct( public readonly bool $explode = false, public readonly string $style = '', public readonly string|bool|int $example = '', - public readonly bool $allowEmptyValue = false + public readonly bool $allowEmptyValue = false, ) { if (empty($ref) && empty($name)) { throw new SwaggerBakeRunTimeException('One of ref or name must be defined'); @@ -55,8 +55,8 @@ public function __construct( 'Invalid Data Type, given %s for %s but must be one of: %s', $type, $name, - implode(',', OpenApiDataType::TYPES) - ) + implode(',', OpenApiDataType::TYPES), + ), ); } } @@ -81,7 +81,7 @@ public function createParameter(): Parameter (new Schema()) ->setType($this->type) ->setEnum($this->enum) - ->setFormat($this->format) + ->setFormat($this->format), ); } } diff --git a/src/Lib/Attribute/OpenApiRequestBody.php b/src/Lib/Attribute/OpenApiRequestBody.php index 3e8ebf25..7142d153 100644 --- a/src/Lib/Attribute/OpenApiRequestBody.php +++ b/src/Lib/Attribute/OpenApiRequestBody.php @@ -24,7 +24,7 @@ public function __construct( public readonly string $description = '', public readonly array $mimeTypes = [], public readonly bool $required = true, - public readonly bool $ignoreCakeSchema = false + public readonly bool $ignoreCakeSchema = false, ) { } diff --git a/src/Lib/Attribute/OpenApiResponse.php b/src/Lib/Attribute/OpenApiResponse.php index 168ee4d5..490291ad 100644 --- a/src/Lib/Attribute/OpenApiResponse.php +++ b/src/Lib/Attribute/OpenApiResponse.php @@ -36,7 +36,7 @@ public function __construct( if (is_array($associations)) { $this->associations = array_replace( ['table' => null, 'whiteList' => null], - $associations + $associations, ); } } diff --git a/src/Lib/Attribute/OpenApiSchema.php b/src/Lib/Attribute/OpenApiSchema.php index 8b263ff8..4276834d 100644 --- a/src/Lib/Attribute/OpenApiSchema.php +++ b/src/Lib/Attribute/OpenApiSchema.php @@ -39,11 +39,11 @@ class OpenApiSchema public function __construct( public readonly int $visibility = 1, public readonly ?string $title = null, - public readonly ?string $description = null + public readonly ?string $description = null, ) { if ($this->visibility < 1 || $this->visibility > 4) { throw new InvalidArgumentException( - 'OpenApiSchema visibility must be 1 through 4. See class constants' + 'OpenApiSchema visibility must be 1 through 4. See class constants', ); } } diff --git a/src/Lib/Attribute/OpenApiSecurity.php b/src/Lib/Attribute/OpenApiSecurity.php index 306d5e03..3c5f7982 100644 --- a/src/Lib/Attribute/OpenApiSecurity.php +++ b/src/Lib/Attribute/OpenApiSecurity.php @@ -19,7 +19,7 @@ class OpenApiSecurity */ public function __construct( public readonly string $name, - public readonly array $scopes = [] + public readonly array $scopes = [], ) { } } diff --git a/src/Lib/Configuration.php b/src/Lib/Configuration.php index a9f1166b..1301bdc6 100644 --- a/src/Lib/Configuration.php +++ b/src/Lib/Configuration.php @@ -109,14 +109,14 @@ public function __construct(array $config = [], string $root = ROOT) throw new SwaggerBakeRunTimeException( 'SwaggerBake config missing. Have you added it to your `config/bootstrap.php`? ' . $e->getMessage(), 500, - $e + $e, ); } foreach (['yml', 'json', 'webPath', 'prefix'] as $property) { if (!array_key_exists(key: $property, array: $config)) { throw new InvalidArgumentException( - "Property `$property` must be defined in your config/swagger_bake.php configuration file." + "Property `$property` must be defined in your config/swagger_bake.php configuration file.", ); } } @@ -131,8 +131,8 @@ public function __construct(array $config = [], string $root = ROOT) sprintf( 'Method %s does not exist in class %s but is trying to be called.', $setter, - self::class - ) + self::class, + ), ); } $this->{$setter}($value); @@ -155,7 +155,7 @@ public function setPrefix(string $prefix) { $this->throwInvalidArgExceptionIfPrefixInvalid( $prefix, - "Invalid prefix: $prefix. Prefix must be a valid URI path such as `/` or `/api`." + "Invalid prefix: $prefix. Prefix must be a valid URI path such as `/` or `/api`.", ); $this->prefix = $prefix; @@ -184,8 +184,8 @@ public function setYml(string $yml) sprintf( "Invalid yml: `%s`. Value should start with a / an be relative to your applications ROOT. $message", - $yml - ) + $yml, + ), ); } @@ -195,8 +195,8 @@ public function setYml(string $yml) sprintf( 'A YML file is required but none was found at "%s". See "%s" for a sample file.', $path, - '$vendor/cnizzardini/cakephp-swagger-bake/assets/swagger.yml' - ) + '$vendor/cnizzardini/cakephp-swagger-bake/assets/swagger.yml', + ), ); } @@ -226,8 +226,8 @@ public function setJson(string $json) sprintf( "Invalid json: `%s`. Value should start with a `/` and be relative to your applications ROOT. $message", - $json - ) + $json, + ), ); } @@ -239,8 +239,8 @@ public function setJson(string $json) made to create %s, but permission was denied or the file path is bad. Either fix the file system permissions, create the file and/or both. $message", $json, - $path - ) + $path, + ), ); } @@ -267,7 +267,7 @@ public function setWebPath(?string $webPath) $webPath, "Invalid webPath: `$webPath`. webPath must be a valid web accessible path based e.g. /swagger.json. Generally if your application serves the json file from something like https://example.com/swagger.json - this value should be /swagger.json " + this value should be /swagger.json ", ); $this->webPath = $webPath; @@ -293,7 +293,7 @@ public function setDocType(string $docType) $allowed = ['swagger','redoc']; if (!in_array($docType, $allowed)) { throw new InvalidArgumentException( - "Invalid docType: $docType. Doctype must be one of " . implode(', ', $allowed) + "Invalid docType: $docType. Doctype must be one of " . implode(', ', $allowed), ); } $this->docType = $docType; @@ -490,8 +490,8 @@ public function setConnectionName(string $connectionName) sprintf( 'Invalid connectionName supplied: %s. Must be one of %s', $connectionName, - implode(', ', $configuredConnections) - ) + implode(', ', $configuredConnections), + ), ); } @@ -524,8 +524,8 @@ public function setEditActionMethods(array $editActionMethods) sprintf( 'Invalid editActionMethod supplied: %s. Must be one of %s', implode(', ', $results), - implode(', ', $methods) - ) + implode(', ', $methods), + ), ); } diff --git a/src/Lib/Extension/CakeSearch/Extension.php b/src/Lib/Extension/CakeSearch/Extension.php index ebb960f7..c44242ae 100644 --- a/src/Lib/Extension/CakeSearch/Extension.php +++ b/src/Lib/Extension/CakeSearch/Extension.php @@ -70,8 +70,8 @@ public function getOperation(Event $event): Operation sprintf( 'Extension `%s` could not be run because the subject must be an instance of `%s`', self::class, - Operation::class - ) + Operation::class, + ), ); } @@ -123,7 +123,7 @@ private function createParameter(FilterDecorator $filter): Parameter $parameter->setSchema( (new Schema()) ->setDescription($filter->getComparison()) - ->setType('string') + ->setType('string'), ); return $parameter; @@ -143,7 +143,7 @@ private function getFilterDecorators(Table $table, OpenApiSearch $openApiSearch) $filters = $manager->getFilters($openApiSearch->collection); foreach ($filters as $filter) { - $decoratedFilters[] = (new FilterDecorator($filter)); + $decoratedFilters[] = new FilterDecorator($filter); } return $decoratedFilters; @@ -158,7 +158,7 @@ private function getSearchManager(Table $table): Manager if (!$table->hasBehavior('Search')) { throw new SwaggerBakeRunTimeException(sprintf( 'Search behavior must be loaded on %s', - $table::class + $table::class, )); } diff --git a/src/Lib/MediaType/MediaTypeTrait.php b/src/Lib/MediaType/MediaTypeTrait.php index d6ddbb56..69a8f009 100644 --- a/src/Lib/MediaType/MediaTypeTrait.php +++ b/src/Lib/MediaType/MediaTypeTrait.php @@ -19,8 +19,8 @@ private function validateSchemaType(string $schemaType): void sprintf( 'Argument must be array or object but was given schemaType `%s`. If you\'re using the ' . 'SwagResponseSchema annotation, try defining schemaType.', - $schemaType - ) + $schemaType, + ), ); } } diff --git a/src/Lib/Model/ModelDecorator.php b/src/Lib/Model/ModelDecorator.php index f8eb44e2..838aee55 100644 --- a/src/Lib/Model/ModelDecorator.php +++ b/src/Lib/Model/ModelDecorator.php @@ -14,7 +14,7 @@ class ModelDecorator */ public function __construct( private Model $model, - private ?Controller $controller = null + private ?Controller $controller = null, ) { } diff --git a/src/Lib/Model/ModelScanner.php b/src/Lib/Model/ModelScanner.php index b6970750..3c7fb130 100644 --- a/src/Lib/Model/ModelScanner.php +++ b/src/Lib/Model/ModelScanner.php @@ -33,7 +33,7 @@ class ModelScanner */ public function __construct( private readonly RouteScanner $routeScanner, - private readonly Configuration $config + private readonly Configuration $config, ) { } @@ -101,7 +101,7 @@ private function findRouteDecoratorByModel(Model $model): ?RouteDecorator $result = (new Collection($routes))->filter( function (RouteDecorator $routeDecorator) use ($model) { return $this->routeHasModel($routeDecorator, $model); - } + }, ); return $result->first(); diff --git a/src/Lib/OpenApi/Content.php b/src/Lib/OpenApi/Content.php index fd606cca..8ab68052 100644 --- a/src/Lib/OpenApi/Content.php +++ b/src/Lib/OpenApi/Content.php @@ -20,7 +20,7 @@ class Content implements JsonSerializable */ public function __construct( private string $mimeType, - private Schema|string $schema + private Schema|string $schema, ) { } diff --git a/src/Lib/OpenApi/Operation.php b/src/Lib/OpenApi/Operation.php index 7f36b764..a253bd08 100644 --- a/src/Lib/OpenApi/Operation.php +++ b/src/Lib/OpenApi/Operation.php @@ -44,7 +44,7 @@ public function __construct( private array $responses = [], private array $security = [], private bool $isDeprecated = false, - private int $sortOrder = 100 + private int $sortOrder = 100, ) { $this->setHttpMethod($httpMethod); $this->setParameters($parameters); @@ -196,7 +196,7 @@ public function getParameterByTypeAndName(string $type, string $name): Parameter { if (!in_array($type, Parameter::IN)) { throw new InvalidArgumentException( - "Invalid parameter type `$type`, must be one: " . implode(', ', Parameter::IN) + "Invalid parameter type `$type`, must be one: " . implode(', ', Parameter::IN), ); } diff --git a/src/Lib/OpenApi/OperationExternalDoc.php b/src/Lib/OpenApi/OperationExternalDoc.php index 2886c2ed..5cd75fa6 100644 --- a/src/Lib/OpenApi/OperationExternalDoc.php +++ b/src/Lib/OpenApi/OperationExternalDoc.php @@ -19,7 +19,7 @@ class OperationExternalDoc implements JsonSerializable */ public function __construct( private string $url, - private string $description = '' + private string $description = '', ) { } diff --git a/src/Lib/OpenApi/Parameter.php b/src/Lib/OpenApi/Parameter.php index 9802b856..7aa2dfe2 100644 --- a/src/Lib/OpenApi/Parameter.php +++ b/src/Lib/OpenApi/Parameter.php @@ -86,7 +86,7 @@ public function jsonSerialize(): mixed // reduce JSON clutter if these values are equal to their defaults return ArrayUtility::removeValuesMatching( $vars, - ['deprecated' => false, 'allowEmptyValue' => false, 'explode' => false, 'allowReserved' => false] + ['deprecated' => false, 'allowEmptyValue' => false, 'explode' => false, 'allowReserved' => false], ); } diff --git a/src/Lib/OpenApi/Path.php b/src/Lib/OpenApi/Path.php index d12577c6..8e70616d 100644 --- a/src/Lib/OpenApi/Path.php +++ b/src/Lib/OpenApi/Path.php @@ -29,7 +29,7 @@ public function __construct( private ?string $ref = null, private ?string $summary = null, private ?string $description = null, - private array $tags = [] + private array $tags = [], ) { $this->setOperations($operations); } diff --git a/src/Lib/OpenApi/PathSecurity.php b/src/Lib/OpenApi/PathSecurity.php index 2af530b8..06a4da17 100644 --- a/src/Lib/OpenApi/PathSecurity.php +++ b/src/Lib/OpenApi/PathSecurity.php @@ -21,7 +21,7 @@ class PathSecurity implements JsonSerializable */ public function __construct( private string $name = '', - private array $scopes = [] + private array $scopes = [], ) { } diff --git a/src/Lib/OpenApi/RequestBody.php b/src/Lib/OpenApi/RequestBody.php index 562803bb..276f017e 100644 --- a/src/Lib/OpenApi/RequestBody.php +++ b/src/Lib/OpenApi/RequestBody.php @@ -23,7 +23,7 @@ public function __construct( private ?string $description = null, private array $content = [], private bool $required = false, - private bool $ignoreCakeSchema = false + private bool $ignoreCakeSchema = false, ) { } diff --git a/src/Lib/OpenApi/Response.php b/src/Lib/OpenApi/Response.php index d66f151c..129bf325 100644 --- a/src/Lib/OpenApi/Response.php +++ b/src/Lib/OpenApi/Response.php @@ -22,7 +22,7 @@ class Response implements JsonSerializable public function __construct( private string $code, private ?string $description = null, - private array $content = [] + private array $content = [], ) { } diff --git a/src/Lib/OpenApi/Schema.php b/src/Lib/OpenApi/Schema.php index 720d1413..ed776c73 100644 --- a/src/Lib/OpenApi/Schema.php +++ b/src/Lib/OpenApi/Schema.php @@ -56,7 +56,7 @@ public function __construct( private int $visibility = OpenApiSchema::VISIBLE_DEFAULT, private ?string $refPath = null, private bool $isCustomSchema = false, - private mixed $example = null + private mixed $example = null, ) { } @@ -70,7 +70,7 @@ public function toArray(): array // always unset $vars = ArrayUtility::removeKeysMatching( $vars, - ['name','refEntity','isPublic', 'refPath', 'visibility', 'isCustomSchema',] + ['name','refEntity','isPublic', 'refPath', 'visibility', 'isCustomSchema',], ); // must stay in this order to prevent https://github.com/cnizzardini/cakephp-swagger-bake/issues/30 @@ -83,7 +83,7 @@ public function toArray(): array // remove null or empty properties to avoid swagger.json clutter $vars = ArrayUtility::removeEmptyVars( $vars, - ['title','properties','items','oneOf','anyOf','allOf','not','enum','format','type','xml','required'] + ['title','properties','items','oneOf','anyOf','allOf','not','enum','format','type','xml','required'], ); // remove null properties only diff --git a/src/Lib/OpenApi/SchemaProperty.php b/src/Lib/OpenApi/SchemaProperty.php index 83898c51..e110a8f5 100644 --- a/src/Lib/OpenApi/SchemaProperty.php +++ b/src/Lib/OpenApi/SchemaProperty.php @@ -86,7 +86,7 @@ public function toArray(): array */ $vars = ArrayUtility::removeKeysMatching( $vars, - ['name','isRequired','requirePresenceOnCreate','requirePresenceOnUpdate','refEntity', 'isHidden'] + ['name','isRequired','requirePresenceOnCreate','requirePresenceOnUpdate','refEntity', 'isHidden'], ); if (!empty($this->refEntity)) { @@ -102,7 +102,7 @@ public function toArray(): array 'format','title','description','multipleOf','minimum','maximum','minLength','maxLength','pattern', 'minItems','maxItems','minProperties','maxProperties','items','enum','default','exclusiveMinimum', 'exclusiveMaximum','uniqueItems','nullable','type','oneOf', - ] + ], ); /* @@ -115,7 +115,7 @@ public function toArray(): array */ $vars = ArrayUtility::removeValuesMatching( $vars, - ['readOnly' => false, 'writeOnly' => false, 'deprecated' => false, 'nullable' => false] + ['readOnly' => false, 'writeOnly' => false, 'deprecated' => false, 'nullable' => false], ); if (isset($vars['enum']) && is_array($vars['enum'])) { @@ -123,7 +123,7 @@ public function toArray(): array } if (isset($vars['items'])) { - $vars['items'] = (object) reset($vars['items']); + $vars['items'] = (object)reset($vars['items']); } return $vars; diff --git a/src/Lib/OpenApi/SchemaTrait.php b/src/Lib/OpenApi/SchemaTrait.php index 2ea12444..905457e5 100644 --- a/src/Lib/OpenApi/SchemaTrait.php +++ b/src/Lib/OpenApi/SchemaTrait.php @@ -31,7 +31,7 @@ public function setType(?string $type) if ($type !== null && !in_array($type, OpenApiDataType::TYPES)) { throw new InvalidArgumentException( "Schema type of `$type` is invalid. Must be one of: " . - implode(',', OpenApiDataType::TYPES) + implode(',', OpenApiDataType::TYPES), ); } diff --git a/src/Lib/OpenApiPathGenerator.php b/src/Lib/OpenApiPathGenerator.php index 495decac..2eb9a07d 100644 --- a/src/Lib/OpenApiPathGenerator.php +++ b/src/Lib/OpenApiPathGenerator.php @@ -25,7 +25,7 @@ class OpenApiPathGenerator public function __construct( private Swagger $swagger, private RouteScanner $routeScanner, - private Configuration $config + private Configuration $config, ) { } @@ -74,7 +74,7 @@ public function generate(array $openapi = []): array } EventManager::instance()->dispatch( - new Event('SwaggerBake.Path.created', $path) + new Event('SwaggerBake.Path.created', $path), ); if (!empty($path->getOperations())) { diff --git a/src/Lib/Operation/DtoParser.php b/src/Lib/Operation/DtoParser.php index 52a1a633..dd8da011 100644 --- a/src/Lib/Operation/DtoParser.php +++ b/src/Lib/Operation/DtoParser.php @@ -47,7 +47,7 @@ public function getParameters(): array foreach ($this->reflection->getProperties() as $reflectionProperty) { $queryParam = (new AttributeFactory( $reflectionProperty, - OpenApiQueryParam::class + OpenApiQueryParam::class, ))->createOneOrNull(); if ($queryParam instanceof OpenApiQueryParam) { @@ -70,7 +70,7 @@ public function getSchemaProperties(): array foreach ($this->reflection->getProperties() as $reflectionProperty) { $schemaProperty = (new AttributeFactory( $reflectionProperty, - OpenApiSchemaProperty::class + OpenApiSchemaProperty::class, ))->createOneOrNull(); if ($schemaProperty instanceof OpenApiSchemaProperty) { @@ -102,7 +102,7 @@ private function getModellessFormSchemaProperties(): array $attr = $schema->field($name); $schemaProperty = new SchemaProperty( name: $name, - type: DataTypeConversion::toType($attr['type']) + type: DataTypeConversion::toType($attr['type']), ); $schemaProperty = (new SchemaPropertyValidation($validator, $schemaProperty, $name))->withValidations(); $schemaProperties[$name] = $schemaProperty; diff --git a/src/Lib/Operation/OperationDocBlock.php b/src/Lib/Operation/OperationDocBlock.php index 18c0fa96..be232ba2 100644 --- a/src/Lib/Operation/OperationDocBlock.php +++ b/src/Lib/Operation/OperationDocBlock.php @@ -24,7 +24,7 @@ class OperationDocBlock public function __construct( private Configuration $config, private Operation $operation, - private DocBlock $doc + private DocBlock $doc, ) { } diff --git a/src/Lib/Operation/OperationFromRouteFactory.php b/src/Lib/Operation/OperationFromRouteFactory.php index ed2c9eb3..761ac358 100644 --- a/src/Lib/Operation/OperationFromRouteFactory.php +++ b/src/Lib/Operation/OperationFromRouteFactory.php @@ -87,7 +87,7 @@ public function create(RouteDecorator $route, string $httpMethod, ?Schema $schem $operation = new Operation( operationId: $route->getName() . ':' . strtolower($httpMethod), httpMethod: $httpMethod, - sortOrder: $sortOrder + sortOrder: $sortOrder, ); $operation = $this->createOperation($operation, $route, $openApiOperation); @@ -125,7 +125,7 @@ public function create(RouteDecorator $route, string $httpMethod, ?Schema $schem 'reflectionMethod' => $refMethod, 'route' => $route, 'schema' => $schema, - ]) + ]), ); return $operation; @@ -166,7 +166,7 @@ private function getDocBlock(RouteDecorator $route): DocBlock private function createOperation( Operation $operation, RouteDecorator $route, - ?OpenApiOperation $openApiOperation + ?OpenApiOperation $openApiOperation, ): Operation { if ($openApiOperation instanceof OpenApiOperation) { $operation->setSummary($openApiOperation->summary); @@ -178,7 +178,7 @@ private function createOperation( new OperationExternalDoc( $openApiOperation->externalDocs['url'] ?? '', $openApiOperation->externalDocs['description'] ?? '', - ) + ), ); } if (is_numeric($openApiOperation->sortOrder)) { diff --git a/src/Lib/Operation/OperationFromYmlFactory.php b/src/Lib/Operation/OperationFromYmlFactory.php index 9648effd..d75e57ae 100644 --- a/src/Lib/Operation/OperationFromYmlFactory.php +++ b/src/Lib/Operation/OperationFromYmlFactory.php @@ -27,12 +27,12 @@ public function create(string $httpMethod, array $yaml): Operation operationId: $yaml['operationId'], httpMethod: $httpMethod, tags: $yaml['tags'] ?? [], - isDeprecated: $yaml['deprecated'] ?? false + isDeprecated: $yaml['deprecated'] ?? false, ); if (isset($yaml['externalDocs']['url'])) { $operation->setExternalDocs( - (new OperationExternalDoc($yaml['externalDocs']['url'], $yaml['externalDocs']['description'])) + new OperationExternalDoc($yaml['externalDocs']['url'], $yaml['externalDocs']['description']), ); } diff --git a/src/Lib/Operation/OperationPathParameter.php b/src/Lib/Operation/OperationPathParameter.php index c14acbb3..12065b65 100644 --- a/src/Lib/Operation/OperationPathParameter.php +++ b/src/Lib/Operation/OperationPathParameter.php @@ -28,7 +28,7 @@ public function __construct( private Operation $operation, private RouteDecorator $route, private ?ReflectionMethod $reflectionMethod = null, - private ?Schema $schema = null + private ?Schema $schema = null, ) { } @@ -74,8 +74,8 @@ private function assignPathParametersFromRoute(): void name: $id, description: $description ?? null, required: true, - schema: (new Schema())->setType($type ?? 'string')->setFormat($format ?? '') - ) + schema: (new Schema())->setType($type ?? 'string')->setFormat($format ?? ''), + ), ); } } @@ -95,7 +95,7 @@ private function updatePathParametersUsingAnnotations(): void /** @var array<\SwaggerBake\Lib\Attribute\OpenApiPathParam> $openApiPathParams */ $openApiPathParams = (new AttributeFactory( $this->reflectionMethod, - OpenApiPathParam::class + OpenApiPathParam::class, ))->createMany(); $parameters = $this->operation->getParameters(); diff --git a/src/Lib/Operation/OperationQueryParameter.php b/src/Lib/Operation/OperationQueryParameter.php index ed75a311..6674c9a4 100644 --- a/src/Lib/Operation/OperationQueryParameter.php +++ b/src/Lib/Operation/OperationQueryParameter.php @@ -165,14 +165,14 @@ private function defineDataTransferObject(): void if (!class_exists($dto->class)) { throw new SwaggerBakeRunTimeException( - sprintf('DTO class %s not found', $dto->class) + sprintf('DTO class %s not found', $dto->class), ); } // get openapi schema query params defined on the class $queryParams = (new AttributeFactory( new ReflectionClass($dto->class), - OpenApiQueryParam::class + OpenApiQueryParam::class, ))->createMany(); /** @var array<\SwaggerBake\Lib\Attribute\OpenApiQueryParam> $queryParams */ $parameters = array_map(function ($param) { diff --git a/src/Lib/Operation/OperationRequestBody.php b/src/Lib/Operation/OperationRequestBody.php index 77d69965..453aaadb 100644 --- a/src/Lib/Operation/OperationRequestBody.php +++ b/src/Lib/Operation/OperationRequestBody.php @@ -37,7 +37,7 @@ public function __construct( private Operation $operation, private RouteDecorator $route, private ?ReflectionMethod $refMethod = null, - private ?Schema $schema = null + private ?Schema $schema = null, ) { $this->config = $swagger->getConfig(); } @@ -73,7 +73,7 @@ private function applyRequestBody(): void { $openApiRequestBody = (new AttributeFactory( $this->refMethod, - OpenApiRequestBody::class + OpenApiRequestBody::class, ))->createOneOrNull(); if (!$openApiRequestBody instanceof OpenApiRequestBody) { @@ -91,7 +91,7 @@ private function applyRequestBody(): void $pieces = explode('/', $openApiRequestBody->ref); $entity = end($pieces); $schema = $this->getSchemaWithRequiredProperties( - $this->swagger->getSchemaByName($entity) + $this->swagger->getSchemaByName($entity), ); } @@ -100,7 +100,7 @@ private function applyRequestBody(): void } $this->operation->setRequestBody( - $openApiRequestBody->createRequestBody($requestBody) + $openApiRequestBody->createRequestBody($requestBody), ); } @@ -115,7 +115,7 @@ private function applyForm(): void /** @var array<\SwaggerBake\Lib\Attribute\OpenApiForm> $openApiForms */ $openApiForms = (new AttributeFactory( $this->refMethod, - OpenApiForm::class + OpenApiForm::class, ))->createMany(); if (empty($openApiForms)) { @@ -126,7 +126,7 @@ private function applyForm(): void foreach ($openApiForms as $attribute) { $schema->pushProperty( - $attribute->create() + $attribute->create(), ); } @@ -149,7 +149,7 @@ private function applyDataTransferObject(): void { $openApiDto = (new AttributeFactory( $this->refMethod, - OpenApiDto::class + OpenApiDto::class, ))->createOneOrNull(); if (!$openApiDto instanceof OpenApiDto || !class_exists($openApiDto->class)) { @@ -160,7 +160,7 @@ private function applyDataTransferObject(): void $dtoReflection = new ReflectionClass($openApiDto->class); $openApiSchema = (new AttributeFactory( $dtoReflection, - OpenApiSchema::class + OpenApiSchema::class, ))->createOneOrNull(); // add schema to #/components/schemas ? @@ -178,7 +178,7 @@ private function applyDataTransferObject(): void // get openapi schema properties defined on the class $schemaProperties = (new AttributeFactory( $dtoReflection, - OpenApiSchemaProperty::class + OpenApiSchemaProperty::class, ))->createMany(); /** @var array<\SwaggerBake\Lib\Attribute\OpenApiSchemaProperty> $schemaProperties */ $properties = array_map(function ($prop) { @@ -215,7 +215,7 @@ private function applySchema(): void if ($this->refMethod instanceof ReflectionMethod) { $openApiRequestBody = (new AttributeFactory( $this->refMethod, - OpenApiRequestBody::class + OpenApiRequestBody::class, ))->createOneOrNull(); } diff --git a/src/Lib/Operation/OperationResponse.php b/src/Lib/Operation/OperationResponse.php index df186c02..e3123fe2 100644 --- a/src/Lib/Operation/OperationResponse.php +++ b/src/Lib/Operation/OperationResponse.php @@ -46,7 +46,7 @@ public function __construct( private Operation $operation, private RouteDecorator $route, private ?Schema $schema = null, - private ?ReflectionMethod $refMethod = null + private ?ReflectionMethod $refMethod = null, ) { } @@ -152,7 +152,7 @@ private function addResponseSchema(Response $response, string $mimeType, OpenApi /** @var \SwaggerBake\Lib\Attribute\OpenApiSchema|null $openApiSchema */ $openApiSchema = (new AttributeFactory( $reflection, - OpenApiSchema::class + OpenApiSchema::class, ))->createOneOrNull(); $schema = $this->createResponseSchema($reflection, $openApiResponse, $openApiSchema); @@ -160,7 +160,7 @@ private function addResponseSchema(Response $response, string $mimeType, OpenApi // class level attributes $schemaProperties = (new AttributeFactory( $reflection, - OpenApiSchemaProperty::class + OpenApiSchemaProperty::class, ))->createMany(); foreach ($schemaProperties as $schemaProperty) { $schema->pushProperty($schemaProperty->create()); @@ -170,7 +170,7 @@ private function addResponseSchema(Response $response, string $mimeType, OpenApi foreach ($reflection->getProperties() as $reflectionProperty) { $schemaProperty = (new AttributeFactory( $reflectionProperty, - OpenApiSchemaProperty::class + OpenApiSchemaProperty::class, ))->createOneOrNull(); if ($schemaProperty instanceof OpenApiSchemaProperty) { @@ -211,7 +211,7 @@ private function addResponseSchema(Response $response, string $mimeType, OpenApi private function createResponseSchema( ReflectionClass $reflectionClass, OpenApiResponse $openApiResponse, - ?OpenApiSchema $openApiSchema + ?OpenApiSchema $openApiSchema, ): Schema { // create base schema from implementation if ($reflectionClass->implementsInterface(CustomSchemaInterface::class)) { @@ -283,11 +283,11 @@ private function addAssociatedSchema(Response $response, string $mimeType, OpenA $schema = $this->getMimeTypeSchema( $mimeType, $openApiResponse->schemaType, - $assocSchema + $assocSchema, ); $response->pushContent(new Content( $mimeType, - $openApiResponse->schemaFormat ? $schema->setFormat($openApiResponse->schemaFormat) : $schema + $openApiResponse->schemaFormat ? $schema->setFormat($openApiResponse->schemaFormat) : $schema, )); $this->operation->pushResponse($response); diff --git a/src/Lib/Operation/OperationResponseAssociation.php b/src/Lib/Operation/OperationResponseAssociation.php index 485e0024..21341afe 100644 --- a/src/Lib/Operation/OperationResponseAssociation.php +++ b/src/Lib/Operation/OperationResponseAssociation.php @@ -42,7 +42,7 @@ public function __construct( private readonly RouteDecorator $route, private readonly ?Schema $schema = null, private ?LocatorInterface $locator = null, - private ?Inflector $inflector = null + private ?Inflector $inflector = null, ) { $this->locator = $locator ?? TableRegistry::getTableLocator(); $this->inflector = $inflector ?? new Inflector(); @@ -109,7 +109,7 @@ private function associate( Table $table, Schema $schema, array $assoc, - ?array $current = null + ?array $current = null, ): Schema { $current = $current ?? array_slice($assoc, 0, 1); try { @@ -119,8 +119,8 @@ private function associate( sprintf( 'OpenApiResponse association not found. Declared on %s result in error: %s', $this->route->getControllerFqn() . '::' . $this->route->getAction(), - $e->getMessage() - ) + $e->getMessage(), + ), ); } diff --git a/src/Lib/Operation/OperationSecurity.php b/src/Lib/Operation/OperationSecurity.php index caa8e317..ed88cebc 100644 --- a/src/Lib/Operation/OperationSecurity.php +++ b/src/Lib/Operation/OperationSecurity.php @@ -22,7 +22,7 @@ class OperationSecurity */ public function __construct( private Operation $operation, - private ?ReflectionMethod $refMethod + private ?ReflectionMethod $refMethod, ) { } @@ -60,7 +60,7 @@ private function assignOpenApiSecurity(): void $this->operation->pushSecurity( (new PathSecurity()) ->setName($sec->name) - ->setScopes($sec->scopes) + ->setScopes($sec->scopes), ); } } diff --git a/src/Lib/Route/RouteDecorator.php b/src/Lib/Route/RouteDecorator.php index d04a8c31..b4ef0704 100644 --- a/src/Lib/Route/RouteDecorator.php +++ b/src/Lib/Route/RouteDecorator.php @@ -315,7 +315,7 @@ function ($piece) { return $piece; }, - explode('/', $this->template) + explode('/', $this->template), ); return implode('/', $pieces); diff --git a/src/Lib/Schema/SchemaFactory.php b/src/Lib/Schema/SchemaFactory.php index 7af21d2b..c4d9f9d4 100644 --- a/src/Lib/Schema/SchemaFactory.php +++ b/src/Lib/Schema/SchemaFactory.php @@ -69,7 +69,7 @@ public function create(ModelDecorator $modelDecorator, int $propertyType = 6): ? EventManager::instance()->dispatch( new Event('SwaggerBake.Schema.created', $schema, [ 'modelDecorator' => $modelDecorator, - ]) + ]), ); return $schema; @@ -204,7 +204,7 @@ private function getPropertyAnnotations(Model $model): array /** @var array<\SwaggerBake\Lib\Attribute\OpenApiSchemaProperty> $attributes */ $attributes = (new AttributeFactory( new ReflectionClass($model->getEntity()), - OpenApiSchemaProperty::class + OpenApiSchemaProperty::class, ))->createMany(); $return = []; diff --git a/src/Lib/Schema/SchemaFromYamlFactory.php b/src/Lib/Schema/SchemaFromYamlFactory.php index 0e4947d8..42a4cff7 100644 --- a/src/Lib/Schema/SchemaFromYamlFactory.php +++ b/src/Lib/Schema/SchemaFromYamlFactory.php @@ -41,7 +41,7 @@ public function create(string $name, array $yml): Schema ->setAttribute($yml['xml']['attribute'] ?? null) ->setNamespace($yml['xml']['namespace'] ?? null) ->setPrefix($yml['xml']['prefix'] ?? null) - ->setWrapped($yml['xml']['wrapped'] ?? null) + ->setWrapped($yml['xml']['wrapped'] ?? null), ); } @@ -54,14 +54,14 @@ public function create(string $name, array $yml): Schema */ if (!empty($propertyVar['type']) && $propertyVar['type'] === 'object') { $schema->pushProperty( - $this->create($propertyName, $propertyVar) + $this->create($propertyName, $propertyVar), ); /* * Property is a property */ } else { $schema->pushProperty( - $factory->create($propertyName, $propertyVar) + $factory->create($propertyName, $propertyVar), ); } } diff --git a/src/Lib/Schema/SchemaPropertyFactory.php b/src/Lib/Schema/SchemaPropertyFactory.php index a24e7182..39c55c42 100644 --- a/src/Lib/Schema/SchemaPropertyFactory.php +++ b/src/Lib/Schema/SchemaPropertyFactory.php @@ -24,7 +24,7 @@ class SchemaPropertyFactory */ public function __construct( private Validator $validator, - private ?DocBlock $docBlock = null + private ?DocBlock $docBlock = null, ) { } @@ -94,7 +94,7 @@ private function findPropertyTag(ModelProperty $property): ?PropertyTag function ($tag) use ($property) { /** @var \phpDocumentor\Reflection\DocBlock\Tags\Property $tag */ return $tag->getVariableName() === $property->getName(); - } + }, ); return !empty($results) ? reset($results) : null; diff --git a/src/Lib/Schema/SchemaPropertyFormat.php b/src/Lib/Schema/SchemaPropertyFormat.php index 9a83bc5d..75181df8 100644 --- a/src/Lib/Schema/SchemaPropertyFormat.php +++ b/src/Lib/Schema/SchemaPropertyFormat.php @@ -43,7 +43,7 @@ class SchemaPropertyFormat public function __construct( private Validator $validator, private SchemaProperty $schemaProperty, - ModelProperty $property + ModelProperty $property, ) { $this->propertyName = $property->getName(); } diff --git a/src/Lib/Schema/SchemaPropertyValidation.php b/src/Lib/Schema/SchemaPropertyValidation.php index edc34992..7ae4854f 100644 --- a/src/Lib/Schema/SchemaPropertyValidation.php +++ b/src/Lib/Schema/SchemaPropertyValidation.php @@ -27,7 +27,7 @@ class SchemaPropertyValidation public function __construct( private Validator $validator, private SchemaProperty $schemaProperty, - ModelProperty|string $property + ModelProperty|string $property, ) { $this->propertyName = is_string($property) ? $property : $property->getName(); } diff --git a/src/Lib/Service/InstallerService.php b/src/Lib/Service/InstallerService.php index a31dcfac..6db5b269 100644 --- a/src/Lib/Service/InstallerService.php +++ b/src/Lib/Service/InstallerService.php @@ -17,7 +17,7 @@ class InstallerService */ public function __construct( private string $configDir = CONFIG, - ?FileUtility $fileUtility = null + ?FileUtility $fileUtility = null, ) { $this->fileUtility = $fileUtility ?? new FileUtility(); } @@ -37,7 +37,7 @@ public function install(string $prefix, bool $skipErrors = false): bool $swaggerYml = $this->configDir . 'swagger.yml'; if (!$this->fileUtility->copy($fromAssets, $swaggerYml)) { throw new InstallException( - "Error copying base OpenAPI YAML from `$fromAssets` to `$swaggerYml`" + "Error copying base OpenAPI YAML from `$fromAssets` to `$swaggerYml`", ); } @@ -45,7 +45,7 @@ public function install(string $prefix, bool $skipErrors = false): bool $swaggerBake = $this->configDir . 'swagger_bake.php'; if (!$this->fileUtility->copy($fromAssets, $swaggerBake)) { throw new InstallException( - "Error copying swagger_bake config from `$fromAssets` to `$swaggerBake`" + "Error copying swagger_bake config from `$fromAssets` to `$swaggerBake`", ); } @@ -82,7 +82,7 @@ private function validate(string $prefix, bool $skipErrors): void { if (!str_starts_with($prefix, '/') || !filter_var('http://localhost' . $prefix, FILTER_VALIDATE_URL)) { throw new InstallException( - "Prefix is invalid. Prefix `$prefix` should start with a `/` and be a valid URL path." + "Prefix is invalid. Prefix `$prefix` should start with a `/` and be a valid URL path.", ); } @@ -90,8 +90,8 @@ private function validate(string $prefix, bool $skipErrors): void throw new InstallException( sprintf( 'Assets directory `%s` does not exist. Please correct the issue or install manually.', - self::ASSETS - ) + self::ASSETS, + ), ); } @@ -101,7 +101,7 @@ private function validate(string $prefix, bool $skipErrors): void throw (new InstallException()) ->setQuestion( 'The installer found an existing swagger.yml and/or swagger_bake.php file. ' . - 'Do you want to continue & overwrite these files?' + 'Do you want to continue & overwrite these files?', ); } } diff --git a/src/Lib/Swagger.php b/src/Lib/Swagger.php index 8a6ca2ae..aae8dc85 100644 --- a/src/Lib/Swagger.php +++ b/src/Lib/Swagger.php @@ -44,7 +44,7 @@ class Swagger public function __construct( private ModelScanner $modelScanner, private Configuration $config, - private ?FileUtility $fileUtility = null + private ?FileUtility $fileUtility = null, ) { $this->fileUtility = $fileUtility ?? new FileUtility(); } @@ -63,11 +63,11 @@ public function build(): Swagger $this->array['x-swagger-bake'] = array_merge_recursive( $xSwaggerBake['x-swagger-bake'], - $this->array['x-swagger-bake'] ?? [] + $this->array['x-swagger-bake'] ?? [], ); EventManager::instance()->dispatch( - new Event('SwaggerBake.initialize', $this) + new Event('SwaggerBake.initialize', $this), ); $this->array = (new OpenApiSchemaGenerator($this->modelScanner))->generate($this->array); @@ -104,7 +104,7 @@ public function getArray(): array uksort($this->array['components']['schemas'], function ($a, $b) { return strcasecmp( preg_replace('/\s+/', '', $a), - preg_replace('/\s+/', '', $b) + preg_replace('/\s+/', '', $b), ); }); } @@ -140,7 +140,7 @@ public function toString(): string $this->addAdditionalSchema(); EventManager::instance()->dispatch( - new Event('SwaggerBake.beforeRender', $this) + new Event('SwaggerBake.beforeRender', $this), ); $json = json_encode($this->getArray(), $this->config->getJsonOptions()); @@ -211,7 +211,7 @@ public function getOperationsWithNoHttp20x(): array $operations, array_filter($path->getOperations(), function ($operation) { return !$operation->hasSuccessResponseCode(); - }) + }), ); } @@ -283,7 +283,7 @@ private function addCustomSchema(Content $content): Content ->setType('array') ->setItems([ '$ref' => $schema->getRefPath(), - ]) + ]), ); } else { $content->setSchema($schema->getRefPath()); diff --git a/src/Lib/SwaggerFactory.php b/src/Lib/SwaggerFactory.php index 24956611..716f0bbe 100644 --- a/src/Lib/SwaggerFactory.php +++ b/src/Lib/SwaggerFactory.php @@ -22,7 +22,7 @@ class SwaggerFactory */ public function __construct( private ?Configuration $config = null, - private ?RouteScanner $routeScanner = null + private ?RouteScanner $routeScanner = null, ) { $this->config = $config ?? new Configuration(); diff --git a/src/Lib/Utility/NamespaceUtility.php b/src/Lib/Utility/NamespaceUtility.php index 5a567274..afaed2a8 100644 --- a/src/Lib/Utility/NamespaceUtility.php +++ b/src/Lib/Utility/NamespaceUtility.php @@ -84,7 +84,7 @@ public static function getClasses(array $namespaces, string $ns = ''): array $classes = array_merge( $classes, - MixerApiNsUtil::findClasses($namespace) + MixerApiNsUtil::findClasses($namespace), ); }