Skip to content

Commit

Permalink
Merge branch 'main' into fix/recommend
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp authored Jul 12, 2024
2 parents 54f560b + 18cf950 commit 8bc4f83
Show file tree
Hide file tree
Showing 21 changed files with 71 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ public partial class GetRecommendationsResponse
/// <summary>
/// Initializes a new instance of the GetRecommendationsResponse class.
/// </summary>
public GetRecommendationsResponse()
[JsonConstructor]
public GetRecommendationsResponse() { }
/// <summary>
/// Initializes a new instance of the GetRecommendationsResponse class.
/// </summary>
/// <param name="results">results (required).</param>
public GetRecommendationsResponse(List<RecommendationsResults> results)
{
Results = results ?? throw new ArgumentNullException(nameof(results));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ part 'get_recommendations_response.g.dart';
final class GetRecommendationsResponse {
/// Returns a new [GetRecommendationsResponse] instance.
const GetRecommendationsResponse({
this.results,
required this.results,
});

@JsonKey(name: r'results')
final List<RecommendationsResults>? results;
final List<RecommendationsResults> results;

@override
bool operator ==(Object other) =>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ void main() async {
/// Prints the search hits.
void printRecommendations(GetRecommendationsResponse response) {
final results = response.results;
if (results == null) {
print("No recommendations found");
return;
}

// Loop over each result and map over the search hits,
// converting each hit to a product.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ part 'get_recommendations_response.g.dart';
final class GetRecommendationsResponse {
/// Returns a new [GetRecommendationsResponse] instance.
const GetRecommendationsResponse({
this.results,
required this.results,
});

@JsonKey(name: r'results')
final List<RecommendationsResults>? results;
final List<RecommendationsResults> results;

@override
bool operator ==(Object other) =>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,20 @@
public class GetRecommendationsResponse {

@JsonProperty("results")
private List<RecommendationsResults> results;
private List<RecommendationsResults> results = new ArrayList<>();

public GetRecommendationsResponse setResults(List<RecommendationsResults> results) {
this.results = results;
return this;
}

public GetRecommendationsResponse addResults(RecommendationsResults resultsItem) {
if (this.results == null) {
this.results = new ArrayList<>();
}
this.results.add(resultsItem);
return this;
}

/** Get results */
@javax.annotation.Nullable
@javax.annotation.Nonnull
public List<RecommendationsResults> getResults() {
return results;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import type { RecommendationsResults } from './recommendationsResults';

export type GetRecommendationsResponse = {
results?: RecommendationsResults[];
results: RecommendationsResults[];
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import type { RecommendationsResults } from './recommendationsResults';

export type GetRecommendationsResponse = {
results?: RecommendationsResults[];
results: RecommendationsResults[];
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ import kotlinx.serialization.json.*
@Serializable
public data class GetRecommendationsResponse(

@SerialName(value = "results") val results: List<RecommendationsResults>? = null,
@SerialName(value = "results") val results: List<RecommendationsResults>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ public static function getters()
*/
public function listInvalidProperties()
{
return [];
$invalidProperties = [];

if (!isset($this->container['results']) || null === $this->container['results']) {
$invalidProperties[] = "'results' can't be null";
}

return $invalidProperties;
}

/**
Expand All @@ -153,7 +159,7 @@ public function valid()
/**
* Gets results.
*
* @return null|\Algolia\AlgoliaSearch\Model\Recommend\RecommendationsResults[]
* @return \Algolia\AlgoliaSearch\Model\Recommend\RecommendationsResults[]
*/
public function getResults()
{
Expand All @@ -163,7 +169,7 @@ public function getResults()
/**
* Sets results.
*
* @param null|\Algolia\AlgoliaSearch\Model\Recommend\RecommendationsResults[] $results results
* @param \Algolia\AlgoliaSearch\Model\Recommend\RecommendationsResults[] $results results
*
* @return self
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations

from json import loads
from typing import Any, Dict, List, Optional, Self
from typing import Any, Dict, List, Self

from pydantic import BaseModel, ConfigDict

Expand All @@ -21,7 +21,7 @@ class GetRecommendationsResponse(BaseModel):
GetRecommendationsResponse
"""

results: Optional[List[RecommendationsResults]] = None
results: List[RecommendationsResults]

model_config = ConfigDict(
use_enum_values=True, populate_by_name=True, validate_assignment=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def initialize(attributes = {})
if (value = attributes[:results]).is_a?(Array)
self.results = value
end
else
self.results = nil
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ package algoliasearch.recommend
/** GetRecommendationsResponse
*/
case class GetRecommendationsResponse(
results: Option[Seq[RecommendationsResults]] = scala.None
results: Seq[RecommendationsResults]
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import Foundation
#endif

public struct GetRecommendationsResponse: Codable, JSONEncodable {
public var results: [RecommendationsResults]?
public var results: [RecommendationsResults]

public init(results: [RecommendationsResults]? = nil) {
public init(results: [RecommendationsResults]) {
self.results = results
}

Expand All @@ -21,7 +21,7 @@ public struct GetRecommendationsResponse: Codable, JSONEncodable {

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(self.results, forKey: .results)
try container.encode(self.results, forKey: .results)
}
}

Expand All @@ -33,6 +33,6 @@ extension GetRecommendationsResponse: Equatable {

extension GetRecommendationsResponse: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(self.results?.hashValue)
hasher.combine(self.results.hashValue)
}
}
7 changes: 6 additions & 1 deletion scripts/cts/runCts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ async function runCtsOne(
const e2eFolder = toAbsolutePath(
`tests/output/${language}/${getTestOutputFolder(language)}/e2e`,
);
if ((await exists(e2eFolder)) && (await fsp.readdir(e2eFolder)).length > 0) folders.push('e2e');
if (
(await exists(e2eFolder)) &&
(await fsp.readdir(e2eFolder)).filter((f) => f !== '__init__.py' && f !== '__pycache__')
.length > 0
)
folders.push('e2e');
}
if (!excludeUnit) {
folders.push('client', 'requests');
Expand Down
2 changes: 2 additions & 0 deletions specs/bundled/algoliasearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ paths:
type: array
items:
$ref: '#/components/schemas/recommendationsResults'
required:
- results
'400':
$ref: '#/components/responses/BadRequest'
'402':
Expand Down
2 changes: 2 additions & 0 deletions specs/bundled/recommend.doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,8 @@ paths:
type: array
items:
$ref: '#/components/schemas/recommendationsResults'
required:
- results
'400':
$ref: '#/components/responses/BadRequest'
'402':
Expand Down
2 changes: 2 additions & 0 deletions specs/bundled/recommend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ paths:
type: array
items:
$ref: '#/components/schemas/recommendationsResults'
required:
- results
'400':
$ref: '#/components/responses/BadRequest'
'402':
Expand Down
2 changes: 2 additions & 0 deletions specs/recommend/paths/getRecommendations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ post:
type: array
items:
$ref: '../common/schemas/RecommendationsResponse.yml#/recommendationsResults'
required:
- results
'400':
$ref: '../../common/responses/BadRequest.yml'
'402':
Expand Down

0 comments on commit 8bc4f83

Please sign in to comment.