diff --git a/.github/.cache_version b/.github/.cache_version index 759a4a15f5..48c15efb15 100644 --- a/.github/.cache_version +++ b/.github/.cache_version @@ -1 +1 @@ -0.0.105 +0.0.108 diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/__tests__/algoliasearch.test.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch/__tests__/algoliasearch.test.ts index 163829b161..c46e998095 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/__tests__/algoliasearch.test.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/__tests__/algoliasearch.test.ts @@ -23,7 +23,7 @@ describe('api', () => { }); it('sets the user agent', async () => { - const req = (await client.post({ + const req = (await client.customPost({ path: '/test', })) as unknown as EchoResponse; @@ -166,13 +166,13 @@ describe('api', () => { region: 'eu', }); - const res1 = (await abtestingClient.get({ + const res1 = (await abtestingClient.customGet({ path: 'abtestingClient', })) as unknown as EchoResponse; - const res2 = (await analyticsClient.get({ + const res2 = (await analyticsClient.customGet({ path: 'analyticsClient', })) as unknown as EchoResponse; - const res3 = (await personalizationClient.get({ + const res3 = (await personalizationClient.customGet({ path: 'personalizationClient', })) as unknown as EchoResponse; @@ -211,13 +211,13 @@ describe('api', () => { region: 'eu', }); - const res1 = (await abtestingClient.get({ + const res1 = (await abtestingClient.customGet({ path: 'abtestingClient', })) as unknown as EchoResponse; - const res2 = (await analyticsClient.get({ + const res2 = (await analyticsClient.customGet({ path: 'analyticsClient', })) as unknown as EchoResponse; - const res3 = (await personalizationClient.get({ + const res3 = (await personalizationClient.customGet({ path: 'personalizationClient', })) as unknown as EchoResponse; diff --git a/generators/src/main/java/com/algolia/codegen/utils/Helpers.java b/generators/src/main/java/com/algolia/codegen/utils/Helpers.java index 7187bb7840..786231f476 100644 --- a/generators/src/main/java/com/algolia/codegen/utils/Helpers.java +++ b/generators/src/main/java/com/algolia/codegen/utils/Helpers.java @@ -17,7 +17,7 @@ public class Helpers { /** The suffix of our client names. */ public static final String API_SUFFIX = "Client"; - public static final Set CUSTOM_METHODS = Set.of("del", "get", "post", "put"); + public static final Set CUSTOM_METHODS = Set.of("customDelete", "customGet", "customPost", "customPut"); private static JsonNode cacheConfig; private static JsonNode cacheOpenApiToolsConfig; diff --git a/scripts/buildSpecs.ts b/scripts/buildSpecs.ts index 66fb538a0e..659333674f 100644 --- a/scripts/buildSpecs.ts +++ b/scripts/buildSpecs.ts @@ -6,7 +6,7 @@ import { checkForCache, exists, run, toAbsolutePath } from './common.js'; import { createSpinner } from './spinners.js'; import type { Spec } from './types.js'; -const ALGOLIASEARCH_LITE_OPERATIONS = ['search', 'post']; +const ALGOLIASEARCH_LITE_OPERATIONS = ['search', 'customPost']; /** * This function will transform properties in the bundle depending on the context. @@ -142,8 +142,8 @@ async function buildLiteSpec({ // Filter methods. parsed.paths = Object.entries(parsed.paths).reduce( (acc, [path, operations]) => { - for (const [method, operation] of Object.entries(operations)) { - if (method === 'post' && ALGOLIASEARCH_LITE_OPERATIONS.includes(operation.operationId)) { + for (const [, operation] of Object.entries(operations)) { + if (ALGOLIASEARCH_LITE_OPERATIONS.includes(operation.operationId)) { return { ...acc, [path]: { post: operation } }; } } diff --git a/specs/common/paths/customRequest.yml b/specs/common/paths/customRequest.yml index c8c7528d23..2476f7419b 100644 --- a/specs/common/paths/customRequest.yml +++ b/specs/common/paths/customRequest.yml @@ -1,9 +1,9 @@ get: - operationId: get + operationId: customGet $ref: '../schemas/CustomRequest.yml#/customRequest' post: - operationId: post + operationId: customPost requestBody: description: Parameters to send with the custom request. content: @@ -13,7 +13,7 @@ post: $ref: '../schemas/CustomRequest.yml#/customRequest' put: - operationId: put + operationId: customPut requestBody: description: Parameters to send with the custom request. content: @@ -23,5 +23,5 @@ put: $ref: '../schemas/CustomRequest.yml#/customRequest' delete: - operationId: del + operationId: customDelete $ref: '../schemas/CustomRequest.yml#/customRequest' diff --git a/templates/dart/api.mustache b/templates/dart/api.mustache index beb8ab7f5a..93af39666a 100644 --- a/templates/dart/api.mustache +++ b/templates/dart/api.mustache @@ -157,7 +157,45 @@ final class {{classname}} implements ApiClient { } {{/operation}} + @Deprecated('This operation has been deprecated, use `customPost` instead') + Future post({ + required String path, + Map? parameters, Object? body, + RequestOptions? requestOptions, + }) async { + return this.customPost(path: path, parameters: parameters, requestOptions: requestOptions); + } + + {{^isAlgoliasearchClient}} + @Deprecated('This operation has been deprecated, use `customPut` instead') + Future put({ + required String path, + Map? parameters, Object? body, + RequestOptions? requestOptions, + }) async { + return customPut(path: path, parameters: parameters, requestOptions: requestOptions); + } + + @Deprecated('This operation has been deprecated, use `customGet` instead') + Future get({ + required String path, + Map? parameters, Object? body, + RequestOptions? requestOptions, + }) async { + return this.customGet(path: path, parameters: parameters, requestOptions: requestOptions); + } + + @Deprecated('This operation has been deprecated, use `customDelete` instead') + Future del({ + required String path, + Map? parameters, Object? body, + RequestOptions? requestOptions, + }) async { + return this.customDelete(path: path, parameters: parameters, requestOptions: requestOptions); + } + {{/isAlgoliasearchClient}} + @override void dispose() => _retryStrategy.dispose(); } -{{/operations}} +{{/operations}} \ No newline at end of file diff --git a/templates/javascript/clients/algoliasearch/builds/models.mustache b/templates/javascript/clients/algoliasearch/builds/models.mustache index 06a34cc74c..a7cbf278d3 100644 --- a/templates/javascript/clients/algoliasearch/builds/models.mustache +++ b/templates/javascript/clients/algoliasearch/builds/models.mustache @@ -7,10 +7,10 @@ import type { } from '{{{npmNamespace}}}/client-common'; import { ErrorBase, - PutProps, - PostProps, - DelProps, - GetProps, + CustomPutProps, + CustomPostProps, + CustomDeleteProps, + CustomGetProps, } from '{{{npmNamespace}}}/client-search/model'; export * from '{{{npmNamespace}}}/client-search/model'; @@ -23,7 +23,13 @@ export { PersonalizationClient } from '{{{npmNamespace}}}/client-personalization export { AnalyticsClient } from '{{{npmNamespace}}}/client-analytics'; export { AbtestingClient } from '{{{npmNamespace}}}/client-abtesting'; -export { ErrorBase, PutProps, PostProps, DelProps, GetProps }; +export { + ErrorBase, + CustomPutProps, + CustomPostProps, + CustomDeleteProps, + CustomGetProps, +}; /** * Options forwarded to the client initialized via the `init` method. @@ -45,4 +51,4 @@ export type InitClientRegion = Partial<{ * Available regions of the initialized client. */ region: TRegion; -}>; +}>; \ No newline at end of file diff --git a/tests/CTS/client/analytics/parameters.json b/tests/CTS/client/analytics/parameters.json index 94c5862e5f..d8f340afc9 100644 --- a/tests/CTS/client/analytics/parameters.json +++ b/tests/CTS/client/analytics/parameters.json @@ -41,7 +41,7 @@ { "type": "method", "object": "$client", - "path": "post", + "path": "customPost", "parameters": { "path": "/test" }, diff --git a/tests/CTS/client/common/commonApi.json b/tests/CTS/client/common/commonApi.json index 7ede0c8765..d7a76c9f50 100644 --- a/tests/CTS/client/common/commonApi.json +++ b/tests/CTS/client/common/commonApi.json @@ -5,7 +5,7 @@ { "type": "method", "object": "$client", - "path": "post", + "path": "customPost", "parameters": { "path": "/test" }, @@ -22,7 +22,7 @@ { "type": "method", "object": "$client", - "path": "get", + "path": "customGet", "parameters": { "path": "/test" }, @@ -42,7 +42,7 @@ { "type": "method", "object": "$client", - "path": "post", + "path": "customPost", "parameters": { "path": "/test" }, diff --git a/tests/CTS/client/insights/parameters.json b/tests/CTS/client/insights/parameters.json index 3551a199ee..fc2b960a70 100644 --- a/tests/CTS/client/insights/parameters.json +++ b/tests/CTS/client/insights/parameters.json @@ -41,7 +41,7 @@ { "type": "method", "object": "$client", - "path": "del", + "path": "customDelete", "parameters": { "path": "/test" }, diff --git a/tests/CTS/client/recommend/api.json b/tests/CTS/client/recommend/api.json index c78ba3a1a5..e8963f83e5 100644 --- a/tests/CTS/client/recommend/api.json +++ b/tests/CTS/client/recommend/api.json @@ -14,7 +14,7 @@ { "type": "method", "object": "$client", - "path": "get", + "path": "customGet", "parameters": { "path": "/test" }, @@ -40,7 +40,7 @@ { "type": "method", "object": "$client", - "path": "post", + "path": "customPost", "parameters": { "path": "/test" }, diff --git a/tests/CTS/client/search/api.json b/tests/CTS/client/search/api.json index c78ba3a1a5..e8963f83e5 100644 --- a/tests/CTS/client/search/api.json +++ b/tests/CTS/client/search/api.json @@ -14,7 +14,7 @@ { "type": "method", "object": "$client", - "path": "get", + "path": "customGet", "parameters": { "path": "/test" }, @@ -40,7 +40,7 @@ { "type": "method", "object": "$client", - "path": "post", + "path": "customPost", "parameters": { "path": "/test" }, diff --git a/tests/CTS/methods/requests/common/del.json b/tests/CTS/methods/requests/common/customDelete.json similarity index 100% rename from tests/CTS/methods/requests/common/del.json rename to tests/CTS/methods/requests/common/customDelete.json diff --git a/tests/CTS/methods/requests/common/get.json b/tests/CTS/methods/requests/common/customGet.json similarity index 100% rename from tests/CTS/methods/requests/common/get.json rename to tests/CTS/methods/requests/common/customGet.json diff --git a/tests/CTS/methods/requests/common/post.json b/tests/CTS/methods/requests/common/customPost.json similarity index 100% rename from tests/CTS/methods/requests/common/post.json rename to tests/CTS/methods/requests/common/customPost.json diff --git a/tests/CTS/methods/requests/common/put.json b/tests/CTS/methods/requests/common/customPut.json similarity index 100% rename from tests/CTS/methods/requests/common/put.json rename to tests/CTS/methods/requests/common/customPut.json