Skip to content

Commit 6b933f0

Browse files
authored
fix(OpenAI): Allow bytes to be nullable on ContainerFileResponse (#705)
1 parent fc439d2 commit 6b933f0

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/Responses/Containers/Files/ContainerFileResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use OpenAI\Testing\Responses\Concerns\Fakeable;
1313

1414
/**
15-
* @phpstan-type ContainerFileType array{id: string, object: 'container.file', created_at: int, bytes: int, container_id: string, path: string, source: 'user'|'assistant'}
15+
* @phpstan-type ContainerFileType array{id: string, object: 'container.file', created_at: int, bytes: int|null, container_id: string, path: string, source: 'user'|'assistant'}
1616
*
1717
* @implements ResponseContract<ContainerFileType>
1818
*/
@@ -34,7 +34,7 @@ private function __construct(
3434
public readonly string $id,
3535
public readonly string $object,
3636
public readonly int $createdAt,
37-
public readonly int $bytes,
37+
public readonly ?int $bytes,
3838
public readonly string $containerId,
3939
public readonly string $path,
4040
public readonly string $source,

tests/Fixtures/ContainerFile.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ function containerFileResource(): array
1616
];
1717
}
1818

19+
/**
20+
* @return array<string, mixed>
21+
*/
22+
function containerFileResourceAssistant(): array
23+
{
24+
return [
25+
'id' => 'cfile_68efad3233308191ae2aea6fdc172940',
26+
'object' => 'container.file',
27+
'created_at' => 1760537906,
28+
'bytes' => null,
29+
'container_id' => 'cntr_68efad24888881938f8d8a661b5036450ac07bb92e293373',
30+
'path' => '/mnt/data/dummy_risk_priority_bar_chart.png',
31+
'source' => 'assistant',
32+
];
33+
}
34+
1935
/**
2036
* @return array<string, mixed>
2137
*/

tests/Responses/Containers/Files/ContainerFileResponse.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@
1515
->source->toBe('user');
1616
});
1717

18+
test('from response with null bytes', function () {
19+
$result = ContainerFileResponse::from(containerFileResourceAssistant(), meta());
20+
21+
expect($result)
22+
->id->toBe('cfile_68efad3233308191ae2aea6fdc172940')
23+
->object->toBe('container.file')
24+
->createdAt->toBe(1760537906)
25+
->bytes->toBeNull()
26+
->containerId->toBe('cntr_68efad24888881938f8d8a661b5036450ac07bb92e293373')
27+
->path->toBe('/mnt/data/dummy_risk_priority_bar_chart.png')
28+
->source->toBe('assistant');
29+
});
30+
1831
test('as array accessible', function () {
1932
$result = ContainerFileResponse::from(containerFileResource(), meta());
2033

0 commit comments

Comments
 (0)