Skip to content

Commit f99535e

Browse files
committed
refactor: consolidates mime type schema
1 parent 05b57c6 commit f99535e

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

src/Files/DTO/InlineFile.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ public static function getJsonSchema(): array
7979
return [
8080
'type' => 'object',
8181
'properties' => [
82-
'mimeType' => [
83-
'type' => 'string',
84-
'description' => 'The MIME type of the file.',
85-
'pattern' => '^[a-zA-Z0-9][a-zA-Z0-9!#$&\-\^_+.]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-\^_+.]*$',
86-
],
82+
'mimeType' => self::getMimeTypePropertySchema(),
8783
'base64Data' => [
8884
'type' => 'string',
8985
'description' => 'The base64-encoded file data.',

src/Files/DTO/LocalFile.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ public static function getJsonSchema(): array
9494
return [
9595
'type' => 'object',
9696
'properties' => [
97-
'mimeType' => [
98-
'type' => 'string',
99-
'description' => 'The MIME type of the file.',
100-
'pattern' => '^[a-zA-Z0-9][a-zA-Z0-9!#$&\-\^_+.]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-\^_+.]*$',
101-
],
97+
'mimeType' => self::getMimeTypePropertySchema(),
10298
'path' => [
10399
'type' => 'string',
104100
'description' => 'The local filesystem path to the file.',

src/Files/DTO/RemoteFile.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ public static function getJsonSchema(): array
106106
return [
107107
'type' => 'object',
108108
'properties' => [
109-
'mimeType' => [
110-
'type' => 'string',
111-
'description' => 'The MIME type of the file.',
112-
'pattern' => '^[a-zA-Z0-9][a-zA-Z0-9!#$&\-\^_+.]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-\^_+.]*$',
113-
],
109+
'mimeType' => self::getMimeTypePropertySchema(),
114110
'url' => [
115111
'type' => 'string',
116112
'format' => 'uri',

src/Files/Traits/HasMimeType.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,20 @@ public function getMimeType(): MimeType
3434
{
3535
return $this->mimeType;
3636
}
37+
38+
/**
39+
* Gets the JSON schema for the MIME type property.
40+
*
41+
* @return array{type: string, description: string, pattern: string} The JSON schema for the mimeType property.
42+
*
43+
* @since n.e.x.t
44+
*/
45+
protected static function getMimeTypePropertySchema(): array
46+
{
47+
return [
48+
'type' => 'string',
49+
'description' => 'The MIME type of the file.',
50+
'pattern' => '^[a-zA-Z0-9][a-zA-Z0-9!#$&\\-\\^_+.]*\\/[a-zA-Z0-9][a-zA-Z0-9!#$&\\-\\^_+.]*$',
51+
];
52+
}
3753
}

0 commit comments

Comments
 (0)