Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/Command/CommandTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Attribute/AbstractOpenApiParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function create(): Parameter
(new Schema())
->setType($this->type)
->setEnum($this->enum)
->setFormat($this->format)
->setFormat($this->format),
);

return $parameter;
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Attribute/AbstractSchemaProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [],
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Attribute/AttributeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class AttributeFactory
*/
public function __construct(
private Reflector $reflection,
private string $attributeClass
private string $attributeClass,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/Lib/Attribute/OpenApiHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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),
),
);
}
}
Expand All @@ -81,7 +81,7 @@ public function createParameter(): Parameter
(new Schema())
->setType($this->type)
->setEnum($this->enum)
->setFormat($this->format)
->setFormat($this->format),
);
}
}
2 changes: 1 addition & 1 deletion src/Lib/Attribute/OpenApiPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class OpenApiPaginator
*/
public function __construct(
public readonly array $sortEnum = [],
public readonly bool $useSortTextInput = false
public readonly bool $useSortTextInput = false,
) {
}
}
2 changes: 1 addition & 1 deletion src/Lib/Attribute/OpenApiPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [],
) {
}
}
4 changes: 2 additions & 2 deletions src/Lib/Attribute/OpenApiPathParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
description: $description,
example: $example,
isRequired: $isRequired,
allowReserved: $allowReserved
allowReserved: $allowReserved,
);
}

Expand All @@ -62,7 +62,7 @@ public function createParameter(): Parameter
->setSchema(
(new Schema())
->setType($this->type)
->setFormat($this->format)
->setFormat($this->format),
);
}
}
8 changes: 4 additions & 4 deletions src/Lib/Attribute/OpenApiQueryParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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),
),
);
}
}
Expand All @@ -81,7 +81,7 @@ public function createParameter(): Parameter
(new Schema())
->setType($this->type)
->setEnum($this->enum)
->setFormat($this->format)
->setFormat($this->format),
);
}
}
2 changes: 1 addition & 1 deletion src/Lib/Attribute/OpenApiRequestBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Attribute/OpenApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
if (is_array($associations)) {
$this->associations = array_replace(
['table' => null, 'whiteList' => null],
$associations
$associations,
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Attribute/OpenApiSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Attribute/OpenApiSecurity.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OpenApiSecurity
*/
public function __construct(
public readonly string $name,
public readonly array $scopes = []
public readonly array $scopes = [],
) {
}
}
38 changes: 19 additions & 19 deletions src/Lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
);
}
}
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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,
),
);
}

Expand All @@ -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',
),
);
}

Expand Down Expand Up @@ -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,
),
);
}

Expand All @@ -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,
),
);
}

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -490,8 +490,8 @@ public function setConnectionName(string $connectionName)
sprintf(
'Invalid connectionName supplied: %s. Must be one of %s',
$connectionName,
implode(', ', $configuredConnections)
)
implode(', ', $configuredConnections),
),
);
}

Expand Down Expand Up @@ -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),
),
);
}

Expand Down
10 changes: 5 additions & 5 deletions src/Lib/Extension/CakeSearch/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
);
}

Expand Down Expand Up @@ -123,7 +123,7 @@ private function createParameter(FilterDecorator $filter): Parameter
$parameter->setSchema(
(new Schema())
->setDescription($filter->getComparison())
->setType('string')
->setType('string'),
);

return $parameter;
Expand All @@ -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;
Expand All @@ -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,
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Lib/MediaType/MediaTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Model/ModelDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ModelDecorator
*/
public function __construct(
private Model $model,
private ?Controller $controller = null
private ?Controller $controller = null,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Model/ModelScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ModelScanner
*/
public function __construct(
private readonly RouteScanner $routeScanner,
private readonly Configuration $config
private readonly Configuration $config,
) {
}

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/OpenApi/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Content implements JsonSerializable
*/
public function __construct(
private string $mimeType,
private Schema|string $schema
private Schema|string $schema,
) {
}

Expand Down
Loading