Skip to content

Commit 008ad52

Browse files
committed
Updated Laravel data support
1 parent 1b11929 commit 008ad52

7 files changed

+29
-17
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
]
4040
},
4141
"require": {
42-
"spatie/laravel-data": "^2",
42+
"spatie/laravel-data": "^2.2",
4343
"laravel/framework": "^8|^9|^10",
4444
"phpdocumentor/reflection-docblock": "^5.3",
4545
"spatie/invade": "^1.0"

composer.lock

+15-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Data/Content.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ public static function fromClass(string $class, ReflectionMethod|ReflectionFunct
4444
public function transform(
4545
bool $transformValues = true,
4646
WrapExecutionType $wrapExecutionType = WrapExecutionType::Disabled,
47+
bool $mapPropertyNames = true,
4748
): array {
4849
return collect($this->types)->mapWithKeys(
49-
fn (string $content_type) => [$content_type => parent::transform($transformValues, $wrapExecutionType)]
50+
fn (string $content_type) => [$content_type => parent::transform($transformValues, $wrapExecutionType, $mapPropertyNames)]
5051
)->toArray();
5152
}
5253

src/Data/OpenApi.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ public static function fromRoutes(array $routes, Command $command): self
7979
/**
8080
* @return array<string,mixed>
8181
*/
82-
public function transform(bool $transformValues = true, WrapExecutionType $wrapExecutionType = WrapExecutionType::Disabled): array
83-
{
82+
public function transform(
83+
bool $transformValues = true,
84+
WrapExecutionType $wrapExecutionType = WrapExecutionType::Disabled,
85+
bool $mapPropertyNames = true,
86+
): array {
8487
// Double call to make sure all schemas are resolved
8588
$this->resolveSchemas();
8689

@@ -97,7 +100,7 @@ public function transform(bool $transformValues = true, WrapExecutionType $wrapE
97100
];
98101

99102
return array_merge(
100-
parent::transform($transformValues, $wrapExecutionType),
103+
parent::transform($transformValues, $wrapExecutionType, $mapPropertyNames),
101104
$paths,
102105
[
103106
'components' => [

src/Data/Operation.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ public static function fromRoute(Route $route): self
7979
public function transform(
8080
bool $transformValues = true,
8181
WrapExecutionType $wrapExecutionType = WrapExecutionType::Disabled,
82+
bool $mapPropertyNames = true,
8283
): array {
8384
return array_filter(
84-
parent::transform($transformValues, $wrapExecutionType),
85+
parent::transform($transformValues, $wrapExecutionType, $mapPropertyNames),
8586
fn (mixed $value) => null !== $value,
8687
);
8788
}

src/Data/Schema.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public static function fromDataClass(string $class): self
134134
public function transform(
135135
bool $transformValues = true,
136136
WrapExecutionType $wrapExecutionType = WrapExecutionType::Disabled,
137+
bool $mapPropertyNames = true,
137138
): array {
138139
$array = array_filter(
139140
parent::transform($transformValues, $wrapExecutionType),
@@ -152,7 +153,7 @@ public function transform(
152153

153154
if (null !== $this->properties) {
154155
$array['properties'] = collect($this->properties->all())
155-
->mapWithKeys(fn (Property $property) => [$property->getName() => $property->type->transform($transformValues, $wrapExecutionType)])
156+
->mapWithKeys(fn (Property $property) => [$property->getName() => $property->type->transform($transformValues, $wrapExecutionType, $mapPropertyNames)])
156157
->toArray();
157158
}
158159

src/Data/SecurityScheme.php

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public static function getPermissions(Route $route): array
6969
public function transform(
7070
bool $transformValues = true,
7171
WrapExecutionType $wrapExecutionType = WrapExecutionType::Disabled,
72+
bool $mapPropertyNames = true,
7273
): array {
7374
return [$this->scheme => $this->permissions];
7475
}

0 commit comments

Comments
 (0)