Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"require": {
"php": "^8.3",
"saloonphp/saloon": "^4.0"
"saloonphp/saloon": "^3.0 || ^4.0"
},
"require-dev": {
"laravel/framework": "^11.0|^12.0",
Expand Down
30 changes: 17 additions & 13 deletions tests/Contract/OpenApiSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@ function getRequestSchema(array $spec, string $method, string $path): ?array
return isset($body['$ref']) ? resolveSchema($spec, $body['$ref']) : $body;
}

function specFields(array $schema): array
function specFields(?array $schema): array
{
if ($schema === null) {
return [];
}

return array_keys($schema['properties'] ?? []);
}

function specRequired(array $schema): array
function specRequired(?array $schema): array
{
if ($schema === null) {
return [];
}

return $schema['required'] ?? [];
}

Expand All @@ -55,18 +63,16 @@ function specRequired(array $schema): array
expect(specFields($schema))->toContain('vectors');
});

it('SearchRequest has required vector and limit', function (): void {
$schema = getRequestSchema(loadSpec(), 'post', '/collections/{collection_name}/points/search');
it('nearest-neighbor search lives on QueryRequest after /points/search retired', function (): void {
$schema = getRequestSchema(loadSpec(), 'post', '/collections/{collection_name}/points/query');
$fields = specFields($schema);
$required = specRequired($schema);

expect($fields)->toContain('vector')
expect($schema)->not->toBeNull()
->and($fields)->toContain('query')
->and($fields)->toContain('limit')
->and($fields)->toContain('filter')
->and($fields)->toContain('with_payload')
->and($fields)->toContain('with_vector')
->and($required)->toContain('vector')
->and($required)->toContain('limit');
->and($fields)->toContain('with_vector');
});

it('ScrollRequest accepts our fields', function (): void {
Expand Down Expand Up @@ -176,13 +182,12 @@ function specRequired(array $schema): array

expect($paths)->toContain('/collections/{collection_name}')
->and($paths)->toContain('/collections/{collection_name}/points')
->and($paths)->toContain('/collections/{collection_name}/points/search')
->and($paths)->toContain('/collections/{collection_name}/points/query')
->and($paths)->toContain('/collections/{collection_name}/points/scroll')
->and($paths)->toContain('/collections/{collection_name}/points/delete')
->and($paths)->toContain('/collections/{collection_name}/points/count')
->and($paths)->toContain('/collections/{collection_name}/points/payload')
->and($paths)->toContain('/collections/{collection_name}/index')
->and($paths)->toContain('/collections/{collection_name}/points/query')
->and($paths)->toContain('/collections/aliases');
});

Expand All @@ -194,14 +199,13 @@ function specRequired(array $schema): array
->and($spec['paths']['/collections/{collection_name}'])->toHaveKey('delete')
->and($spec['paths']['/collections/{collection_name}/points'])->toHaveKey('put')
->and($spec['paths']['/collections/{collection_name}/points'])->toHaveKey('post')
->and($spec['paths']['/collections/{collection_name}/points/search'])->toHaveKey('post')
->and($spec['paths']['/collections/{collection_name}/points/query'])->toHaveKey('post')
->and($spec['paths']['/collections/{collection_name}/points/scroll'])->toHaveKey('post')
->and($spec['paths']['/collections/{collection_name}/points/delete'])->toHaveKey('post')
->and($spec['paths']['/collections/{collection_name}/points/count'])->toHaveKey('post')
->and($spec['paths']['/collections/{collection_name}/points/payload'])->toHaveKey('post')
->and($spec['paths']['/collections/{collection_name}/index'])->toHaveKey('put')
->and($spec['paths']['/collections/{collection_name}/index/{field_name}'])->toHaveKey('delete')
->and($spec['paths']['/collections/{collection_name}/points/query'])->toHaveKey('post')
->and($spec['paths']['/collections/aliases'])->toHaveKey('post');
});
});
Expand Down
Loading