From 7ad9b90a9226e0898a000394e678ade0ed12cc8e Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 30 Aug 2024 12:45:56 +0200 Subject: [PATCH 1/5] fix(specs): ignorePlurals can be a boolean string --- scripts/cts/runCts.ts | 3 +- specs/common/schemas/IndexSettings.yml | 7 ++ templates/go/tests/e2e/e2e.mustache | 2 +- tests/CTS/requests/search/getRule.json | 35 +++++++++- tests/CTS/requests/search/searchRules.json | 44 ++++++++++-- .../src/generated/e2e/Analytics.test.cs | 68 ------------------ tests/output/go/tests/e2e/analytics_test.go | 61 ---------------- tests/output/go/tests/echo.go | 16 ++++- .../java/com/algolia/e2e/Analytics.test.java | 48 ------------- .../javascript/src/e2e/analytics.test.ts | 38 ---------- tests/output/php/src/e2e/AnalyticsTest.php | 59 ---------------- .../output/python/tests/e2e/analytics_test.py | 40 ----------- tests/output/ruby/test/e2e/analytics_test.rb | 30 -------- .../algoliasearch/e2e/AnalyticsTest.scala | 51 -------------- .../swift/Tests/e2e/AnalyticsTests.swift | 69 ------------------- 15 files changed, 95 insertions(+), 476 deletions(-) delete mode 100644 tests/output/csharp/src/generated/e2e/Analytics.test.cs delete mode 100644 tests/output/go/tests/e2e/analytics_test.go delete mode 100644 tests/output/java/src/test/java/com/algolia/e2e/Analytics.test.java delete mode 100644 tests/output/javascript/src/e2e/analytics.test.ts delete mode 100644 tests/output/php/src/e2e/AnalyticsTest.php delete mode 100644 tests/output/python/tests/e2e/analytics_test.py delete mode 100644 tests/output/ruby/test/e2e/analytics_test.rb delete mode 100644 tests/output/scala/src/test/scala/algoliasearch/e2e/AnalyticsTest.scala delete mode 100644 tests/output/swift/Tests/e2e/AnalyticsTests.swift diff --git a/scripts/cts/runCts.ts b/scripts/cts/runCts.ts index b57bb189b9..1d440c88c0 100644 --- a/scripts/cts/runCts.ts +++ b/scripts/cts/runCts.ts @@ -126,7 +126,8 @@ export async function runCts( clients: string[], suites: Record, ): Promise { - const withBenchmarkServer = suites.benchmark && (clients.includes('search') || clients.includes('all')); + const withBenchmarkServer = + suites.benchmark && (clients.includes('search') || clients.includes('all') || languages.includes('swift')); const withClientServer = suites.client && (clients.includes('search') || clients.includes('all')); const closeTestServer = await startTestServer({ ...suites, diff --git a/specs/common/schemas/IndexSettings.yml b/specs/common/schemas/IndexSettings.yml index efc4889a17..b9ba3f4cf3 100644 --- a/specs/common/schemas/IndexSettings.yml +++ b/specs/common/schemas/IndexSettings.yml @@ -962,6 +962,7 @@ ignorePlurals: If true, `ignorePlurals` is active for all languages included in `queryLanguages`, or for all supported languages, if `queryLanguges` is empty. If false, singulars, plurals, and other declensions won't be considered equivalent. default: false + - $ref: '#/booleanString' x-categories: - Languages @@ -1168,3 +1169,9 @@ supportedLanguage: - ur - uz - zh + +booleanString: + type: string + enum: + - true + - false diff --git a/templates/go/tests/e2e/e2e.mustache b/templates/go/tests/e2e/e2e.mustache index 50c86ed2f7..3d413e53a4 100644 --- a/templates/go/tests/e2e/e2e.mustache +++ b/templates/go/tests/e2e/e2e.mustache @@ -51,7 +51,7 @@ func Test{{#lambda.titlecase}}{{clientPrefix}}{{/lambda.titlecase}}E2E_{{#lambda err = json.Unmarshal([]byte(expectedBodyRaw), &expectedBody) require.NoError(t, err) - unionBody := tests.Union(expectedBody, rawBodyMap) + unionBody := tests.Union(t, expectedBody, rawBodyMap) unionBodyRaw, err := json.Marshal(unionBody) require.NoError(t, err) diff --git a/tests/CTS/requests/search/getRule.json b/tests/CTS/requests/search/getRule.json index 7d778b480b..1bd1550908 100644 --- a/tests/CTS/requests/search/getRule.json +++ b/tests/CTS/requests/search/getRule.json @@ -1,12 +1,41 @@ [ { "parameters": { - "indexName": "indexName", - "objectID": "id1" + "indexName": "cts_e2e_browse", + "objectID": "qr-1725004648916" }, "request": { - "path": "/1/indexes/indexName/rules/id1", + "path": "/1/indexes/cts_e2e_browse/rules/qr-1725004648916", "method": "GET" + }, + "response": { + "status": 200, + "body": { + "description": "test_rule", + "enabled": true, + "objectID": "qr-1725004648916", + "conditions": [ + { + "alternatives": true, + "anchoring": "contains", + "pattern": "zorro" + } + ], + "consequence": { + "params": { + "ignorePlurals": "true" + }, + "filterPromotes": true, + "promote": [ + { + "objectIDs": [ + "\u00C6on Flux" + ], + "position": 0 + } + ] + } + } } } ] diff --git a/tests/CTS/requests/search/searchRules.json b/tests/CTS/requests/search/searchRules.json index a83e199c84..b51ddb296b 100644 --- a/tests/CTS/requests/search/searchRules.json +++ b/tests/CTS/requests/search/searchRules.json @@ -1,16 +1,52 @@ [ { "parameters": { - "indexName": "indexName", + "indexName": "cts_e2e_browse", "searchRulesParams": { - "query": "something" + "query": "zorro" } }, "request": { - "path": "/1/indexes/indexName/rules/search", + "path": "/1/indexes/cts_e2e_browse/rules/search", "method": "POST", "body": { - "query": "something" + "query": "zorro" + } + }, + "response": { + "status": 200, + "body": { + "hits": [ + { + "conditions": [ + { + "alternatives": true, + "anchoring": "contains", + "pattern": "zorro" + } + ], + "consequence": { + "params": { + "ignorePlurals": "true" + }, + "filterPromotes": true, + "promote": [ + { + "objectIDs": [ + "\u00C6on Flux" + ], + "position": 0 + } + ] + }, + "description": "test_rule", + "enabled": true, + "objectID": "qr-1725004648916" + } + ], + "nbHits": 1, + "nbPages": 1, + "page": 0 } } } diff --git a/tests/output/csharp/src/generated/e2e/Analytics.test.cs b/tests/output/csharp/src/generated/e2e/Analytics.test.cs deleted file mode 100644 index b1b9949c13..0000000000 --- a/tests/output/csharp/src/generated/e2e/Analytics.test.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -using System.Text.Json; -using Algolia.Search.Clients; -using Algolia.Search.Http; -using Algolia.Search.Models.Analytics; -using Algolia.Search.Serializer; -using Algolia.Search.Tests.Utils; -using dotenv.net; -using Quibble.Xunit; -using Xunit; -using Action = Algolia.Search.Models.Ingestion.Action; - -namespace Algolia.Search.e2e; - -public class AnalyticsClientRequestTestsE2E -{ - private readonly AnalyticsClient client; - - public AnalyticsClientRequestTestsE2E() - { - DotEnv.Load( - options: new DotEnvOptions( - ignoreExceptions: true, - probeForEnv: true, - probeLevelsToSearch: 8, - envFilePaths: new[] { ".env" } - ) - ); - - var appId = Environment.GetEnvironmentVariable("ALGOLIA_APPLICATION_ID"); - if (appId == null) - { - throw new Exception("please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests"); - } - - var apiKey = Environment.GetEnvironmentVariable("ALGOLIA_ADMIN_KEY"); - if (apiKey == null) - { - throw new Exception("please provide an `ALGOLIA_ADMIN_KEY` env var for e2e tests"); - } - - client = new AnalyticsClient(new AnalyticsConfig(appId, apiKey, "us")); - } - - [Fact] - public void Dispose() { } - - [Fact(DisplayName = "e2e with complex query params")] - public async Task GetTopSearchesTest2() - { - try - { - var resp = await client.GetTopSearchesAsync("cts_e2e_space in index"); - // Check status code 200 - Assert.NotNull(resp); - - JsonAssert.EqualOverrideDefault( - "{\"searches\":[{\"search\":\"\",\"nbHits\":0}]}", - JsonSerializer.Serialize(resp, JsonConfig.Options), - new JsonDiffConfig(true) - ); - } - catch (Exception e) - { - Assert.Fail("An exception was thrown: " + e.Message); - } - } -} diff --git a/tests/output/go/tests/e2e/analytics_test.go b/tests/output/go/tests/e2e/analytics_test.go deleted file mode 100644 index e1ceca8ffe..0000000000 --- a/tests/output/go/tests/e2e/analytics_test.go +++ /dev/null @@ -1,61 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -package e2e - -import ( - "encoding/json" - "gotests/tests" - "os" - "testing" - - "github.com/kinbiko/jsonassert" - "github.com/stretchr/testify/require" - - "github.com/joho/godotenv" - - "github.com/algolia/algoliasearch-client-go/v4/algolia/analytics" -) - -func createE2EAnalyticsClient(t *testing.T) *analytics.APIClient { - t.Helper() - - appID := os.Getenv("ALGOLIA_APPLICATION_ID") - if appID == "" && os.Getenv("CI") != "true" { - err := godotenv.Load("../../../../.env") - require.NoError(t, err) - appID = os.Getenv("ALGOLIA_APPLICATION_ID") - } - apiKey := os.Getenv("ALGOLIA_ADMIN_KEY") - client, err := analytics.NewClient(appID, apiKey, analytics.US) - require.NoError(t, err) - - return client -} - -func TestAnalyticsE2E_GetTopSearches(t *testing.T) { - t.Run("e2e with complex query params", func(t *testing.T) { - client := createE2EAnalyticsClient(t) - res, err := client.GetTopSearches(client.NewApiGetTopSearchesRequest( - "cts_e2e_space in index", - )) - require.NoError(t, err) - _ = res - - rawBody, err := json.Marshal(res) - require.NoError(t, err) - - var rawBodyMap any - err = json.Unmarshal(rawBody, &rawBodyMap) - require.NoError(t, err) - - expectedBodyRaw := `{"searches":[{"search":"","nbHits":0}]}` - var expectedBody any - err = json.Unmarshal([]byte(expectedBodyRaw), &expectedBody) - require.NoError(t, err) - - unionBody := tests.Union(expectedBody, rawBodyMap) - unionBodyRaw, err := json.Marshal(unionBody) - require.NoError(t, err) - - jsonassert.New(t).Assertf(string(unionBodyRaw), expectedBodyRaw) - }) -} diff --git a/tests/output/go/tests/echo.go b/tests/output/go/tests/echo.go index fa6b37e73b..d1f2039eca 100644 --- a/tests/output/go/tests/echo.go +++ b/tests/output/go/tests/echo.go @@ -6,7 +6,10 @@ import ( "net/http" "net/url" "strings" + "testing" "time" + + "github.com/stretchr/testify/require" ) type EchoRequester struct { @@ -55,18 +58,25 @@ func ZeroValue[T any]() T { return v } -func Union(expected any, received any) any { +func Union(t *testing.T, expected any, received any) any { + t.Helper() + if expected != nil { + require.NotNil(t, received, expected) + } + switch expected.(type) { case map[string]any: res := map[string]any{} for key, val := range expected.(map[string]any) { - res[key] = Union(val, received.(map[string]any)[key]) + require.Contains(t, received.(map[string]any), key) + res[key] = Union(t, val, received.(map[string]any)[key]) } return res case []any: res := []any{} + require.GreaterOrEqual(t, len(received.([]any)), len(expected.([]any))) for i, val := range expected.([]any) { - res = append(res, Union(val, received.([]any)[i])) + res = append(res, Union(t, val, received.([]any)[i])) } return res default: diff --git a/tests/output/java/src/test/java/com/algolia/e2e/Analytics.test.java b/tests/output/java/src/test/java/com/algolia/e2e/Analytics.test.java deleted file mode 100644 index 5a74c6cf58..0000000000 --- a/tests/output/java/src/test/java/com/algolia/e2e/Analytics.test.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.algolia.e2e; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -import com.algolia.api.AnalyticsClient; -import com.algolia.config.*; -import com.algolia.model.analytics.*; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.json.JsonMapper; -import io.github.cdimascio.dotenv.Dotenv; -import java.util.*; -import org.junit.jupiter.api.*; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -class AnalyticsClientRequestsTestsE2E { - - private AnalyticsClient client; - private ObjectMapper json; - - @BeforeAll - void init() { - this.json = JsonMapper.builder().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).build(); - - if ("true".equals(System.getenv("CI"))) { - this.client = new AnalyticsClient(System.getenv("ALGOLIA_APPLICATION_ID"), System.getenv("ALGOLIA_ADMIN_KEY"), "us"); - } else { - var dotenv = Dotenv.configure().directory("../../").load(); - this.client = new AnalyticsClient(dotenv.get("ALGOLIA_APPLICATION_ID"), dotenv.get("ALGOLIA_ADMIN_KEY"), "us"); - } - } - - @AfterAll - void tearUp() throws Exception { - client.close(); - } - - @Test - @DisplayName("e2e with complex query params") - void getTopSearchesTest2() { - var res = client.getTopSearches("cts_e2e_space in index"); - assertDoesNotThrow(() -> - JSONAssert.assertEquals("{\"searches\":[{\"search\":\"\",\"nbHits\":0}]}", json.writeValueAsString(res), JSONCompareMode.LENIENT) - ); - } -} diff --git a/tests/output/javascript/src/e2e/analytics.test.ts b/tests/output/javascript/src/e2e/analytics.test.ts deleted file mode 100644 index 6ca6ed9d14..0000000000 --- a/tests/output/javascript/src/e2e/analytics.test.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -import { analyticsClient } from '@algolia/client-analytics'; -import * as dotenv from 'dotenv'; - -import { union } from '../helpers'; - -dotenv.config({ path: '../../.env' }); - -if (!process.env.ALGOLIA_APPLICATION_ID) { - throw new Error( - 'please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests' - ); -} - -if (!process.env.ALGOLIA_ADMIN_KEY) { - throw new Error( - 'please provide an `ALGOLIA_ADMIN_KEY` env var for e2e tests' - ); -} - -const client = analyticsClient( - process.env.ALGOLIA_APPLICATION_ID, - process.env.ALGOLIA_ADMIN_KEY, - 'us' -); - -describe('getTopSearches', () => { - test('e2e with complex query params', async () => { - const resp = await client.getTopSearches({ - index: 'cts_e2e_space in index', - }); - - const expectedBody = { searches: [{ search: '', nbHits: 0 }] }; - - expect(expectedBody).toEqual(union(expectedBody, resp)); - }); -}); diff --git a/tests/output/php/src/e2e/AnalyticsTest.php b/tests/output/php/src/e2e/AnalyticsTest.php deleted file mode 100644 index e9e9401c46..0000000000 --- a/tests/output/php/src/e2e/AnalyticsTest.php +++ /dev/null @@ -1,59 +0,0 @@ -load(); -} - -/** - * @internal - */ -#[CoversClass(AnalyticsClient::class)] -class AnalyticsTest extends TestCase -{ - #[TestDox('e2e with complex query params')] - public function testGetTopSearches2() - { - $client = $this->getClient(); - $resp = $client->getTopSearches( - 'cts_e2e_space in index', - ); - - $expected = json_decode('{"searches":[{"search":"","nbHits":0}]}', true); - - $this->assertEquals($this->union($expected, $resp), $expected); - } - - protected function union($expected, $received) - { - if (is_array($expected)) { - $res = []; - // array and object are the same thing in PHP (magic ✨) - foreach ($expected as $k => $v) { - $res[$k] = $this->union($v, $received[$k]); - } - - return $res; - } - - return $received; - } - - protected function getClient() - { - return AnalyticsClient::create($_ENV['ALGOLIA_APPLICATION_ID'], $_ENV['ALGOLIA_ADMIN_KEY'], 'us'); - } -} diff --git a/tests/output/python/tests/e2e/analytics_test.py b/tests/output/python/tests/e2e/analytics_test.py deleted file mode 100644 index 502bce98f2..0000000000 --- a/tests/output/python/tests/e2e/analytics_test.py +++ /dev/null @@ -1,40 +0,0 @@ -# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -from os import environ -from json import loads -from algoliasearch.analytics.client import AnalyticsClient -from ..helpers import Helpers -from dotenv import load_dotenv - -load_dotenv("../../.env") - - -class TestAnalyticsClientE2E: - _helpers = Helpers() - _e2e_app_id = environ.get("ALGOLIA_APPLICATION_ID") - if _e2e_app_id is None: - raise Exception( - "please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests" - ) - - _e2e_api_key = environ.get("ALGOLIA_ADMIN_KEY") - if _e2e_api_key is None: - raise Exception("please provide an `ALGOLIA_ADMIN_KEY` env var for e2e tests") - - async def test_get_top_searches_2(self): - """ - e2e with complex query params - """ - raw_resp = await AnalyticsClient( - self._e2e_app_id, self._e2e_api_key, "us" - ).get_top_searches_with_http_info( - index="cts_e2e_space in index", - ) - assert raw_resp.status_code == 200 - - resp = await AnalyticsClient( - self._e2e_app_id, self._e2e_api_key, "us" - ).get_top_searches( - index="cts_e2e_space in index", - ) - _expected_body = loads("""{"searches":[{"search":"","nbHits":0}]}""") - assert self._helpers.union(_expected_body, resp) == _expected_body diff --git a/tests/output/ruby/test/e2e/analytics_test.rb b/tests/output/ruby/test/e2e/analytics_test.rb deleted file mode 100644 index 66e9d773cc..0000000000 --- a/tests/output/ruby/test/e2e/analytics_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -require "algolia" -require "test/unit" -require "dotenv" - -require_relative "../helpers" - -Dotenv.load("../../.env") - -class TestAnalyticsClientE2E < Test::Unit::TestCase - include Algolia::Analytics - def setup - @client = Algolia::AnalyticsClient.create( - ENV.fetch("ALGOLIA_APPLICATION_ID", nil), - ENV.fetch("ALGOLIA_ADMIN_KEY", nil), - "us" - ) - end - - # e2e with complex query params - def test_get_top_searches2 - res = @client.get_top_searches_with_http_info("cts_e2e_space in index") - - assert_equal(res.status, 200) - res = @client.get_top_searches("cts_e2e_space in index") - expected_body = JSON.parse("{\"searches\":[{\"search\":\"\",\"nbHits\":0}]}") - assert_equal(expected_body, union(expected_body, JSON.parse(res.to_json))) - end - -end diff --git a/tests/output/scala/src/test/scala/algoliasearch/e2e/AnalyticsTest.scala b/tests/output/scala/src/test/scala/algoliasearch/e2e/AnalyticsTest.scala deleted file mode 100644 index a9bdf43149..0000000000 --- a/tests/output/scala/src/test/scala/algoliasearch/e2e/AnalyticsTest.scala +++ /dev/null @@ -1,51 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -package algoliasearch.e2e - -import algoliasearch.api.AnalyticsClient -import algoliasearch.config.* -import algoliasearch.analytics.* -import org.json4s.* -import org.json4s.native.JsonParser.* -import org.scalatest.funsuite.AnyFunSuite -import io.github.cdimascio.dotenv.Dotenv -import org.skyscreamer.jsonassert.JSONCompare.compareJSON -import org.skyscreamer.jsonassert.JSONCompareMode -import org.json4s.native.Serialization -import org.json4s.native.Serialization.write - -import scala.concurrent.duration.Duration -import scala.concurrent.{Await, ExecutionContextExecutor} - -class AnalyticsTestE2E extends AnyFunSuite { - implicit val ec: ExecutionContextExecutor = scala.concurrent.ExecutionContext.global - implicit val formats: Formats = org.json4s.DefaultFormats - - def testClient(): AnalyticsClient = { - val region = Some("us") - if (System.getenv("CI") == "true") { - AnalyticsClient( - appId = System.getenv("ALGOLIA_APPLICATION_ID"), - apiKey = System.getenv("ALGOLIA_ADMIN_KEY"), - region = region - ) - } else { - val dotenv = Dotenv.configure.directory("../../").load - AnalyticsClient( - appId = dotenv.get("ALGOLIA_APPLICATION_ID"), - apiKey = dotenv.get("ALGOLIA_ADMIN_KEY"), - region = region - ) - } - } - - test("e2e with complex query params2") { - val client = testClient() - val future = client.getTopSearches( - index = "cts_e2e_space in index" - ) - - val response = Await.result(future, Duration.Inf) - compareJSON("""{"searches":[{"search":"","nbHits":0}]}""", write(response), JSONCompareMode.LENIENT) - } - -} diff --git a/tests/output/swift/Tests/e2e/AnalyticsTests.swift b/tests/output/swift/Tests/e2e/AnalyticsTests.swift deleted file mode 100644 index fa7b87786e..0000000000 --- a/tests/output/swift/Tests/e2e/AnalyticsTests.swift +++ /dev/null @@ -1,69 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on -// https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import XCTest - -import DotEnv -import Utils - -@testable import Analytics -@testable import Core - -final class AnalyticsClientRequestsTestsE2E: XCTestCase { - static var APPLICATION_ID = "my_application_id" - static var API_KEY = "my_api_key" - static var client: AnalyticsClient? - - override class func setUp() { - if !(Bool(ProcessInfo.processInfo.environment["CI"] ?? "false") ?? false) { - do { - let currentFileURL = try XCTUnwrap(URL(string: #file)) - - let packageDirectoryURL = currentFileURL - .deletingLastPathComponent() - .deletingLastPathComponent() - .deletingLastPathComponent() - .deletingLastPathComponent() - .deletingLastPathComponent() - - let dotEnvURL = packageDirectoryURL - .appendingPathComponent(".env") - dump(dotEnvURL.absoluteString) - try DotEnv.load(path: dotEnvURL.absoluteString, encoding: .utf8, overwrite: true) - } catch { - XCTFail("Unable to load .env file") - } - } - - do { - self.APPLICATION_ID = try XCTUnwrap(ProcessInfo.processInfo.environment["ALGOLIA_APPLICATION_ID"]) - } catch { - XCTFail("Please provide an `ALGOLIA_APPLICATION_ID` env var for e2e tests") - } - - do { - self.API_KEY = try XCTUnwrap(ProcessInfo.processInfo.environment["ALGOLIA_ADMIN_KEY"]) - } catch { - XCTFail("Please provide an `ALGOLIA_ADMIN_KEY` env var for e2e tests") - } - - self.client = try? AnalyticsClient(appID: self.APPLICATION_ID, apiKey: self.API_KEY, region: .us) - } - - /// e2e with complex query params - func testGetTopSearchesTest2() async throws { - guard let client = AnalyticsClientRequestsTestsE2E.client else { - XCTFail("E2E client is not initialized") - return - } - - let response = try await client.getTopSearchesWithHTTPInfo(index: "cts_e2e_space in index") - let responseBody = try XCTUnwrap(response.body) - let responseBodyData = try CodableHelper.jsonEncoder.encode(responseBody) - - let expectedBodyData = try XCTUnwrap("{\"searches\":[{\"search\":\"\",\"nbHits\":0}]}".data(using: .utf8)) - - XCTLenientAssertEqual(received: responseBodyData, expected: expectedBodyData) - - XCTAssertEqual(response.statusCode, 200) - } -} From 4ceb5e56baa991dd98f86b22b4b6387b438797c3 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 30 Aug 2024 13:04:16 +0200 Subject: [PATCH 2/5] new json formatter --- .eslintrc.cjs | 6 +- eslint/tsconfig.json | 3 +- package.json | 2 +- tests/CTS/requests/search/getRule.json | 4 +- yarn.lock | 226 ++++++++----------------- 5 files changed, 76 insertions(+), 165 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 5ef842ec40..a647d823dd 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -196,8 +196,10 @@ module.exports = { }, { files: ['*.json'], - - plugins: ['json-format'], + parserOptions: { + extraFileExtensions: ['.json'], + }, + extends: ["plugin:json/recommended-legacy"] }, { files: ['templates/**/*.mustache'], diff --git a/eslint/tsconfig.json b/eslint/tsconfig.json index fc8a45b660..8eadaa6722 100644 --- a/eslint/tsconfig.json +++ b/eslint/tsconfig.json @@ -5,7 +5,8 @@ }, "include": [ "src/**/*.ts", - "tests/**/*.ts" + "tests/**/*.ts", + "package.json", ], "exclude": [ "node_modules", diff --git a/package.json b/package.json index 3de9ac7365..cb83729724 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "eslint-plugin-eslint-comments": "3.2.0", "eslint-plugin-import": "2.29.1", "eslint-plugin-jsdoc": "50.2.2", - "eslint-plugin-json-format": "2.0.1", + "eslint-plugin-json": "4.0.1", "eslint-plugin-prettier": "5.2.1", "eslint-plugin-unused-imports": "3.2.0", "eslint-plugin-yml": "1.14.0", diff --git a/tests/CTS/requests/search/getRule.json b/tests/CTS/requests/search/getRule.json index 1bd1550908..68b83e1c8e 100644 --- a/tests/CTS/requests/search/getRule.json +++ b/tests/CTS/requests/search/getRule.json @@ -10,9 +10,7 @@ }, "response": { "status": 200, - "body": { - "description": "test_rule", - "enabled": true, + "body": { "description": "test_rule", "enabled": true, "objectID": "qr-1725004648916", "conditions": [ { diff --git a/yarn.lock b/yarn.lock index 3dc4322351..9c7669debd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -94,7 +94,7 @@ __metadata: eslint-plugin-eslint-comments: "npm:3.2.0" eslint-plugin-import: "npm:2.29.1" eslint-plugin-jsdoc: "npm:50.2.2" - eslint-plugin-json-format: "npm:2.0.1" + eslint-plugin-json: "npm:4.0.1" eslint-plugin-prettier: "npm:5.2.1" eslint-plugin-unused-imports: "npm:3.2.0" eslint-plugin-yml: "npm:1.14.0" @@ -1683,7 +1683,7 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:^7.17.8, @babel/runtime@npm:^7.18.9, @babel/runtime@npm:^7.21.0, @babel/runtime@npm:^7.8.4": +"@babel/runtime@npm:^7.17.8, @babel/runtime@npm:^7.21.0, @babel/runtime@npm:^7.8.4": version: 7.25.4 resolution: "@babel/runtime@npm:7.25.4" dependencies: @@ -4565,16 +4565,6 @@ __metadata: languageName: node linkType: hard -"@types/glob@npm:^7.1.1": - version: 7.2.0 - resolution: "@types/glob@npm:7.2.0" - dependencies: - "@types/minimatch": "npm:*" - "@types/node": "npm:*" - checksum: 10/6ae717fedfdfdad25f3d5a568323926c64f52ef35897bcac8aca8e19bc50c0bd84630bbd063e5d52078b2137d8e7d3c26eabebd1a2f03ff350fff8a91e79fc19 - languageName: node - linkType: hard - "@types/graceful-fs@npm:^4.1.3": version: 4.1.9 resolution: "@types/graceful-fs@npm:4.1.9" @@ -4672,13 +4662,6 @@ __metadata: languageName: node linkType: hard -"@types/minimatch@npm:*": - version: 5.1.2 - resolution: "@types/minimatch@npm:5.1.2" - checksum: 10/94db5060d20df2b80d77b74dd384df3115f01889b5b6c40fa2dfa27cfc03a68fb0ff7c1f2a0366070263eb2e9d6bfd8c87111d4bc3ae93c3f291297c1bf56c85 - languageName: node - linkType: hard - "@types/node@npm:*, @types/node@npm:22.5.0": version: 22.5.0 resolution: "@types/node@npm:22.5.0" @@ -5755,7 +5738,7 @@ __metadata: languageName: node linkType: hard -"chalk@npm:4.1.2, chalk@npm:^4.0.0, chalk@npm:^4.1.0, chalk@npm:^4.1.1, chalk@npm:^4.1.2": +"chalk@npm:4.1.2, chalk@npm:^4.0.0, chalk@npm:^4.1.0, chalk@npm:^4.1.1": version: 4.1.2 resolution: "chalk@npm:4.1.2" dependencies: @@ -6086,13 +6069,6 @@ __metadata: languageName: node linkType: hard -"common-tags@npm:^1.8.0": - version: 1.8.2 - resolution: "common-tags@npm:1.8.2" - checksum: 10/c665d0f463ee79dda801471ad8da6cb33ff7332ba45609916a508ad3d77ba07ca9deeb452e83f81f24c2b081e2c1315347f23d239210e63d1c5e1a0c7c019fe2 - languageName: node - linkType: hard - "compare-versions@npm:4.1.4": version: 4.1.4 resolution: "compare-versions@npm:4.1.4" @@ -6532,13 +6508,6 @@ __metadata: languageName: node linkType: hard -"detect-indent@npm:^6.0.0": - version: 6.1.0 - resolution: "detect-indent@npm:6.1.0" - checksum: 10/ab953a73c72dbd4e8fc68e4ed4bfd92c97eb6c43734af3900add963fd3a9316f3bc0578b018b24198d4c31a358571eff5f0656e81a1f3b9ad5c547d58b2d093d - languageName: node - linkType: hard - "detect-libc@npm:^1.0.3": version: 1.0.3 resolution: "detect-libc@npm:1.0.3" @@ -6555,20 +6524,13 @@ __metadata: languageName: node linkType: hard -"detect-newline@npm:3.1.0, detect-newline@npm:^3.0.0": +"detect-newline@npm:^3.0.0": version: 3.1.0 resolution: "detect-newline@npm:3.1.0" checksum: 10/ae6cd429c41ad01b164c59ea36f264a2c479598e61cba7c99da24175a7ab80ddf066420f2bec9a1c57a6bead411b4655ff15ad7d281c000a89791f48cbe939e7 languageName: node linkType: hard -"diff-match-patch@npm:^1.0.4": - version: 1.0.5 - resolution: "diff-match-patch@npm:1.0.5" - checksum: 10/fd1ab417eba9559bda752a4dfc9a8ac73fa2ca8b146d29d153964b437168e301c09d8a688fae0cd81d32dc6508a4918a94614213c85df760793f44e245173bb6 - languageName: node - linkType: hard - "diff-sequences@npm:^29.6.3": version: 29.6.3 resolution: "diff-sequences@npm:29.6.3" @@ -7313,21 +7275,13 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-json-format@npm:2.0.1": - version: 2.0.1 - resolution: "eslint-plugin-json-format@npm:2.0.1" +"eslint-plugin-json@npm:4.0.1": + version: 4.0.1 + resolution: "eslint-plugin-json@npm:4.0.1" dependencies: - common-tags: "npm:^1.8.0" - debug: "npm:^4.1.1" - diff-match-patch: "npm:^1.0.4" - json-fixer: "npm:^1.3.2" - line-column: "npm:^1.0.2" - lodash: "npm:^4.17.15" - minimatch: "npm:^3.0.4" - sort-package-json: "npm:^1.22.1" - peerDependencies: - eslint: ">= 3.2.1" - checksum: 10/1f99cf21ca76695c242ab5df1f4d8ad863e8e2477b774a98e1bcffdce476a5027ad6dd321472c97ea1d94d561ba26e9e36d3268a639c69d8ede7e49fc1f5a8ac + lodash: "npm:^4.17.21" + vscode-json-languageservice: "npm:^4.1.6" + checksum: 10/d891eb5326cca9af5d4a2ebdef5e04761d9a2fca56841d533f755dd475539818d9f43cc7f1e19952276fca8493ea58b4e143ee68f75b2971e2ea8e5e244e0929 languageName: node linkType: hard @@ -7737,7 +7691,7 @@ __metadata: languageName: node linkType: hard -"fast-glob@npm:^3.0.3, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.1, fast-glob@npm:^3.3.2": +"fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.1, fast-glob@npm:^3.3.2": version: 3.3.2 resolution: "fast-glob@npm:3.3.2" dependencies: @@ -8160,13 +8114,6 @@ __metadata: languageName: node linkType: hard -"git-hooks-list@npm:1.0.3": - version: 1.0.3 - resolution: "git-hooks-list@npm:1.0.3" - checksum: 10/a1dd03d39c1d727ba08a35dbdbdcc6e96de8c4170c942dc95bf787ca6e34998d39fb5295a00242b58a3d265de0b69a0686d0cf583baa6b7830f268542c4576b9 - languageName: node - linkType: hard - "glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2": version: 5.1.2 resolution: "glob-parent@npm:5.1.2" @@ -8241,22 +8188,6 @@ __metadata: languageName: node linkType: hard -"globby@npm:10.0.0": - version: 10.0.0 - resolution: "globby@npm:10.0.0" - dependencies: - "@types/glob": "npm:^7.1.1" - array-union: "npm:^2.1.0" - dir-glob: "npm:^3.0.1" - fast-glob: "npm:^3.0.3" - glob: "npm:^7.1.3" - ignore: "npm:^5.1.1" - merge2: "npm:^1.2.3" - slash: "npm:^3.0.0" - checksum: 10/d0c94128706b5e12a251ddbd1b87cf0e67e57e373c816f242bb7a4a2fbe931602db1a330780d511a5bce675c25fac297622ac01d540c8479cca9c8177528947a - languageName: node - linkType: hard - "globby@npm:^11.1.0": version: 11.1.0 resolution: "globby@npm:11.1.0" @@ -8549,7 +8480,7 @@ __metadata: languageName: node linkType: hard -"ignore@npm:^5.0.5, ignore@npm:^5.1.1, ignore@npm:^5.1.8, ignore@npm:^5.2.0, ignore@npm:^5.3.1": +"ignore@npm:^5.0.5, ignore@npm:^5.1.8, ignore@npm:^5.2.0, ignore@npm:^5.3.1": version: 5.3.2 resolution: "ignore@npm:5.3.2" checksum: 10/cceb6a457000f8f6a50e1196429750d782afce5680dd878aa4221bd79972d68b3a55b4b1458fc682be978f4d3c6a249046aa0880637367216444ab7b014cfc98 @@ -8836,13 +8767,6 @@ __metadata: languageName: node linkType: hard -"is-plain-obj@npm:2.1.0": - version: 2.1.0 - resolution: "is-plain-obj@npm:2.1.0" - checksum: 10/cec9100678b0a9fe0248a81743041ed990c2d4c99f893d935545cfbc42876cbe86d207f3b895700c690ad2fa520e568c44afc1605044b535a7820c1d40e38daa - languageName: node - linkType: hard - "is-plain-obj@npm:^4.1.0": version: 4.1.0 resolution: "is-plain-obj@npm:4.1.0" @@ -8947,13 +8871,6 @@ __metadata: languageName: node linkType: hard -"isarray@npm:1.0.0, isarray@npm:^1.0.0, isarray@npm:~1.0.0": - version: 1.0.0 - resolution: "isarray@npm:1.0.0" - checksum: 10/f032df8e02dce8ec565cf2eb605ea939bdccea528dbcf565cdf92bfa2da9110461159d86a537388ef1acef8815a330642d7885b29010e8f7eac967c9993b65ab - languageName: node - linkType: hard - "isarray@npm:^2.0.5": version: 2.0.5 resolution: "isarray@npm:2.0.5" @@ -8961,6 +8878,13 @@ __metadata: languageName: node linkType: hard +"isarray@npm:~1.0.0": + version: 1.0.0 + resolution: "isarray@npm:1.0.0" + checksum: 10/f032df8e02dce8ec565cf2eb605ea939bdccea528dbcf565cdf92bfa2da9110461159d86a537388ef1acef8815a330642d7885b29010e8f7eac967c9993b65ab + languageName: node + linkType: hard + "isexe@npm:^2.0.0": version: 2.0.0 resolution: "isexe@npm:2.0.0" @@ -8975,15 +8899,6 @@ __metadata: languageName: node linkType: hard -"isobject@npm:^2.0.0": - version: 2.1.0 - resolution: "isobject@npm:2.1.0" - dependencies: - isarray: "npm:1.0.0" - checksum: 10/811c6f5a866877d31f0606a88af4a45f282544de886bf29f6a34c46616a1ae2ed17076cc6bf34c0128f33eecf7e1fcaa2c82cf3770560d3e26810894e96ae79f - languageName: node - linkType: hard - "istanbul-lib-coverage@npm:^3.0.0, istanbul-lib-coverage@npm:^3.2.0": version: 3.2.2 resolution: "istanbul-lib-coverage@npm:3.2.2" @@ -9637,17 +9552,6 @@ __metadata: languageName: node linkType: hard -"json-fixer@npm:^1.3.2": - version: 1.6.15 - resolution: "json-fixer@npm:1.6.15" - dependencies: - "@babel/runtime": "npm:^7.18.9" - chalk: "npm:^4.1.2" - pegjs: "npm:^0.10.0" - checksum: 10/240d6ad7ed8438159ad6ef97e75180f61361a54a32354e5e57f69f6974d844e4019533bbf960c00a180011225bc7bd17a6a63a4292e66e6259c7f2fe977a6097 - languageName: node - linkType: hard - "json-parse-even-better-errors@npm:^2.3.0": version: 2.3.1 resolution: "json-parse-even-better-errors@npm:2.3.1" @@ -9705,6 +9609,13 @@ __metadata: languageName: node linkType: hard +"jsonc-parser@npm:^3.0.0": + version: 3.3.1 + resolution: "jsonc-parser@npm:3.3.1" + checksum: 10/9b0dc391f20b47378f843ef1e877e73ec652a5bdc3c5fa1f36af0f119a55091d147a86c1ee86a232296f55c929bba174538c2bf0312610e0817a22de131cc3f4 + languageName: node + linkType: hard + "jsonfile@npm:^6.0.1": version: 6.1.0 resolution: "jsonfile@npm:6.1.0" @@ -9914,16 +9825,6 @@ __metadata: languageName: node linkType: hard -"line-column@npm:^1.0.2": - version: 1.0.2 - resolution: "line-column@npm:1.0.2" - dependencies: - isarray: "npm:^1.0.0" - isobject: "npm:^2.0.0" - checksum: 10/955c60d175e18d925057fa8a29f051eb8bf363d07bd2a7237a421442368855725ff2868690add1add1884833621f18873c228e2d17ba859d6c69ab0a53e88868 - languageName: node - linkType: hard - "lines-and-columns@npm:^1.1.6": version: 1.2.4 resolution: "lines-and-columns@npm:1.2.4" @@ -10219,7 +10120,7 @@ __metadata: languageName: node linkType: hard -"merge2@npm:^1.2.3, merge2@npm:^1.3.0, merge2@npm:^1.4.1": +"merge2@npm:^1.3.0, merge2@npm:^1.4.1": version: 1.4.1 resolution: "merge2@npm:1.4.1" checksum: 10/7268db63ed5169466540b6fb947aec313200bcf6d40c5ab722c22e242f651994619bcd85601602972d3c85bd2cc45a358a4c61937e9f11a061919a1da569b0c2 @@ -11208,15 +11109,6 @@ __metadata: languageName: node linkType: hard -"pegjs@npm:^0.10.0": - version: 0.10.0 - resolution: "pegjs@npm:0.10.0" - bin: - pegjs: bin/pegjs - checksum: 10/edc12c9da9afa68ea1274350c3843026355ef3678de0e24213ba0598ee660d40f6752548ba5ddfbcdefee1904545c8a23bb59f331a5e8b3543bee29c21051f67 - languageName: node - linkType: hard - "perfect-scrollbar@npm:^1.5.5": version: 1.5.5 resolution: "perfect-scrollbar@npm:1.5.5" @@ -12458,29 +12350,6 @@ __metadata: languageName: node linkType: hard -"sort-object-keys@npm:^1.1.3": - version: 1.1.3 - resolution: "sort-object-keys@npm:1.1.3" - checksum: 10/abea944d6722a1710a1aa6e4f9509da085d93d5fc0db23947cb411eedc7731f80022ce8fa68ed83a53dd2ac7441fcf72a3f38c09b3d9bbc4ff80546aa2e151ad - languageName: node - linkType: hard - -"sort-package-json@npm:^1.22.1": - version: 1.57.0 - resolution: "sort-package-json@npm:1.57.0" - dependencies: - detect-indent: "npm:^6.0.0" - detect-newline: "npm:3.1.0" - git-hooks-list: "npm:1.0.3" - globby: "npm:10.0.0" - is-plain-obj: "npm:2.1.0" - sort-object-keys: "npm:^1.1.3" - bin: - sort-package-json: cli.js - checksum: 10/abc217315070ffd6559b32b95917b92c8376880c0d17b4ad2b0eeacdffb38bf723b892a56c56d91ae6999fca3369bfdf5e29b1b02b2fc944b0cbb299c069d0e8 - languageName: node - linkType: hard - "source-map-js@npm:^1.2.0": version: 1.2.0 resolution: "source-map-js@npm:1.2.0" @@ -13651,6 +13520,47 @@ __metadata: languageName: node linkType: hard +"vscode-json-languageservice@npm:^4.1.6": + version: 4.2.1 + resolution: "vscode-json-languageservice@npm:4.2.1" + dependencies: + jsonc-parser: "npm:^3.0.0" + vscode-languageserver-textdocument: "npm:^1.0.3" + vscode-languageserver-types: "npm:^3.16.0" + vscode-nls: "npm:^5.0.0" + vscode-uri: "npm:^3.0.3" + checksum: 10/ebd3dd037cfb5ede73eaf5c634463aa2609014d544b6b97505d6e062e9bc8cb80f049d52939354a27acd7d26f48af3d95e6546598d60b1a384e6877f1eca7d0c + languageName: node + linkType: hard + +"vscode-languageserver-textdocument@npm:^1.0.3": + version: 1.0.12 + resolution: "vscode-languageserver-textdocument@npm:1.0.12" + checksum: 10/2bc0fde952d40f35a31179623d1491b0fafdee156aaf58557f40f5d394a25fc84826763cdde55fa6ce2ed9cd35a931355ad6dd7fe5db82e7f21e5d865f0af8c6 + languageName: node + linkType: hard + +"vscode-languageserver-types@npm:^3.16.0": + version: 3.17.5 + resolution: "vscode-languageserver-types@npm:3.17.5" + checksum: 10/900d0b81df5bef8d90933e75be089142f6989cc70fdb2d5a3a5f11fa20feb396aaea23ccffc8fbcc83a2f0e1b13c6ee48ff8151f236cbd6e61a4f856efac1a58 + languageName: node + linkType: hard + +"vscode-nls@npm:^5.0.0": + version: 5.2.0 + resolution: "vscode-nls@npm:5.2.0" + checksum: 10/7dd0d07e5f1fd7a7d1b35eabea20322e2efef4e93cebe6de45ee015ea0152ec1c354fd763d3987aed1db261f466ff31631d6acd679ac67af608fb49b9868e1ab + languageName: node + linkType: hard + +"vscode-uri@npm:^3.0.3": + version: 3.0.8 + resolution: "vscode-uri@npm:3.0.8" + checksum: 10/e882d6b679e0d053cbc042893c0951a135d899a192b62cd07f0a8924f11ae722067a8d6b1b5b147034becf57faf9fff9fb543b17b749fd0f17db1f54f783f07c + languageName: node + linkType: hard + "walker@npm:^1.0.8": version: 1.0.8 resolution: "walker@npm:1.0.8" From 910a6676c2e27a687a12830744184d51a202a5c7 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 30 Aug 2024 13:27:29 +0200 Subject: [PATCH 3/5] fix all --- .../java/com/algolia/codegen/AlgoliaSwiftGenerator.java | 1 + specs/common/schemas/IndexSettings.yml | 2 +- .../javascript/clients/algoliasearch/builds/models.mustache | 2 ++ tests/CTS/requests/search/getRule.json | 6 ++++-- tests/CTS/requests/search/searchRules.json | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/generators/src/main/java/com/algolia/codegen/AlgoliaSwiftGenerator.java b/generators/src/main/java/com/algolia/codegen/AlgoliaSwiftGenerator.java index 8b1706079e..5b41a2e6cf 100644 --- a/generators/src/main/java/com/algolia/codegen/AlgoliaSwiftGenerator.java +++ b/generators/src/main/java/com/algolia/codegen/AlgoliaSwiftGenerator.java @@ -45,6 +45,7 @@ public class AlgoliaSwiftGenerator extends Swift5ClientCodegen { "basesearchresponse", "batchrequest", "batchwriteparams", + "booleanstring", "condition", "configuration", "consequence", diff --git a/specs/common/schemas/IndexSettings.yml b/specs/common/schemas/IndexSettings.yml index b9ba3f4cf3..41cdc0be79 100644 --- a/specs/common/schemas/IndexSettings.yml +++ b/specs/common/schemas/IndexSettings.yml @@ -957,12 +957,12 @@ ignorePlurals: This overrides languages you set with `queryLanguages`. items: $ref: '#/supportedLanguage' + - $ref: '#/booleanString' - type: boolean description: | If true, `ignorePlurals` is active for all languages included in `queryLanguages`, or for all supported languages, if `queryLanguges` is empty. If false, singulars, plurals, and other declensions won't be considered equivalent. default: false - - $ref: '#/booleanString' x-categories: - Languages diff --git a/templates/javascript/clients/algoliasearch/builds/models.mustache b/templates/javascript/clients/algoliasearch/builds/models.mustache index 6b7b04e7a9..db607a929e 100644 --- a/templates/javascript/clients/algoliasearch/builds/models.mustache +++ b/templates/javascript/clients/algoliasearch/builds/models.mustache @@ -18,6 +18,7 @@ import { BaseSearchParams, BaseSearchParamsWithoutQuery, BaseSearchResponse, + BooleanString, Condition, Consequence, ConsequenceHide, @@ -104,6 +105,7 @@ export { BaseSearchParams, BaseSearchParamsWithoutQuery, BaseSearchResponse, + BooleanString, Condition, Consequence, ConsequenceHide, diff --git a/tests/CTS/requests/search/getRule.json b/tests/CTS/requests/search/getRule.json index 68b83e1c8e..d12a158df8 100644 --- a/tests/CTS/requests/search/getRule.json +++ b/tests/CTS/requests/search/getRule.json @@ -9,8 +9,10 @@ "method": "GET" }, "response": { - "status": 200, - "body": { "description": "test_rule", "enabled": true, + "statusCode": 200, + "body": { + "description": "test_rule", + "enabled": true, "objectID": "qr-1725004648916", "conditions": [ { diff --git a/tests/CTS/requests/search/searchRules.json b/tests/CTS/requests/search/searchRules.json index b51ddb296b..37beb8651f 100644 --- a/tests/CTS/requests/search/searchRules.json +++ b/tests/CTS/requests/search/searchRules.json @@ -14,7 +14,7 @@ } }, "response": { - "status": 200, + "statusCode": 200, "body": { "hits": [ { From 6bcca567e1f58a3a5cdae441e76363a67f7c10e3 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 30 Aug 2024 15:05:10 +0200 Subject: [PATCH 4/5] fix ruby --- .../lib/algolia/api_client.rb | 2 +- templates/ruby/partial_model_generic.mustache | 24 ------------------- templates/ruby/partial_oneof_module.mustache | 8 +++++-- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/clients/algoliasearch-client-ruby/lib/algolia/api_client.rb b/clients/algoliasearch-client-ruby/lib/algolia/api_client.rb index 8fd2e0c8a8..4438762206 100644 --- a/clients/algoliasearch-client-ruby/lib/algolia/api_client.rb +++ b/clients/algoliasearch-client-ruby/lib/algolia/api_client.rb @@ -93,7 +93,7 @@ def convert_to_type(data, return_type) data.each { |k, v| hash[k] = convert_to_type(v, sub_type) } end else - # models (e.g. Pet) or oneOf + # models (e.g. Pet), enum, or oneOf klass = Algolia.const_get(return_type) klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data) end diff --git a/templates/ruby/partial_model_generic.mustache b/templates/ruby/partial_model_generic.mustache index 1bbb9117f2..a1fbfb3d2e 100644 --- a/templates/ruby/partial_model_generic.mustache +++ b/templates/ruby/partial_model_generic.mustache @@ -13,30 +13,6 @@ attr_accessor :additional_properties {{/getAdditionalPropertiesIsAnyType}} -{{#hasEnums}} - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - -{{/hasEnums}} # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/templates/ruby/partial_oneof_module.mustache b/templates/ruby/partial_oneof_module.mustache index 3a32bab4a9..53b671cdf6 100644 --- a/templates/ruby/partial_oneof_module.mustache +++ b/templates/ruby/partial_oneof_module.mustache @@ -116,12 +116,16 @@ else # model const = {{moduleName}}::{{modelModule}}.const_get(klass) if const - if const.respond_to?(:openapi_one_of) # nested oneOf model + if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + elsif const.respond_to?(:acceptable_attributes) # raise if data contains keys that are not known to the model raise unless (data.keys - const.acceptable_attributes).empty? model = const.build_from_hash(data) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model From 7e33a1bda4fc9768939fbbfa1feeeb0356540ca7 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 30 Aug 2024 15:14:42 +0200 Subject: [PATCH 5/5] quotes --- specs/common/schemas/IndexSettings.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/common/schemas/IndexSettings.yml b/specs/common/schemas/IndexSettings.yml index 41cdc0be79..f4e104816d 100644 --- a/specs/common/schemas/IndexSettings.yml +++ b/specs/common/schemas/IndexSettings.yml @@ -1173,5 +1173,5 @@ supportedLanguage: booleanString: type: string enum: - - true - - false + - 'true' + - 'false'