1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* It's free open-source software released under the MIT License. |
5
|
|
|
* |
6
|
|
|
* @author Anatoly Nekhay <[email protected]> |
7
|
|
|
* @copyright Copyright (c) 2018, Anatoly Nekhay |
8
|
|
|
* @license https://github.com/sunrise-php/http-router/blob/master/LICENSE |
9
|
|
|
* @link https://github.com/sunrise-php/http-router |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Sunrise\Http\Router\OpenApi; |
15
|
|
|
|
16
|
|
|
use Sunrise\Coder\MediaTypeInterface; |
17
|
|
|
use Sunrise\Hydrator\TypeConverter\TimestampTypeConverter; |
18
|
|
|
|
19
|
|
|
use function sys_get_temp_dir; |
20
|
|
|
|
21
|
|
|
use const DIRECTORY_SEPARATOR; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @since 3.0.0 |
25
|
|
|
*/ |
26
|
|
|
final class OpenApiConfiguration |
27
|
|
|
{ |
28
|
|
|
public const VERSION = '3.1.1'; |
29
|
|
|
public const JSON_SCHEMA_DIALECT = 'https://json-schema.org/draft/2020-12/schema'; |
30
|
|
|
|
31
|
|
|
public const DEFAULT_TIMESTAMP_FORMAT = TimestampTypeConverter::DEFAULT_FORMAT; |
32
|
|
|
public const DEFAULT_RESPONSE_DESCRIPTION = 'The operation was successful.'; |
33
|
|
|
|
34
|
5 |
|
public function __construct( |
35
|
|
|
/** @var array<array-key, mixed> */ |
36
|
|
|
public readonly array $initialDocument, |
37
|
|
|
/** @var array<array-key, mixed> */ |
38
|
|
|
public readonly array $initialOperation, |
39
|
|
|
public readonly MediaTypeInterface $documentMediaType, |
40
|
|
|
/** @var array<array-key, mixed> */ |
41
|
|
|
public readonly array $documentEncodingContext = [], |
42
|
|
|
public readonly ?string $documentFilename = null, |
43
|
|
|
public readonly string $defaultTimestampFormat = self::DEFAULT_TIMESTAMP_FORMAT, |
44
|
|
|
public readonly string $defaultResponseDescription = self::DEFAULT_RESPONSE_DESCRIPTION, |
45
|
|
|
) { |
46
|
5 |
|
} |
47
|
|
|
|
48
|
5 |
|
public function getDocumentFilename(): string |
49
|
|
|
{ |
50
|
5 |
|
return $this->documentFilename ?? $this->getTemporaryDocumentFilename(); |
51
|
|
|
} |
52
|
|
|
|
53
|
2 |
|
public function getTemporaryDocumentFilename(): string |
54
|
|
|
{ |
55
|
2 |
|
return sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'openapi'; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|