Skip to content

Commit ed67905

Browse files
committed
fix docs
1 parent 0daf3cd commit ed67905

33 files changed

+225
-218
lines changed

.openapi.php

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,47 @@
33
use Astral\Serialize\OpenApi\Storage\OpenAPI\ServersStorage;
44

55
return [
6+
// API Document Title
67
'title' => 'API Docs',
78

9+
// Description of the API document
810
'description' => 'API Docs description.',
911

1012
/**
11-
* 向全局头部参数存储中添加一个的头部参数。
12-
* @param string $name
13-
* @param string $example
14-
* @param string $description
13+
* Global headers to be added to every request.
14+
* Each header should include name, example, and description.
15+
*
16+
* Example:
17+
* [
18+
* 'name' => 'Authorization',
19+
* 'example' => 'Bearer token',
20+
* 'description' => 'Authentication token'
21+
* ]
1522
*/
16-
'headers' => [
17-
18-
],
23+
'headers' => [],
1924

25+
/**
26+
* Service base URLs (servers).
27+
* You can define multiple environments like production, staging, etc.
28+
*
29+
* @type ServersStorage[] $service
30+
*/
2031
'service' => [
21-
new ServersStorage('http://127.0.0.1','默认环境'),
32+
new ServersStorage('http://127.0.0.1', 'Default Environment'),
2233
],
34+
35+
/**
36+
* Directories to exclude from scanning.
37+
* These paths are relative to the project root directory.
38+
*
39+
* Default excluded directories:
40+
* - /vendor
41+
* - /tests
42+
* - /migrations
43+
* Example:
44+
* ['/sdk', '/app']
45+
*
46+
* You can override or extend this list in your config file.
47+
*/
48+
'exclude_dirs' => [],
2349
];

src/Annotations/Input/InputDateFormat.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public function match(mixed $value, DataCollection $collection, InputValueContex
2828
return is_string($value) || is_numeric($value);
2929
}
3030

31-
3231
public function resolve(mixed $value, DataCollection $collection, InputValueContext $context): string|DateTime
3332
{
3433

src/Annotations/Output/OutputDateFormat.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public function match(mixed $value, DataCollection $collection, OutContext $cont
3030
return is_string($value) || is_numeric($value) || is_subclass_of($value, DateTimeInterface::class);
3131
}
3232

33-
3433
public function resolve(mixed $value, DataCollection $collection, OutContext $context): string|DateTime|null
3534
{
3635
return $this->formatValue($value);

src/Casts/InputConstructCast.php renamed to src/Casts/InputValue/InputConstructCast.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Astral\Serialize\Casts;
5+
namespace Astral\Serialize\Casts\InputValue;
66

77
use Astral\Serialize\Support\Collections\ConstructDataCollection;
88

@@ -18,7 +18,11 @@ public function resolve(array $constructorParameters, object $object, ?array $re
1818
{
1919
$args = [];
2020
foreach ($constructorParameters as $param) {
21-
$args[] = array_key_exists($param->name, $readonlyVols) ? $readonlyVols[$param->name] : $object->{$param->name};
21+
$value = array_key_exists($param->name, $readonlyVols) ? $readonlyVols[$param->name] : $object->{$param->name};
22+
if ($param->isNull === false && $value === null && $param->defaultValue !== null) {
23+
$value = $param->defaultValue;
24+
}
25+
$args[] = $value;
2226
}
2327

2428
$object->__construct(...$args);

src/Enums/TypeKindEnum.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Astral\Serialize\Enums;
44

5-
65
use RuntimeException;
76

87
enum TypeKindEnum

src/Faker/FakerResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Astral\Serialize\Faker;
44

5-
use Astral\Serialize\Casts\InputConstructCast;
5+
use Astral\Serialize\Casts\InputValue\InputConstructCast;
66
use Astral\Serialize\Faker\Rule\FakerDefaultRules;
77
use Astral\Serialize\Resolvers\GroupResolver;
88
use Astral\Serialize\Support\Collections\DataCollection;

src/OpenApi.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function buildByClass(string $className): void
3434
$tagDoc = isset($tagDoc[0]) ? $tagDoc[0]->newInstance() : null;
3535

3636
if ($tagDoc) {
37-
self::$OpenAPI->addTag(new TagStorage($tagDoc->value, $tagDoc->description));
37+
self::$openAPI->addTag(new TagStorage($tagDoc->value, $tagDoc->description));
3838
}
3939

4040
foreach ($classRefection->getMethods() as $item) {
@@ -79,7 +79,7 @@ public function buildByClass(string $className): void
7979
response: $instances[Response::class],
8080
);
8181

82-
self::$OpenAPI->addPath($openApiCollection);
82+
self::$openAPI->addPath($openApiCollection);
8383
}
8484
}
8585
}

src/OpenApi/Annotations/OpenApi.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#[Attribute(Attribute::TARGET_PROPERTY)]
1010
class OpenApi
1111
{
12-
1312
public function __construct(
1413
public string $description = '',
1514
public string $example = '',

src/OpenApi/Annotations/RequestBody.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public function __construct(
1515
public string $className = '',
1616
public ContentTypeEnum $contentType = ContentTypeEnum::JSON,
1717
public array|null $groups = null
18-
){
18+
) {
1919
}
2020
}

src/OpenApi/Annotations/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ public function __construct(
1414
public string $className,
1515
public ?int $code = 200,
1616
public ?array $groups = null,
17-
){
17+
) {
1818
}
1919
}

0 commit comments

Comments
 (0)