From 63549446c0c5d75a710d29ab2d8919dcdaf79881 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 5 Nov 2021 09:59:05 +0100 Subject: [PATCH 1/8] feat: openapi sample with search, index, and batch API --- spec_sample.yaml | 489 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 489 insertions(+) create mode 100644 spec_sample.yaml diff --git a/spec_sample.yaml b/spec_sample.yaml new file mode 100644 index 00000000000..adcc4403042 --- /dev/null +++ b/spec_sample.yaml @@ -0,0 +1,489 @@ +openapi: 3.0.0 +info: + title: Search API + description: API powering the Search feature of Algolia. + version: 0.1.0 +servers: + - url: https://{appId}-1.algolianet.com + variables: + appId: + default: test + - url: https://{appId}-2.algolianet.com + variables: + appId: + default: test + - url: https://{appId}-3.algolianet.com + variables: + appId: + default: test + - url: https://{appId}-dsn.algolianet.com + variables: + appId: + default: test +paths: + /1/indexes/{indexName}/query: + post: + tags: + - search + operationId: searchSingle + summary: Get search results + parameters: + - $ref: '#/components/parameters/AppId' + - $ref: '#/components/parameters/ApiKey' + - $ref: '#/components/parameters/IndexName' + responses: + '200': + description: OK + content: + application/json: + schema: + title: singleQueryResponse + type: object + properties: + hits: + type: array + items: + type: object + additionalProperties: {} + properties: + objectID: + type: string + example: objectID1 + nbHits: + type: integer + queryID: + type: string + pattern: '[a-f0-9]{32}' + example: 43b15df305339e827f0ac0bdc5ebcaa7 + '400': + $ref: '#/components/responses/BadRequest' + '404': + $ref: '#/components/responses/IndexNotFound' + /1/indexes/*/queries: + post: + tags: + - search + operationId: searchMulti + summary: Get search results for the given requests. + parameters: + - $ref: '#/components/parameters/AppId' + - $ref: '#/components/parameters/ApiKey' + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + title: multipleQueries + type: object + properties: + indexName: + type: string + example: products + description: The Algolia index name + query: + type: string + description: The query to search for + type: + type: string + enum: [default, facet] + default: default + description: Perform a search query with `default`, will search for facet values if `facet` is given + facet: + type: string + description: The `facet` name + params: + type: object + additionalProperties: true + description: A key-value mapping of additional search parameters + example: + filters: 'in_stock:true' + required: + - indexName + responses: + '200': + description: OK + content: + application/json: + schema: + title: multipleQueriesResponse + type: object + properties: + results: + type: array + items: + type: object + properties: + hits: + type: array + items: + type: object + additionalProperties: {} + properties: + objectID: + type: string + example: objectID1 + nbHits: + type: integer + queryID: + type: string + pattern: '[a-f0-9]{32}' + example: 43b15df305339e827f0ac0bdc5ebcaa7 + '400': + $ref: '#/components/responses/BadRequest' + '404': + $ref: '#/components/responses/IndexNotFound' + /1/indexes/{indexName}: + post: + tags: + - object + operationId: saveSingle + summary: Save object + description: Add an object to the index, automatically assigning it an object ID + parameters: + - $ref: '#/components/parameters/AppId' + - $ref: '#/components/parameters/ApiKey' + - $ref: '#/components/parameters/IndexName' + requestBody: + required: true + content: + application/json: + schema: + type: object + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + '400': + $ref: '#/components/responses/BadRequest' + '404': + $ref: '#/components/responses/IndexNotFound' + /1/indexes/{indexName}/batch: + post: + tags: + - object + operationId: batchSingle + summary: Performs multiple write operations in a single API call + parameters: + - $ref: '#/components/parameters/AppId' + - $ref: '#/components/parameters/ApiKey' + - $ref: '#/components/parameters/IndexName' + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + title: operation + type: object + properties: + action: + type: string + description: type of operation + body: + type: object + description: arguments to the operation (depends on the type of the operation) + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + taskID: + type: integer + objectIDs: + type: array + items: + type: string + '400': + $ref: '#/components/responses/BadRequest' + '404': + $ref: '#/components/responses/IndexNotFound' +components: + parameters: + AppId: + name: X-Algolia-Application-Id + in: header + description: Algolia appID + required: true + schema: + type: string + example: 'DJNVGS47DK' + ApiKey: + name: X-Algolia-API-Key + in: header + description: Algolia API key + required: true + schema: + type: string + example: 'sjzcj8gfe345adkb6gw3yul8hgredv34' + IndexName: + name: indexName + in: path + description: The index in which to perform the request + required: true + schema: + type: string + example: 'myIndexName' + responses: + BadRequest: + description: Bad request or request arguments + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + IndexNotFound: + description: Index not found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + schemas: + Error: + type: object + properties: + message: + type: string + SearchParams: + type: object + additionalProperties: false + properties: + query: + type: string + description: The text to search in the index. + similarQuery: + type: string + description: Overrides the query parameter and performs a more generic search that can be used to find “similar” results. + attributesToRetrieve: + type: array + items: + type: string + description: This parameter controls which attributes to retrieve and which not to retrieve. + restrictSearchableAttributes: + type: array + items: + type: string + description: Restricts a given query to look in only a subset of your searchable attributes. + relevancyStrictness: + type: string + description: Controls the relevancy threshold below which less relevant results aren’t included in the results. + filters: + type: array + items: + type: string + description: Filter the query with numeric, facet and/or tag filters. + facetFilters: + type: array + items: + type: string + description: Filter hits by facet value. + optionalFilters: + type: array + items: + type: string + description: Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter. + numericFilters: + type: array + items: + type: string + description: Filter on numeric attributes. + tagFilters: + type: array + items: + type: string + description: Filter hits by tags. + sumOrFiltersScores: + type: string + description: Determines how to calculate the total score for filtering. + facets: + type: array + items: + type: string + description: Retrieve facets and their facet values. + maxValuesPerFacet: + type: integer + description: Maximum number of facet values to return for each facet during a regular search. + facetingAfterDistinct: + type: boolean + description: Force faceting to be applied after de-duplication (via the Distinct setting). + sortFacetValuesBy: + type: string + description: Controls how facet values are fetched. + default: 'count' + attributesToHighlight: + type: array + items: + type: string + description: List of attributes to highlight. + attributesToSnippet: + type: array + items: + type: string + description: List of attributes to snippet, with an optional maximum number of words to snippet. + highlightPreTag: + type: string + description: The HTML string to insert before the highlighted parts in all highlight and snippet results. + highlightPostTag: + type: string + description: The HTML string to insert after the highlighted parts in all highlight and snippet results. + snippetEllipsisText: + type: string + description: String used as an ellipsis indicator when a snippet is truncated. + restrictHighlightAndSnippetArrays: + type: string + description: Restrict highlighting and snippeting to items that matched the query. + page: + type: integer + description: Specify the page to retrieve. + default: 0 + hitsPerPage: + type: integer + description: Set the number of hits per page. + default: 20 + offset: + type: integer + description: Specify the offset of the first hit to return. + default: null + length: + type: integer + description: Set the number of hits to retrieve (used only with offset). + minWordSizefor1Typo: + type: integer + description: Minimum number of characters a word in the query string must contain to accept matches with 1 typo. + minWordSizefor2Typos: + type: integer + description: Minimum number of characters a word in the query string must contain to accept matches with 2 typos. + typoTolerance: + type: string + description: Controls whether typo tolerance is enabled and how it is applied. + default: true + allowTyposOnNumericTokens: + type: boolean + description: Whether to allow typos on numbers (“numeric tokens”) in the query string. + disableTypoToleranceOnAttributes: + type: string + description: List of attributes on which you want to disable typo tolerance. + aroundLatLng: + type: string + description: Search for entries around a central geolocation, enabling a geo search within a circular area. + aroundLatLngViaIP: + type: string + description: Search for entries around a given location automatically computed from the requester’s IP address. + aroundRadius: + type: string + description: Define the maximum radius for a geo search (in meters). + aroundPrecision: + type: string + description: Precision of geo search (in meters), to add grouping by geo location to the ranking formula. + minimumAroundRadius: + type: string + description: Minimum radius (in meters) used for a geo search when aroundRadius is not set. + insideBoundingBox: + type: string + description: Search inside a rectangular area (in geo coordinates). + insidePolygon: + type: string + description: Search inside a polygon (in geo coordinates). + ignorePlurals: + type: string + description: Treats singular, plurals, and other forms of declensions as matching terms. + removeStopWords: + type: string + description: Removes stop (common) words from the query before executing it. + queryLanguages: + type: string + description: Sets the languages to be used by language-specific settings and functionalities such as ignorePlurals, removeStopWords, and CJK word-detection. + naturalLanguages: + type: string + description: This parameter changes the default values of certain parameters and settings that work best for a natural language query, such as ignorePlurals, removeStopWords, removeWordsIfNoResults, analyticsTags and ruleContexts. These parameters and settings work well together when the query is formatted in natural language instead of keywords, for example when your user performs a voice search. + decompoundQuery: + type: string + description: Splits compound words into their composing atoms in the query. + enableRules: + type: string + description: Whether Rules should be globally enabled. + ruleContexts: + type: string + description: Enables contextual rules. + enablePersonalization: + type: string + description: Enable the Personalization feature. + personalizationImpact: + type: string + description: Define the impact of the Personalization feature. + userToken: + type: string + description: Associates a certain user token with the current search. + queryType: + type: string + description: Controls if and how query words are interpreted as prefixes. + removeWordsIfNoResults: + type: string + description: Selects a strategy to remove words from the query when it doesn’t match any hits. + advancedSyntax: + type: string + description: Enables the advanced query syntax. + optionalWords: + type: string + description: A list of words that should be considered as optional when found in the query. + disableExactOnAttributes: + type: string + description: List of attributes on which you want to disable the exact ranking criterion. + exactOnSingleWordQuery: + type: string + description: Controls how the exact ranking criterion is computed when the query contains only one word. + alternativesAsExact: + type: string + description: List of alternatives that should be considered an exact match by the exact ranking criterion. + advancedSyntaxFeatures: + type: string + description: Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is enabled. + distinct: + type: string + description: Enables de-duplication or grouping of results. + getRankingInfo: + type: string + description: Retrieve detailed ranking information. + clickAnalytics: + type: string + description: Enable the Click Analytics feature. + analytics: + type: string + description: Whether the current query will be taken into account in the Analytics. + analyticsTags: + type: string + description: List of tags to apply to the query for analytics purposes. + synonyms: + type: string + description: Whether to take into account an index’s synonyms for a particular search. + replaceSynonymsInHighlight: + type: string + description: Whether to highlight and snippet the original word that matches the synonym or the synonym itself. + minProximity: + type: string + description: Precision of the proximity ranking criterion. + responseFields: + type: string + description: Choose which fields to return in the API response. This parameters applies to search and browse queries. + maxFacetHits: + type: string + description: Maximum number of facet hits to return during a search for facet values. + percentileComputation: + type: string + description: Whether to include or exclude a query from the processing-time percentile computation. + attributeCriteriaComputedByMinProximity: + type: string + description: When attribute is ranked above proximity in your ranking formula, proximity is used to select which searchable attribute is matched in the attribute ranking stage. + enableABTest: + type: string + description: Whether this search should participate in running AB tests. + enableReRanking: + type: string + description: Whether this search should use AI Re-Ranking. \ No newline at end of file From da5f55a35248b8be7535863a89272b4898d28814 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 5 Nov 2021 11:10:34 +0100 Subject: [PATCH 2/8] rename to yml --- spec_sample.yaml => spec_sample.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename spec_sample.yaml => spec_sample.yml (99%) diff --git a/spec_sample.yaml b/spec_sample.yml similarity index 99% rename from spec_sample.yaml rename to spec_sample.yml index adcc4403042..f150601e13a 100644 --- a/spec_sample.yaml +++ b/spec_sample.yml @@ -223,7 +223,7 @@ components: required: true schema: type: string - example: 'sjzcj8gfe345adkb6gw3yul8hgredv34' + example: '43b15df305339e827f0ac0bdc5ebcaa7' IndexName: name: indexName in: path From de4a1241d0c81604cc755fc13480ad6d4be9d7d9 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 5 Nov 2021 16:02:15 +0100 Subject: [PATCH 3/8] hopefully I've answered everything --- openapi_spec/parameters.yml | 26 ++ openapi_spec/paths/indexes/batch.yml | 55 +++ openapi_spec/paths/indexes/saveObject.yml | 34 ++ openapi_spec/paths/indexes/search.yml | 40 ++ openapi_spec/paths/indexes/searchMulti.yml | 77 ++++ openapi_spec/responses/BadRequest.yml | 5 + openapi_spec/responses/IndexNotFound.yml | 5 + openapi_spec/schemas/Error.yml | 7 + openapi_spec/schemas/SearchParams.yml | 449 +++++++++++++++++++ openapi_spec/spec.yml | 32 ++ package.json | 8 +- spec_sample.yml | 489 --------------------- yarn.lock | 340 +++++++++++++- 13 files changed, 1073 insertions(+), 494 deletions(-) create mode 100644 openapi_spec/parameters.yml create mode 100644 openapi_spec/paths/indexes/batch.yml create mode 100644 openapi_spec/paths/indexes/saveObject.yml create mode 100644 openapi_spec/paths/indexes/search.yml create mode 100644 openapi_spec/paths/indexes/searchMulti.yml create mode 100644 openapi_spec/responses/BadRequest.yml create mode 100644 openapi_spec/responses/IndexNotFound.yml create mode 100644 openapi_spec/schemas/Error.yml create mode 100644 openapi_spec/schemas/SearchParams.yml create mode 100644 openapi_spec/spec.yml delete mode 100644 spec_sample.yml diff --git a/openapi_spec/parameters.yml b/openapi_spec/parameters.yml new file mode 100644 index 00000000000..ae77ae2257a --- /dev/null +++ b/openapi_spec/parameters.yml @@ -0,0 +1,26 @@ +AppId: + name: X-Algolia-Application-Id + in: header + description: Algolia appID + required: true + schema: + type: string + pattern: "^(?:beta|testing)?[A-Z0-9]{10}$" + example: "DJNVGS47DK" +ApiKey: + name: X-Algolia-API-Key + in: header + description: Algolia API key + required: true + schema: + type: string + pattern: "^[a-f0-9]{32}$" + example: "43b15df305339e827f0ac0bdc5ebcaa7" +IndexName: + name: indexName + in: path + description: The index in which to perform the request + required: true + schema: + type: string + example: "myIndexName" diff --git a/openapi_spec/paths/indexes/batch.yml b/openapi_spec/paths/indexes/batch.yml new file mode 100644 index 00000000000..e5490426df6 --- /dev/null +++ b/openapi_spec/paths/indexes/batch.yml @@ -0,0 +1,55 @@ +post: + tags: + - object + operationId: batch + summary: Performs multiple write operations in a single API call + parameters: + - $ref: "../../parameters.yml#/AppId" + - $ref: "../../parameters.yml#/ApiKey" + - $ref: "../../parameters.yml#/IndexName" + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + title: operation + type: object + additionalProperties: false + properties: + action: + type: string + enum: + - "addObject" + - "updateObject" + - "partialUpdateObject" + - "partialUpdateObjectNoCreate" + - "deleteObject" + - "delete" + - "clear" + description: type of operation + body: + type: object + # this could be a long oneOf with every possibilities + additionalProperties: true + description: arguments to the operation (depends on the type of the operation) + responses: + "200": + description: OK + content: + application/json: + schema: + type: object + additionalProperties: false + properties: + taskID: + type: integer + objectIDs: + type: array + items: + type: string + "400": + $ref: "../../responses/BadRequest.yml" + "404": + $ref: "../../responses/IndexNotFound.yml" diff --git a/openapi_spec/paths/indexes/saveObject.yml b/openapi_spec/paths/indexes/saveObject.yml new file mode 100644 index 00000000000..0ada4fb698f --- /dev/null +++ b/openapi_spec/paths/indexes/saveObject.yml @@ -0,0 +1,34 @@ +post: + tags: + - object + operationId: saveObject + summary: Save object + description: Add an object to the index, automatically assigning it an object ID + parameters: + - $ref: "../../parameters.yml#/AppId" + - $ref: "../../parameters.yml#/ApiKey" + - $ref: "../../parameters.yml#/IndexName" + requestBody: + required: true + content: + application/json: + schema: + type: object + additionalProperties: true + responses: + "200": + description: OK + content: + application/json: + schema: + type: object + additionalProperties: false + properties: + taskID: + type: number + objectID: + type: string + "400": + $ref: "../../responses/BadRequest.yml" + "404": + $ref: "../../responses/IndexNotFound.yml" diff --git a/openapi_spec/paths/indexes/search.yml b/openapi_spec/paths/indexes/search.yml new file mode 100644 index 00000000000..3d43ecb7170 --- /dev/null +++ b/openapi_spec/paths/indexes/search.yml @@ -0,0 +1,40 @@ +post: + tags: + - search + operationId: search + summary: Get search results + parameters: + - $ref: "../../parameters.yml#/AppId" + - $ref: "../../parameters.yml#/ApiKey" + - $ref: "../../parameters.yml#/IndexName" + requestBody: + $ref: "../../schemas/SearchParams.yml" + responses: + "200": + description: OK + content: + application/json: + schema: + title: singleQueryResponse + type: object + additionalProperties: false + properties: + hits: + type: array + items: + type: object + additionalProperties: false + properties: + objectID: + type: string + example: objectID1 + nbHits: + type: integer + queryID: + type: string + pattern: "[a-f0-9]{32}" + example: 43b15df305339e827f0ac0bdc5ebcaa7 + "400": + $ref: "../../responses/BadRequest.yml" + "404": + $ref: "../../responses/IndexNotFound.yml" diff --git a/openapi_spec/paths/indexes/searchMulti.yml b/openapi_spec/paths/indexes/searchMulti.yml new file mode 100644 index 00000000000..7df1638c6eb --- /dev/null +++ b/openapi_spec/paths/indexes/searchMulti.yml @@ -0,0 +1,77 @@ +post: + tags: + - search + operationId: searchMulti + summary: Get search results for the given requests. + parameters: + - $ref: "../../parameters.yml#/AppId" + - $ref: "../../parameters.yml#/ApiKey" + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + title: multipleQueries + type: object + additionalProperties: false + properties: + indexName: + type: string + example: products + description: The Algolia index name + query: + type: string + description: The query to search for + type: + type: string + enum: [default, facet] + default: default + description: Perform a search query with `default`, will search for facet values if `facet` is given + facet: + type: string + description: The `facet` name + params: + type: object + additionalProperties: true + description: A key-value mapping of additional search parameters + example: + filters: "in_stock:true" + required: + - indexName + responses: + "200": + description: OK + content: + application/json: + schema: + title: multipleQueriesResponse + type: object + additionalProperties: false + properties: + results: + type: array + items: + type: object + additionalProperties: false + properties: + hits: + type: array + items: + type: object + additionalProperties: false + properties: + objectID: + type: string + example: objectID1 + nbHits: + type: integer + queryID: + type: string + pattern: "[a-f0-9]{32}" + example: 43b15df305339e827f0ac0bdc5ebcaa7 + "400": + $ref: "../../responses/BadRequest.yml" + "404": + $ref: "../../responses/IndexNotFound.yml" diff --git a/openapi_spec/responses/BadRequest.yml b/openapi_spec/responses/BadRequest.yml new file mode 100644 index 00000000000..112fbe73f58 --- /dev/null +++ b/openapi_spec/responses/BadRequest.yml @@ -0,0 +1,5 @@ +description: Bad request or request arguments +content: + application/json: + schema: + $ref: "../schemas/Error.yml" diff --git a/openapi_spec/responses/IndexNotFound.yml b/openapi_spec/responses/IndexNotFound.yml new file mode 100644 index 00000000000..0ac5e0980f3 --- /dev/null +++ b/openapi_spec/responses/IndexNotFound.yml @@ -0,0 +1,5 @@ +description: Index not found +content: + application/json: + schema: + $ref: "../schemas/Error.yml" diff --git a/openapi_spec/schemas/Error.yml b/openapi_spec/schemas/Error.yml new file mode 100644 index 00000000000..214c152880b --- /dev/null +++ b/openapi_spec/schemas/Error.yml @@ -0,0 +1,7 @@ +description: Error +type: object +additionalProperties: true +properties: + message: + type: string + example: "Invalid application id" diff --git a/openapi_spec/schemas/SearchParams.yml b/openapi_spec/schemas/SearchParams.yml new file mode 100644 index 00000000000..43c63e3608d --- /dev/null +++ b/openapi_spec/schemas/SearchParams.yml @@ -0,0 +1,449 @@ +type: object +additionalProperties: false +properties: +query: + type: string + summary: The text to search in the index. + default: "" +similarQuery: + type: string + summary: Overrides the query parameter and performs a more generic search that can be used to find “similar” results. + default: "" +searchableAttributes: + type: array + items: + type: string + summary: The complete list of attributes used for searching. + default: [] +attributesForFaceting: + type: array + items: + type: string + summary: The complete list of attributes that will be used for faceting. + default: [] +unretrievableAttributes: + type: array + items: + type: string + summary: List of attributes that can’t be retrieved at query time. + default: [] +attributesToRetrieve: + type: array + items: + type: string + summary: This parameter controls which attributes to retrieve and which not to retrieve. + default: ["*"] +restrictSearchableAttributes: + type: array + items: + type: string + summary: Restricts a given query to look in only a subset of your searchable attributes. + default: [] +ranking: + type: array + items: + type: string + summary: Controls how Algolia should sort your results. + default: + - "typo" + - "geo" + - "words" + - "filters" + - "proximity" + - "attribute" + - "exact" + - "custom" +customRanking: + type: array + items: + type: string + summary: Specifies the custom ranking criterion. + default: [] +relevancyStrictness: + type: integer + summary: Controls the relevancy threshold below which less relevant results aren’t included in the results. + default: 100 +replicas: + type: array + items: + type: string + summary: Creates replicas, exact copies of an index. + default: [] +filters: + type: string + summary: Filter the query with numeric, facet and/or tag filters. + default: "" + # There could be a pattern for this one (complicated one) +facetFilters: + type: array + items: + type: string + summary: Filter hits by facet value. + default: [] +optionalFilters: + type: array + items: + type: string + summary: Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter. + default: [] +numericFilters: + type: array + items: + type: string + summary: Filter on numeric attributes. + default: [] +tagFilters: + type: array + items: + type: string + summary: Filter hits by tags. + default: [] +sumOrFiltersScores: + type: boolean + summary: Determines how to calculate the total score for filtering. + default: false +facets: + type: array + items: + type: string + summary: Retrieve facets and their facet values. + default: [] +maxValuesPerFacet: + type: integer + summary: Maximum number of facet values to return for each facet during a regular search. + default: 100 +facetingAfterDistinct: + type: boolean + summary: Force faceting to be applied after de-duplication (via the Distinct setting). + default: false +sortFacetValuesBy: + type: string + summary: Controls how facet values are fetched. + default: "count" +attributesToHighlight: + type: array + items: + type: string + summary: List of attributes to highlight. +attributesToSnippet: + type: array + items: + type: string + summary: List of attributes to snippet, with an optional maximum number of words to snippet. + default: [] +highlightPreTag: + type: string + summary: The HTML string to insert before the highlighted parts in all highlight and snippet results. + default: "" +highlightPostTag: + type: string + summary: The HTML string to insert after the highlighted parts in all highlight and snippet results. + default: "" +snippetEllipsisText: + type: string + summary: String used as an ellipsis indicator when a snippet is truncated. + default: "…" +restrictHighlightAndSnippetArrays: + type: boolean + summary: Restrict highlighting and snippeting to items that matched the query. + default: false +page: + type: integer + summary: Specify the page to retrieve. + default: 0 +hitsPerPage: + type: integer + summary: Set the number of hits per page. + default: 20 +offset: + type: integer + summary: Specify the offset of the first hit to return. + default: null +length: + type: integer + summary: Set the number of hits to retrieve (used only with offset). + default: null +paginationLimitedTo: + type: integer + summary: Set the maximum number of hits accessible via pagination. + default: 1000 +minWordSizefor1Typo: + type: integer + summary: Minimum number of characters a word in the query string must contain to accept matches with 1 typo. + default: 4 +minWordSizefor2Typos: + type: integer + summary: Minimum number of characters a word in the query string must contain to accept matches with 2 typos. + default: 8 +typoTolerance: + type: string + enum: [true, false, "min", "strict"] + summary: Controls whether typo tolerance is enabled and how it is applied. + default: true +allowTyposOnNumericTokens: + type: boolean + summary: Whether to allow typos on numbers (“numeric tokens”) in the query string. + default: true +disableTypoToleranceOnAttributes: + type: array + items: + type: string + summary: List of attributes on which you want to disable typo tolerance. + default: [] +disableTypoToleranceOnWords: + type: array + items: + type: string + summary: A list of words for which you want to turn off typo tolerance. + default: [] +separatorsToIndex: + type: string + summary: Control which separators are indexed. + default: "" +aroundLatLng: + type: string + summary: Search for entries around a central geolocation, enabling a geo search within a circular area. + default: null +aroundLatLngViaIP: + type: boolean + summary: Search for entries around a given location automatically computed from the requester’s IP address. + default: false +aroundRadius: + type: string + summary: Define the maximum radius for a geo search (in meters). + default: null +aroundPrecision: + type: integer + summary: Precision of geo search (in meters), to add grouping by geo location to the ranking formula. + default: 10 +minimumAroundRadius: + type: integer + summary: Minimum radius (in meters) used for a geo search when aroundRadius is not set. + default: null +insideBoundingBox: + type: array + items: + type: float + summary: Search inside a rectangular area (in geo coordinates). + default: null +insidePolygon: + type: array + items: + type: float + summary: Search inside a polygon (in geo coordinates). + default: null +ignorePlurals: + type: string + summary: Treats singular, plurals, and other forms of declensions as matching terms. + default: false +attributesToTransliterate: + type: array + summary: Specify on which attributes to apply transliteration. +removeStopWords: + type: string + summary: Removes stop (common) words from the query before executing it. + default: false +camelCaseAttributes: + type: array + items: + type: string + summary: List of attributes on which to do a decomposition of camel case words. + default: [] +decompoundedAttributes: + type: object + additionalProperties: true + summary: Specify on which attributes in your index Algolia should apply word segmentation, also known as decompounding. + default: {} +keepDiacriticsOnCharacters: + type: string + summary: List of characters that the engine shouldn’t automatically normalize. + default: "" +customNormalization: + type: object + additionalProperties: true + summary: Override the default normalization handled by the engine. + default: {} +queryLanguages: + type: array + items: + type: string + summary: Sets the languages to be used by language-specific settings and functionalities such as ignorePlurals, removeStopWords, and CJK word-detection. + default: [] +indexLanguages: + type: array + items: + type: string + summary: Sets the languages at the index level for language-specific processing such as tokenization and normalization. + default: [] +naturalLanguages: + type: array + items: + type: string + summary: This parameter changes the default values of certain parameters and settings that work best for a natural language query, such as ignorePlurals, removeStopWords, removeWordsIfNoResults, analyticsTags and ruleContexts. These parameters and settings work well together when the query is formatted in natural language instead of keywords, for example when your user performs a voice search. + default: [] +decompoundQuery: + type: boolean + summary: Splits compound words into their composing atoms in the query. + default: true +enableRules: + type: boolean + summary: Whether Rules should be globally enabled. + default: true +filterPromotes: + type: boolean + summary: Whether promoted results should match the filters of the current search, except for geographic filters. + default: false +ruleContexts: + type: array + items: + type: string + summary: Enables contextual rules. + default: [] +enablePersonalization: + type: boolean + summary: Enable the Personalization feature. + default: false +personalizationImpact: + type: integer + summary: Define the impact of the Personalization feature. + default: 100 +userToken: + type: string + summary: Associates a certain user token with the current search. +queryType: + type: string + enum: ["prefixLast", "prefixAll", "prefixNone"] + summary: Controls if and how query words are interpreted as prefixes. + default: "prefixLast" +removeWordsIfNoResults: + type: string + enum: ["none", "lastWords", "firstWords", "allOptional"] + summary: Selects a strategy to remove words from the query when it doesn’t match any hits. + default: "none" +advancedSyntax: + type: boolean + summary: Enables the advanced query syntax. + default: false +optionalWords: + type: array + items: + type: string + summary: A list of words that should be considered as optional when found in the query. + default: [] +disablePrefixOnAttributes: + type: array + items: + type: string + summary: List of attributes on which you want to disable prefix matching. + default: [] +disableExactOnAttributes: + type: array + items: + type: string + summary: List of attributes on which you want to disable the exact ranking criterion. + default: [] +exactOnSingleWordQuery: + type: string + enum: ["attribute", "none", "word"] + summary: Controls how the exact ranking criterion is computed when the query contains only one word. + default: "attribute" +alternativesAsExact: + type: array + items: + type: string + enum: ["ignorePlurals", "singleWordSynonym", "multiWordsSynonym"] + summary: List of alternatives that should be considered an exact match by the exact ranking criterion. + default: ["ignorePlurals", "singleWordSynonym"] +advancedSyntaxFeatures: + type: array + items: + type: string + enums: ["exactPhrase", "excludeWords"] + summary: Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is enabled. + default: ["exactPhrase", "excludeWords"] +numericAttributesForFiltering: + type: array + items: + type: string + summary: List of numeric attributes that can be used as numerical filters. + default: null +allowCompressionOfIntegerArray: + type: boolean + summary: Enables compression of large integer arrays. + default: false +attributeForDistinct: + type: string + summary: Name of the de-duplication attribute to be used with the distinct feature. + default: null +distinct: + type: integer + min: 0 + max: 4 + summary: Enables de-duplication or grouping of results. + default: 0 +getRankingInfo: + type: boolean + summary: Retrieve detailed ranking information. + default: false +clickAnalytics: + type: boolean + summary: Enable the Click Analytics feature. + default: false +analytics: + type: boolean + summary: Whether the current query will be taken into account in the Analytics. + default: true +analyticsTags: + type: array + items: + type: string + summary: List of tags to apply to the query for analytics purposes. + default: [] +synonyms: + type: boolean + summary: Whether to take into account an index’s synonyms for a particular search. + default: true +replaceSynonymsInHighlight: + type: boolean + summary: Whether to highlight and snippet the original word that matches the synonym or the synonym itself. + default: false +minProximity: + type: integer + min: 1 + max: 7 + summary: Precision of the proximity ranking criterion. + default: 1 +responseFields: + type: array + items: + type: string + summary: Choose which fields to return in the API response. This parameters applies to search and browse queries. +maxFacetHits: + type: integer + summary: Maximum number of facet hits to return during a search for facet values. + default: 10 +percentileComputation: + type: boolean + summary: Whether to include or exclude a query from the processing-time percentile computation. + default: true +attributeCriteriaComputedByMinProximity: + type: boolean + summary: When attribute is ranked above proximity in your ranking formula, proximity is used to select which searchable attribute is matched in the attribute ranking stage. + default: false +userData: + type: object + additionalProperties: true + summary: Lets you store custom data in your indices. + default: {} +enableABTest: + type: boolean + summary: Whether this search should participate in running AB tests. + default: true +enableReRanking: + type: boolean + summary: Whether this search should use AI Re-Ranking. + default: true +renderingContent: + type: object + summary: Content defining how the search interface should be rendered. Can be set via the settings for a default value and can be overridden via rules. + default: {} diff --git a/openapi_spec/spec.yml b/openapi_spec/spec.yml new file mode 100644 index 00000000000..dd38e0ac783 --- /dev/null +++ b/openapi_spec/spec.yml @@ -0,0 +1,32 @@ +openapi: 3.0.2 +info: + title: Search API + description: API powering the Search feature of Algolia. + version: 0.1.0 +servers: + - url: https://{appId}-1.algolianet.com + variables: + appId: + default: test + - url: https://{appId}-2.algolianet.com + variables: + appId: + default: test + - url: https://{appId}-3.algolianet.com + variables: + appId: + default: test + - url: https://{appId}-dsn.algolianet.com + variables: + appId: + default: test +paths: + # We can add this one later, as it requires the init method + # /1/indexes/{indexName}/query: + # $ref: "./paths/indexes/search.yml" + /1/indexes/*/queries: + $ref: "./paths/indexes/searchMulti.yml" + /1/indexes/{indexName}: + $ref: "./paths/indexes/saveObject.yml" + /1/indexes/{indexName}/batch: + $ref: "./paths/indexes/batch.yml" diff --git a/package.json b/package.json index 07010202639..6756a922dc1 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ ], "scripts": { "generate": "PACKAGE_VERSION='4.11.0' TS_POST_PROCESS_FILE='yarn prettier --write .' yarn openapi-generator-cli generate --generator-key client && yarn install", + "build:spec": "yarn swagger-cli bundle openapi_spec/spec.yml --outfile dist/openapi.yml --type yaml", "client:build": "cd output/ && yarn install && yarn build && cd ..", "client:test": "yarn install && tsc && node dist/app.js", "clean:output": "rm -rf output/*", @@ -21,5 +22,8 @@ "node": ">= 12.0.0", "yarn": ">= 2.0.0" }, - "packageManager": "yarn@3.0.2" -} + "packageManager": "yarn@3.0.2", + "dependencies": { + "swagger-cli": "^4.0.4" + } +} \ No newline at end of file diff --git a/spec_sample.yml b/spec_sample.yml deleted file mode 100644 index f150601e13a..00000000000 --- a/spec_sample.yml +++ /dev/null @@ -1,489 +0,0 @@ -openapi: 3.0.0 -info: - title: Search API - description: API powering the Search feature of Algolia. - version: 0.1.0 -servers: - - url: https://{appId}-1.algolianet.com - variables: - appId: - default: test - - url: https://{appId}-2.algolianet.com - variables: - appId: - default: test - - url: https://{appId}-3.algolianet.com - variables: - appId: - default: test - - url: https://{appId}-dsn.algolianet.com - variables: - appId: - default: test -paths: - /1/indexes/{indexName}/query: - post: - tags: - - search - operationId: searchSingle - summary: Get search results - parameters: - - $ref: '#/components/parameters/AppId' - - $ref: '#/components/parameters/ApiKey' - - $ref: '#/components/parameters/IndexName' - responses: - '200': - description: OK - content: - application/json: - schema: - title: singleQueryResponse - type: object - properties: - hits: - type: array - items: - type: object - additionalProperties: {} - properties: - objectID: - type: string - example: objectID1 - nbHits: - type: integer - queryID: - type: string - pattern: '[a-f0-9]{32}' - example: 43b15df305339e827f0ac0bdc5ebcaa7 - '400': - $ref: '#/components/responses/BadRequest' - '404': - $ref: '#/components/responses/IndexNotFound' - /1/indexes/*/queries: - post: - tags: - - search - operationId: searchMulti - summary: Get search results for the given requests. - parameters: - - $ref: '#/components/parameters/AppId' - - $ref: '#/components/parameters/ApiKey' - requestBody: - required: true - content: - application/json: - schema: - type: array - items: - title: multipleQueries - type: object - properties: - indexName: - type: string - example: products - description: The Algolia index name - query: - type: string - description: The query to search for - type: - type: string - enum: [default, facet] - default: default - description: Perform a search query with `default`, will search for facet values if `facet` is given - facet: - type: string - description: The `facet` name - params: - type: object - additionalProperties: true - description: A key-value mapping of additional search parameters - example: - filters: 'in_stock:true' - required: - - indexName - responses: - '200': - description: OK - content: - application/json: - schema: - title: multipleQueriesResponse - type: object - properties: - results: - type: array - items: - type: object - properties: - hits: - type: array - items: - type: object - additionalProperties: {} - properties: - objectID: - type: string - example: objectID1 - nbHits: - type: integer - queryID: - type: string - pattern: '[a-f0-9]{32}' - example: 43b15df305339e827f0ac0bdc5ebcaa7 - '400': - $ref: '#/components/responses/BadRequest' - '404': - $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}: - post: - tags: - - object - operationId: saveSingle - summary: Save object - description: Add an object to the index, automatically assigning it an object ID - parameters: - - $ref: '#/components/parameters/AppId' - - $ref: '#/components/parameters/ApiKey' - - $ref: '#/components/parameters/IndexName' - requestBody: - required: true - content: - application/json: - schema: - type: object - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - '400': - $ref: '#/components/responses/BadRequest' - '404': - $ref: '#/components/responses/IndexNotFound' - /1/indexes/{indexName}/batch: - post: - tags: - - object - operationId: batchSingle - summary: Performs multiple write operations in a single API call - parameters: - - $ref: '#/components/parameters/AppId' - - $ref: '#/components/parameters/ApiKey' - - $ref: '#/components/parameters/IndexName' - requestBody: - required: true - content: - application/json: - schema: - type: array - items: - title: operation - type: object - properties: - action: - type: string - description: type of operation - body: - type: object - description: arguments to the operation (depends on the type of the operation) - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - properties: - taskID: - type: integer - objectIDs: - type: array - items: - type: string - '400': - $ref: '#/components/responses/BadRequest' - '404': - $ref: '#/components/responses/IndexNotFound' -components: - parameters: - AppId: - name: X-Algolia-Application-Id - in: header - description: Algolia appID - required: true - schema: - type: string - example: 'DJNVGS47DK' - ApiKey: - name: X-Algolia-API-Key - in: header - description: Algolia API key - required: true - schema: - type: string - example: '43b15df305339e827f0ac0bdc5ebcaa7' - IndexName: - name: indexName - in: path - description: The index in which to perform the request - required: true - schema: - type: string - example: 'myIndexName' - responses: - BadRequest: - description: Bad request or request arguments - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - IndexNotFound: - description: Index not found - content: - application/json: - schema: - $ref: '#/components/schemas/Error' - schemas: - Error: - type: object - properties: - message: - type: string - SearchParams: - type: object - additionalProperties: false - properties: - query: - type: string - description: The text to search in the index. - similarQuery: - type: string - description: Overrides the query parameter and performs a more generic search that can be used to find “similar” results. - attributesToRetrieve: - type: array - items: - type: string - description: This parameter controls which attributes to retrieve and which not to retrieve. - restrictSearchableAttributes: - type: array - items: - type: string - description: Restricts a given query to look in only a subset of your searchable attributes. - relevancyStrictness: - type: string - description: Controls the relevancy threshold below which less relevant results aren’t included in the results. - filters: - type: array - items: - type: string - description: Filter the query with numeric, facet and/or tag filters. - facetFilters: - type: array - items: - type: string - description: Filter hits by facet value. - optionalFilters: - type: array - items: - type: string - description: Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter. - numericFilters: - type: array - items: - type: string - description: Filter on numeric attributes. - tagFilters: - type: array - items: - type: string - description: Filter hits by tags. - sumOrFiltersScores: - type: string - description: Determines how to calculate the total score for filtering. - facets: - type: array - items: - type: string - description: Retrieve facets and their facet values. - maxValuesPerFacet: - type: integer - description: Maximum number of facet values to return for each facet during a regular search. - facetingAfterDistinct: - type: boolean - description: Force faceting to be applied after de-duplication (via the Distinct setting). - sortFacetValuesBy: - type: string - description: Controls how facet values are fetched. - default: 'count' - attributesToHighlight: - type: array - items: - type: string - description: List of attributes to highlight. - attributesToSnippet: - type: array - items: - type: string - description: List of attributes to snippet, with an optional maximum number of words to snippet. - highlightPreTag: - type: string - description: The HTML string to insert before the highlighted parts in all highlight and snippet results. - highlightPostTag: - type: string - description: The HTML string to insert after the highlighted parts in all highlight and snippet results. - snippetEllipsisText: - type: string - description: String used as an ellipsis indicator when a snippet is truncated. - restrictHighlightAndSnippetArrays: - type: string - description: Restrict highlighting and snippeting to items that matched the query. - page: - type: integer - description: Specify the page to retrieve. - default: 0 - hitsPerPage: - type: integer - description: Set the number of hits per page. - default: 20 - offset: - type: integer - description: Specify the offset of the first hit to return. - default: null - length: - type: integer - description: Set the number of hits to retrieve (used only with offset). - minWordSizefor1Typo: - type: integer - description: Minimum number of characters a word in the query string must contain to accept matches with 1 typo. - minWordSizefor2Typos: - type: integer - description: Minimum number of characters a word in the query string must contain to accept matches with 2 typos. - typoTolerance: - type: string - description: Controls whether typo tolerance is enabled and how it is applied. - default: true - allowTyposOnNumericTokens: - type: boolean - description: Whether to allow typos on numbers (“numeric tokens”) in the query string. - disableTypoToleranceOnAttributes: - type: string - description: List of attributes on which you want to disable typo tolerance. - aroundLatLng: - type: string - description: Search for entries around a central geolocation, enabling a geo search within a circular area. - aroundLatLngViaIP: - type: string - description: Search for entries around a given location automatically computed from the requester’s IP address. - aroundRadius: - type: string - description: Define the maximum radius for a geo search (in meters). - aroundPrecision: - type: string - description: Precision of geo search (in meters), to add grouping by geo location to the ranking formula. - minimumAroundRadius: - type: string - description: Minimum radius (in meters) used for a geo search when aroundRadius is not set. - insideBoundingBox: - type: string - description: Search inside a rectangular area (in geo coordinates). - insidePolygon: - type: string - description: Search inside a polygon (in geo coordinates). - ignorePlurals: - type: string - description: Treats singular, plurals, and other forms of declensions as matching terms. - removeStopWords: - type: string - description: Removes stop (common) words from the query before executing it. - queryLanguages: - type: string - description: Sets the languages to be used by language-specific settings and functionalities such as ignorePlurals, removeStopWords, and CJK word-detection. - naturalLanguages: - type: string - description: This parameter changes the default values of certain parameters and settings that work best for a natural language query, such as ignorePlurals, removeStopWords, removeWordsIfNoResults, analyticsTags and ruleContexts. These parameters and settings work well together when the query is formatted in natural language instead of keywords, for example when your user performs a voice search. - decompoundQuery: - type: string - description: Splits compound words into their composing atoms in the query. - enableRules: - type: string - description: Whether Rules should be globally enabled. - ruleContexts: - type: string - description: Enables contextual rules. - enablePersonalization: - type: string - description: Enable the Personalization feature. - personalizationImpact: - type: string - description: Define the impact of the Personalization feature. - userToken: - type: string - description: Associates a certain user token with the current search. - queryType: - type: string - description: Controls if and how query words are interpreted as prefixes. - removeWordsIfNoResults: - type: string - description: Selects a strategy to remove words from the query when it doesn’t match any hits. - advancedSyntax: - type: string - description: Enables the advanced query syntax. - optionalWords: - type: string - description: A list of words that should be considered as optional when found in the query. - disableExactOnAttributes: - type: string - description: List of attributes on which you want to disable the exact ranking criterion. - exactOnSingleWordQuery: - type: string - description: Controls how the exact ranking criterion is computed when the query contains only one word. - alternativesAsExact: - type: string - description: List of alternatives that should be considered an exact match by the exact ranking criterion. - advancedSyntaxFeatures: - type: string - description: Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is enabled. - distinct: - type: string - description: Enables de-duplication or grouping of results. - getRankingInfo: - type: string - description: Retrieve detailed ranking information. - clickAnalytics: - type: string - description: Enable the Click Analytics feature. - analytics: - type: string - description: Whether the current query will be taken into account in the Analytics. - analyticsTags: - type: string - description: List of tags to apply to the query for analytics purposes. - synonyms: - type: string - description: Whether to take into account an index’s synonyms for a particular search. - replaceSynonymsInHighlight: - type: string - description: Whether to highlight and snippet the original word that matches the synonym or the synonym itself. - minProximity: - type: string - description: Precision of the proximity ranking criterion. - responseFields: - type: string - description: Choose which fields to return in the API response. This parameters applies to search and browse queries. - maxFacetHits: - type: string - description: Maximum number of facet hits to return during a search for facet values. - percentileComputation: - type: string - description: Whether to include or exclude a query from the processing-time percentile computation. - attributeCriteriaComputedByMinProximity: - type: string - description: When attribute is ranked above proximity in your ranking formula, proximity is used to select which searchable attribute is matched in the attribute ranking stage. - enableABTest: - type: string - description: Whether this search should participate in running AB tests. - enableReRanking: - type: string - description: Whether this search should use AI Re-Ranking. \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index a1868df75e0..e0f0f6fae49 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,10 +12,74 @@ __metadata: "@openapitools/openapi-generator-cli": ^2.4.13 algoliasearch-client-javascript: "file:output/" prettier: 2.4.1 + swagger-cli: ^4.0.4 typescript: 4.4.4 languageName: unknown linkType: soft +"@apidevtools/json-schema-ref-parser@npm:^9.0.6": + version: 9.0.9 + resolution: "@apidevtools/json-schema-ref-parser@npm:9.0.9" + dependencies: + "@jsdevtools/ono": ^7.1.3 + "@types/json-schema": ^7.0.6 + call-me-maybe: ^1.0.1 + js-yaml: ^4.1.0 + checksum: b21f6bdd37d2942c3967ee77569bc74fadd1b922f688daf5ef85057789a2c3a7f4afc473aa2f3a93ec950dabb6ef365f8bd9cf51e4e062a1ee1e59b989f8f9b4 + languageName: node + linkType: hard + +"@apidevtools/openapi-schemas@npm:^2.0.4": + version: 2.1.0 + resolution: "@apidevtools/openapi-schemas@npm:2.1.0" + checksum: 4a8f64935b9049ef21e41fa4b188f39f6bc3f5291cebd451701db1115451ccb246a739e46cc5ce9ecdec781671431db40db7851acdac84a990a45756e0f32de3 + languageName: node + linkType: hard + +"@apidevtools/swagger-cli@npm:4.0.4": + version: 4.0.4 + resolution: "@apidevtools/swagger-cli@npm:4.0.4" + dependencies: + "@apidevtools/swagger-parser": ^10.0.1 + chalk: ^4.1.0 + js-yaml: ^3.14.0 + yargs: ^15.4.1 + bin: + swagger-cli: bin/swagger-cli.js + checksum: 653730283c60e26f784161461184a2a4936d0a5b53c079e19129d0086d3fb9386cfbb674182efd51ed2391f065e1aef067e27a8a98357fc562db010e18b1c161 + languageName: node + linkType: hard + +"@apidevtools/swagger-methods@npm:^3.0.2": + version: 3.0.2 + resolution: "@apidevtools/swagger-methods@npm:3.0.2" + checksum: d06b1ac5c1956613c4c6be695612ef860cd4e962b93a509ca551735a328a856cae1e33399cac1dcbf8333ba22b231746f3586074769ef0e172cf549ec9e7eaae + languageName: node + linkType: hard + +"@apidevtools/swagger-parser@npm:^10.0.1": + version: 10.0.3 + resolution: "@apidevtools/swagger-parser@npm:10.0.3" + dependencies: + "@apidevtools/json-schema-ref-parser": ^9.0.6 + "@apidevtools/openapi-schemas": ^2.0.4 + "@apidevtools/swagger-methods": ^3.0.2 + "@jsdevtools/ono": ^7.1.3 + call-me-maybe: ^1.0.1 + z-schema: ^5.0.1 + peerDependencies: + openapi-types: ">=7" + checksum: 580a86d4c2a667e825dae80d2ed115c282e6210e3cb0ffc39b3bf5fc5b4fcb576cce3fc3d0519b6c4de8fa617ab0dbee1adeac134d0c1364e0a0f7d394b28796 + languageName: node + linkType: hard + +"@jsdevtools/ono@npm:^7.1.3": + version: 7.1.3 + resolution: "@jsdevtools/ono@npm:7.1.3" + checksum: 2297fcd472ba810bffe8519d2249171132844c7174f3a16634f9260761c8c78bc0428a4190b5b6d72d45673c13918ab9844d706c3ed4ef8f62ab11a2627a08ad + languageName: node + linkType: hard + "@nestjs/common@npm:8.0.9": version: 8.0.9 resolution: "@nestjs/common@npm:8.0.9" @@ -115,6 +179,13 @@ __metadata: languageName: node linkType: hard +"@types/json-schema@npm:^7.0.6": + version: 7.0.9 + resolution: "@types/json-schema@npm:7.0.9" + checksum: 259d0e25f11a21ba5c708f7ea47196bd396e379fddb79c76f9f4f62c945879dc21657904914313ec2754e443c5018ea8372362f323f30e0792897fdb2098a705 + languageName: node + linkType: hard + "@types/node@npm:*, @types/node@npm:^16.11.6": version: 16.11.6 resolution: "@types/node@npm:16.11.6" @@ -155,11 +226,11 @@ __metadata: "algoliasearch-client-javascript@file:output/::locator=%40algolia%2Fautomation-javascript-client%40workspace%3A.": version: 5.0.0 - resolution: "algoliasearch-client-javascript@file:output/#output/::hash=cb8090&locator=%40algolia%2Fautomation-javascript-client%40workspace%3A." + resolution: "algoliasearch-client-javascript@file:output/#output/::hash=eecce8&locator=%40algolia%2Fautomation-javascript-client%40workspace%3A." dependencies: "@types/request": ^2.48.7 request: ^2.81.0 - checksum: eb246387ed217c5fddb84329ca25481169b855dc4021bc57271dddd643ff1a0941aa2680d5c02f57b4a3293170b9cb09ab3d833eff11e0619af84259a6185f95 + checksum: f5c39500e1657e312edaccf3fab400ba3c648a0363230274bb435b3f8238996fbd256b31fe5711862dd959bc6d3e936145768e2c16a9f1acf03c1a3d18124a4d languageName: node linkType: hard @@ -199,6 +270,22 @@ __metadata: languageName: node linkType: hard +"argparse@npm:^1.0.7": + version: 1.0.10 + resolution: "argparse@npm:1.0.10" + dependencies: + sprintf-js: ~1.0.2 + checksum: 7ca6e45583a28de7258e39e13d81e925cfa25d7d4aacbf806a382d3c02fcb13403a07fb8aeef949f10a7cfe4a62da0e2e807b348a5980554cc28ee573ef95945 + languageName: node + linkType: hard + +"argparse@npm:^2.0.1": + version: 2.0.1 + resolution: "argparse@npm:2.0.1" + checksum: 83644b56493e89a254bae05702abf3a1101b4fa4d0ca31df1c9985275a5a5bd47b3c27b7fa0b71098d41114d8ca000e6ed90cad764b306f8a503665e4d517ced + languageName: node + linkType: hard + "asn1@npm:~0.2.3": version: 0.2.6 resolution: "asn1@npm:0.2.6" @@ -299,6 +386,20 @@ __metadata: languageName: node linkType: hard +"call-me-maybe@npm:^1.0.1": + version: 1.0.1 + resolution: "call-me-maybe@npm:1.0.1" + checksum: d19e9d6ac2c6a83fb1215718b64c5e233f688ebebb603bdfe4af59cde952df1f2b648530fab555bf290ea910d69d7d9665ebc916e871e0e194f47c2e48e4886b + languageName: node + linkType: hard + +"camelcase@npm:^5.0.0": + version: 5.3.1 + resolution: "camelcase@npm:5.3.1" + checksum: e6effce26b9404e3c0f301498184f243811c30dfe6d0b9051863bd8e4034d09c8c2923794f280d6827e5aa055f6c434115ff97864a16a963366fb35fd673024b + languageName: node + linkType: hard + "caseless@npm:~0.12.0": version: 0.12.0 resolution: "caseless@npm:0.12.0" @@ -346,6 +447,17 @@ __metadata: languageName: node linkType: hard +"cliui@npm:^6.0.0": + version: 6.0.0 + resolution: "cliui@npm:6.0.0" + dependencies: + string-width: ^4.2.0 + strip-ansi: ^6.0.0 + wrap-ansi: ^6.2.0 + checksum: 4fcfd26d292c9f00238117f39fc797608292ae36bac2168cfee4c85923817d0607fe21b3329a8621e01aedf512c99b7eaa60e363a671ffd378df6649fb48ae42 + languageName: node + linkType: hard + "cliui@npm:^7.0.2": version: 7.0.4 resolution: "cliui@npm:7.0.4" @@ -396,6 +508,13 @@ __metadata: languageName: node linkType: hard +"commander@npm:^2.7.1": + version: 2.20.3 + resolution: "commander@npm:2.20.3" + checksum: ab8c07884e42c3a8dbc5dd9592c606176c7eb5c1ca5ff274bcf907039b2c41de3626f684ea75ccf4d361ba004bbaff1f577d5384c155f3871e456bdf27becf9e + languageName: node + linkType: hard + "compare-versions@npm:3.6.0": version: 3.6.0 resolution: "compare-versions@npm:3.6.0" @@ -467,6 +586,13 @@ __metadata: languageName: node linkType: hard +"decamelize@npm:^1.2.0": + version: 1.2.0 + resolution: "decamelize@npm:1.2.0" + checksum: ad8c51a7e7e0720c70ec2eeb1163b66da03e7616d7b98c9ef43cce2416395e84c1e9548dd94f5f6ffecfee9f8b94251fc57121a8b021f2ff2469b2bae247b8aa + languageName: node + linkType: hard + "defaults@npm:^1.0.3": version: 1.0.3 resolution: "defaults@npm:1.0.3" @@ -526,6 +652,16 @@ __metadata: languageName: node linkType: hard +"esprima@npm:^4.0.0": + version: 4.0.1 + resolution: "esprima@npm:4.0.1" + bin: + esparse: ./bin/esparse.js + esvalidate: ./bin/esvalidate.js + checksum: b45bc805a613dbea2835278c306b91aff6173c8d034223fa81498c77dcbce3b2931bf6006db816f62eacd9fd4ea975dfd85a5b7f3c6402cfd050d4ca3c13a628 + languageName: node + linkType: hard + "extend@npm:~3.0.2": version: 3.0.2 resolution: "extend@npm:3.0.2" @@ -588,6 +724,16 @@ __metadata: languageName: node linkType: hard +"find-up@npm:^4.1.0": + version: 4.1.0 + resolution: "find-up@npm:4.1.0" + dependencies: + locate-path: ^5.0.0 + path-exists: ^4.0.0 + checksum: 4c172680e8f8c1f78839486e14a43ef82e9decd0e74145f40707cc42e7420506d5ec92d9a11c22bd2c48fb0c384ea05dd30e10dd152fefeec6f2f75282a8b844 + languageName: node + linkType: hard + "follow-redirects@npm:^1.14.0": version: 1.14.5 resolution: "follow-redirects@npm:1.14.5" @@ -645,7 +791,7 @@ __metadata: languageName: node linkType: hard -"get-caller-file@npm:^2.0.5": +"get-caller-file@npm:^2.0.1, get-caller-file@npm:^2.0.5": version: 2.0.5 resolution: "get-caller-file@npm:2.0.5" checksum: b9769a836d2a98c3ee734a88ba712e62703f1df31b94b784762c433c27a386dd6029ff55c2a920c392e33657d80191edbf18c61487e198844844516f843496b9 @@ -814,6 +960,29 @@ __metadata: languageName: node linkType: hard +"js-yaml@npm:^3.14.0": + version: 3.14.1 + resolution: "js-yaml@npm:3.14.1" + dependencies: + argparse: ^1.0.7 + esprima: ^4.0.0 + bin: + js-yaml: bin/js-yaml.js + checksum: bef146085f472d44dee30ec34e5cf36bf89164f5d585435a3d3da89e52622dff0b188a580e4ad091c3341889e14cb88cac6e4deb16dc5b1e9623bb0601fc255c + languageName: node + linkType: hard + +"js-yaml@npm:^4.1.0": + version: 4.1.0 + resolution: "js-yaml@npm:4.1.0" + dependencies: + argparse: ^2.0.1 + bin: + js-yaml: bin/js-yaml.js + checksum: c7830dfd456c3ef2c6e355cc5a92e6700ceafa1d14bba54497b34a99f0376cecbb3e9ac14d3e5849b426d5a5140709a66237a8c991c675431271c4ce5504151a + languageName: node + linkType: hard + "jsbn@npm:~0.1.0": version: 0.1.1 resolution: "jsbn@npm:0.1.1" @@ -867,6 +1036,29 @@ __metadata: languageName: node linkType: hard +"locate-path@npm:^5.0.0": + version: 5.0.0 + resolution: "locate-path@npm:5.0.0" + dependencies: + p-locate: ^4.1.0 + checksum: 83e51725e67517287d73e1ded92b28602e3ae5580b301fe54bfb76c0c723e3f285b19252e375712316774cf52006cb236aed5704692c32db0d5d089b69696e30 + languageName: node + linkType: hard + +"lodash.get@npm:^4.4.2": + version: 4.4.2 + resolution: "lodash.get@npm:4.4.2" + checksum: e403047ddb03181c9d0e92df9556570e2b67e0f0a930fcbbbd779370972368f5568e914f913e93f3b08f6d492abc71e14d4e9b7a18916c31fa04bd2306efe545 + languageName: node + linkType: hard + +"lodash.isequal@npm:^4.5.0": + version: 4.5.0 + resolution: "lodash.isequal@npm:4.5.0" + checksum: da27515dc5230eb1140ba65ff8de3613649620e8656b19a6270afe4866b7bd461d9ba2ac8a48dcc57f7adac4ee80e1de9f965d89d4d81a0ad52bb3eec2609644 + languageName: node + linkType: hard + "lodash@npm:4.17.21, lodash@npm:^4.17.21": version: 4.17.21 resolution: "lodash@npm:4.17.21" @@ -988,6 +1180,38 @@ __metadata: languageName: node linkType: hard +"p-limit@npm:^2.2.0": + version: 2.3.0 + resolution: "p-limit@npm:2.3.0" + dependencies: + p-try: ^2.0.0 + checksum: 84ff17f1a38126c3314e91ecfe56aecbf36430940e2873dadaa773ffe072dc23b7af8e46d4b6485d302a11673fe94c6b67ca2cfbb60c989848b02100d0594ac1 + languageName: node + linkType: hard + +"p-locate@npm:^4.1.0": + version: 4.1.0 + resolution: "p-locate@npm:4.1.0" + dependencies: + p-limit: ^2.2.0 + checksum: 513bd14a455f5da4ebfcb819ef706c54adb09097703de6aeaa5d26fe5ea16df92b48d1ac45e01e3944ce1e6aa2a66f7f8894742b8c9d6e276e16cd2049a2b870 + languageName: node + linkType: hard + +"p-try@npm:^2.0.0": + version: 2.2.0 + resolution: "p-try@npm:2.2.0" + checksum: f8a8e9a7693659383f06aec604ad5ead237c7a261c18048a6e1b5b85a5f8a067e469aa24f5bc009b991ea3b058a87f5065ef4176793a200d4917349881216cae + languageName: node + linkType: hard + +"path-exists@npm:^4.0.0": + version: 4.0.0 + resolution: "path-exists@npm:4.0.0" + checksum: 505807199dfb7c50737b057dd8d351b82c033029ab94cb10a657609e00c1bc53b951cfdbccab8de04c5584d5eff31128ce6afd3db79281874a5ef2adbba55ed1 + languageName: node + linkType: hard + "path-is-absolute@npm:^1.0.0": version: 1.0.1 resolution: "path-is-absolute@npm:1.0.1" @@ -1092,6 +1316,13 @@ __metadata: languageName: node linkType: hard +"require-main-filename@npm:^2.0.0": + version: 2.0.0 + resolution: "require-main-filename@npm:2.0.0" + checksum: e9e294695fea08b076457e9ddff854e81bffbe248ed34c1eec348b7abbd22a0d02e8d75506559e2265e96978f3c4720bd77a6dad84755de8162b357eb6c778c7 + languageName: node + linkType: hard + "restore-cursor@npm:^3.1.0": version: 3.1.0 resolution: "restore-cursor@npm:3.1.0" @@ -1141,6 +1372,13 @@ __metadata: languageName: node linkType: hard +"set-blocking@npm:^2.0.0": + version: 2.0.0 + resolution: "set-blocking@npm:2.0.0" + checksum: 6e65a05f7cf7ebdf8b7c75b101e18c0b7e3dff4940d480efed8aad3a36a4005140b660fa1d804cb8bce911cac290441dc728084a30504d3516ac2ff7ad607b02 + languageName: node + linkType: hard + "signal-exit@npm:^3.0.2": version: 3.0.5 resolution: "signal-exit@npm:3.0.5" @@ -1155,6 +1393,13 @@ __metadata: languageName: node linkType: hard +"sprintf-js@npm:~1.0.2": + version: 1.0.3 + resolution: "sprintf-js@npm:1.0.3" + checksum: 19d79aec211f09b99ec3099b5b2ae2f6e9cdefe50bc91ac4c69144b6d3928a640bb6ae5b3def70c2e85a2c3d9f5ec2719921e3a59d3ca3ef4b2fd1a4656a0df3 + languageName: node + linkType: hard + "sshpk@npm:^1.7.0": version: 1.16.1 resolution: "sshpk@npm:1.16.1" @@ -1223,6 +1468,17 @@ __metadata: languageName: node linkType: hard +"swagger-cli@npm:^4.0.4": + version: 4.0.4 + resolution: "swagger-cli@npm:4.0.4" + dependencies: + "@apidevtools/swagger-cli": 4.0.4 + bin: + swagger-cli: swagger-cli.js + checksum: 6e98774cd18f6655b0a3353e6b5f9001dcf945c2038829b8e7ba8f74f52a5d55de9c72acbdbc0dcbfc6b629ab1f143624b88b24a2539c6b8a7ff120114137b67 + languageName: node + linkType: hard + "through@npm:^2.3.6": version: 2.3.8 resolution: "through@npm:2.3.8" @@ -1377,6 +1633,13 @@ __metadata: languageName: node linkType: hard +"validator@npm:^13.6.0": + version: 13.7.0 + resolution: "validator@npm:13.7.0" + checksum: 2b83283de1222ca549a7ef57f46e8d49c6669213348db78b7045bce36a3b5843ff1e9f709ebf74574e06223461ee1f264f8cc9a26a0060a79a27de079d8286ef + languageName: node + linkType: hard + "verror@npm:1.10.0": version: 1.10.0 resolution: "verror@npm:1.10.0" @@ -1414,6 +1677,24 @@ __metadata: languageName: node linkType: hard +"which-module@npm:^2.0.0": + version: 2.0.0 + resolution: "which-module@npm:2.0.0" + checksum: 809f7fd3dfcb2cdbe0180b60d68100c88785084f8f9492b0998c051d7a8efe56784492609d3f09ac161635b78ea29219eb1418a98c15ce87d085bce905705c9c + languageName: node + linkType: hard + +"wrap-ansi@npm:^6.2.0": + version: 6.2.0 + resolution: "wrap-ansi@npm:6.2.0" + dependencies: + ansi-styles: ^4.0.0 + string-width: ^4.1.0 + strip-ansi: ^6.0.0 + checksum: 6cd96a410161ff617b63581a08376f0cb9162375adeb7956e10c8cd397821f7eb2a6de24eb22a0b28401300bf228c86e50617cd568209b5f6775b93c97d2fe3a + languageName: node + linkType: hard + "wrap-ansi@npm:^7.0.0": version: 7.0.0 resolution: "wrap-ansi@npm:7.0.0" @@ -1432,6 +1713,13 @@ __metadata: languageName: node linkType: hard +"y18n@npm:^4.0.0": + version: 4.0.3 + resolution: "y18n@npm:4.0.3" + checksum: 014dfcd9b5f4105c3bb397c1c8c6429a9df004aa560964fb36732bfb999bfe83d45ae40aeda5b55d21b1ee53d8291580a32a756a443e064317953f08025b1aa4 + languageName: node + linkType: hard + "y18n@npm:^5.0.5": version: 5.0.8 resolution: "y18n@npm:5.0.8" @@ -1439,6 +1727,16 @@ __metadata: languageName: node linkType: hard +"yargs-parser@npm:^18.1.2": + version: 18.1.3 + resolution: "yargs-parser@npm:18.1.3" + dependencies: + camelcase: ^5.0.0 + decamelize: ^1.2.0 + checksum: 60e8c7d1b85814594d3719300ecad4e6ae3796748b0926137bfec1f3042581b8646d67e83c6fc80a692ef08b8390f21ddcacb9464476c39bbdf52e34961dd4d9 + languageName: node + linkType: hard + "yargs-parser@npm:^20.2.2": version: 20.2.9 resolution: "yargs-parser@npm:20.2.9" @@ -1446,6 +1744,25 @@ __metadata: languageName: node linkType: hard +"yargs@npm:^15.4.1": + version: 15.4.1 + resolution: "yargs@npm:15.4.1" + dependencies: + cliui: ^6.0.0 + decamelize: ^1.2.0 + find-up: ^4.1.0 + get-caller-file: ^2.0.1 + require-directory: ^2.1.1 + require-main-filename: ^2.0.0 + set-blocking: ^2.0.0 + string-width: ^4.2.0 + which-module: ^2.0.0 + y18n: ^4.0.0 + yargs-parser: ^18.1.2 + checksum: 40b974f508d8aed28598087720e086ecd32a5fd3e945e95ea4457da04ee9bdb8bdd17fd91acff36dc5b7f0595a735929c514c40c402416bbb87c03f6fb782373 + languageName: node + linkType: hard + "yargs@npm:^16.2.0": version: 16.2.0 resolution: "yargs@npm:16.2.0" @@ -1460,3 +1777,20 @@ __metadata: checksum: b14afbb51e3251a204d81937c86a7e9d4bdbf9a2bcee38226c900d00f522969ab675703bee2a6f99f8e20103f608382936034e64d921b74df82b63c07c5e8f59 languageName: node linkType: hard + +"z-schema@npm:^5.0.1": + version: 5.0.1 + resolution: "z-schema@npm:5.0.1" + dependencies: + commander: ^2.7.1 + lodash.get: ^4.4.2 + lodash.isequal: ^4.5.0 + validator: ^13.6.0 + dependenciesMeta: + commander: + optional: true + bin: + z-schema: bin/z-schema + checksum: 9e825d3c426efe65291c84178139b1a3dd08f9e70a6ba2844c3125d97c140abedf5f6799e05c22e9dc4ce005b49db3ca916e9dc6d98d903086a75fe256fef067 + languageName: node + linkType: hard From 7cf934a18f4d2369c85b4bfffb1544385db6c765 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Mon, 8 Nov 2021 14:49:00 +0100 Subject: [PATCH 4/8] some fixups --- openapi_spec/paths/indexes/batch.yml | 49 +- openapi_spec/schemas/SearchParams.yml | 856 +++++++++++++------------- 2 files changed, 456 insertions(+), 449 deletions(-) diff --git a/openapi_spec/paths/indexes/batch.yml b/openapi_spec/paths/indexes/batch.yml index e5490426df6..0302a020676 100644 --- a/openapi_spec/paths/indexes/batch.yml +++ b/openapi_spec/paths/indexes/batch.yml @@ -12,28 +12,33 @@ post: content: application/json: schema: - type: array - items: - title: operation - type: object - additionalProperties: false - properties: - action: - type: string - enum: - - "addObject" - - "updateObject" - - "partialUpdateObject" - - "partialUpdateObjectNoCreate" - - "deleteObject" - - "delete" - - "clear" - description: type of operation - body: - type: object - # this could be a long oneOf with every possibilities - additionalProperties: true - description: arguments to the operation (depends on the type of the operation) + allOf: + - $ref: "../../schemas/SearchParams.yml" + - type: object + properties: + requests: + type: array + items: + title: operation + type: object + additionalProperties: false + properties: + action: + type: string + enum: + - "addObject" + - "updateObject" + - "partialUpdateObject" + - "partialUpdateObjectNoCreate" + - "deleteObject" + - "delete" + - "clear" + description: type of operation + body: + type: object + # this could be a long oneOf with every possibilities + additionalProperties: true + description: arguments to the operation (depends on the type of the operation) responses: "200": description: OK diff --git a/openapi_spec/schemas/SearchParams.yml b/openapi_spec/schemas/SearchParams.yml index 43c63e3608d..e45a88ed52f 100644 --- a/openapi_spec/schemas/SearchParams.yml +++ b/openapi_spec/schemas/SearchParams.yml @@ -1,449 +1,451 @@ type: object additionalProperties: false properties: -query: - type: string - summary: The text to search in the index. - default: "" -similarQuery: - type: string - summary: Overrides the query parameter and performs a more generic search that can be used to find “similar” results. - default: "" -searchableAttributes: - type: array - items: + query: type: string - summary: The complete list of attributes used for searching. - default: [] -attributesForFaceting: - type: array - items: + description: The text to search in the index. + default: "" + similarQuery: type: string - summary: The complete list of attributes that will be used for faceting. - default: [] -unretrievableAttributes: - type: array - items: + description: Overrides the query parameter and performs a more generic search that can be used to find “similar” results. + default: "" + searchableAttributes: + type: array + items: + type: string + description: The complete list of attributes used for searching. + default: [] + attributesForFaceting: + type: array + items: + type: string + description: The complete list of attributes that will be used for faceting. + default: [] + unretrievableAttributes: + type: array + items: + type: string + description: List of attributes that can’t be retrieved at query time. + default: [] + attributesToRetrieve: + type: array + items: + type: string + description: This parameter controls which attributes to retrieve and which not to retrieve. + default: ["*"] + restrictSearchableAttributes: + type: array + items: + type: string + description: Restricts a given query to look in only a subset of your searchable attributes. + default: [] + ranking: + type: array + items: + type: string + description: Controls how Algolia should sort your results. + default: + - "typo" + - "geo" + - "words" + - "filters" + - "proximity" + - "attribute" + - "exact" + - "custom" + customRanking: + type: array + items: + type: string + description: Specifies the custom ranking criterion. + default: [] + relevancyStrictness: + type: integer + description: Controls the relevancy threshold below which less relevant results aren’t included in the results. + default: 100 + replicas: + type: array + items: + type: string + description: Creates replicas, exact copies of an index. + default: [] + filters: type: string - summary: List of attributes that can’t be retrieved at query time. - default: [] -attributesToRetrieve: - type: array - items: + description: Filter the query with numeric, facet and/or tag filters. + default: "" + # There could be a pattern for this one (complicated one) + facetFilters: + type: array + items: + type: string + description: Filter hits by facet value. + default: [] + optionalFilters: + type: array + items: + type: string + description: Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter. + default: [] + numericFilters: + type: array + items: + type: string + description: Filter on numeric attributes. + default: [] + tagFilters: + type: array + items: + type: string + description: Filter hits by tags. + default: [] + sumOrFiltersScores: + type: boolean + description: Determines how to calculate the total score for filtering. + default: false + facets: + type: array + items: + type: string + description: Retrieve facets and their facet values. + default: [] + maxValuesPerFacet: + type: integer + description: Maximum number of facet values to return for each facet during a regular search. + default: 100 + facetingAfterDistinct: + type: boolean + description: Force faceting to be applied after de-duplication (via the Distinct setting). + default: false + sortFacetValuesBy: type: string - summary: This parameter controls which attributes to retrieve and which not to retrieve. - default: ["*"] -restrictSearchableAttributes: - type: array - items: + description: Controls how facet values are fetched. + default: "count" + attributesToHighlight: + type: array + items: + type: string + description: List of attributes to highlight. + attributesToSnippet: + type: array + items: + type: string + description: List of attributes to snippet, with an optional maximum number of words to snippet. + default: [] + highlightPreTag: type: string - summary: Restricts a given query to look in only a subset of your searchable attributes. - default: [] -ranking: - type: array - items: + description: The HTML string to insert before the highlighted parts in all highlight and snippet results. + default: "" + highlightPostTag: type: string - summary: Controls how Algolia should sort your results. - default: - - "typo" - - "geo" - - "words" - - "filters" - - "proximity" - - "attribute" - - "exact" - - "custom" -customRanking: - type: array - items: + description: The HTML string to insert after the highlighted parts in all highlight and snippet results. + default: "" + snippetEllipsisText: type: string - summary: Specifies the custom ranking criterion. - default: [] -relevancyStrictness: - type: integer - summary: Controls the relevancy threshold below which less relevant results aren’t included in the results. - default: 100 -replicas: - type: array - items: + description: String used as an ellipsis indicator when a snippet is truncated. + default: "…" + restrictHighlightAndSnippetArrays: + type: boolean + description: Restrict highlighting and snippeting to items that matched the query. + default: false + page: + type: integer + description: Specify the page to retrieve. + default: 0 + hitsPerPage: + type: integer + description: Set the number of hits per page. + default: 20 + offset: + type: integer + description: Specify the offset of the first hit to return. + default: null + length: + type: integer + description: Set the number of hits to retrieve (used only with offset). + default: null + paginationLimitedTo: + type: integer + description: Set the maximum number of hits accessible via pagination. + default: 1000 + minWordSizefor1Typo: + type: integer + description: Minimum number of characters a word in the query string must contain to accept matches with 1 typo. + default: 4 + minWordSizefor2Typos: + type: integer + description: Minimum number of characters a word in the query string must contain to accept matches with 2 typos. + default: 8 + typoTolerance: type: string - summary: Creates replicas, exact copies of an index. - default: [] -filters: - type: string - summary: Filter the query with numeric, facet and/or tag filters. - default: "" - # There could be a pattern for this one (complicated one) -facetFilters: - type: array - items: + enum: [true, false, "min", "strict"] + description: Controls whether typo tolerance is enabled and how it is applied. + default: true + allowTyposOnNumericTokens: + type: boolean + description: Whether to allow typos on numbers (“numeric tokens”) in the query string. + default: true + disableTypoToleranceOnAttributes: + type: array + items: + type: string + description: List of attributes on which you want to disable typo tolerance. + default: [] + disableTypoToleranceOnWords: + type: array + items: + type: string + description: A list of words for which you want to turn off typo tolerance. + default: [] + separatorsToIndex: type: string - summary: Filter hits by facet value. - default: [] -optionalFilters: - type: array - items: + description: Control which separators are indexed. + default: "" + aroundLatLng: type: string - summary: Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter. - default: [] -numericFilters: - type: array - items: + description: Search for entries around a central geolocation, enabling a geo search within a circular area. + default: null + aroundLatLngViaIP: + type: boolean + description: Search for entries around a given location automatically computed from the requester’s IP address. + default: false + aroundRadius: type: string - summary: Filter on numeric attributes. - default: [] -tagFilters: - type: array - items: + description: Define the maximum radius for a geo search (in meters). + default: null + aroundPrecision: + type: integer + description: Precision of geo search (in meters), to add grouping by geo location to the ranking formula. + default: 10 + minimumAroundRadius: + type: integer + description: Minimum radius (in meters) used for a geo search when aroundRadius is not set. + default: null + insideBoundingBox: + type: array + items: + type: number + description: Search inside a rectangular area (in geo coordinates). + default: null + insidePolygon: + type: array + items: + type: number + description: Search inside a polygon (in geo coordinates). + default: null + ignorePlurals: type: string - summary: Filter hits by tags. - default: [] -sumOrFiltersScores: - type: boolean - summary: Determines how to calculate the total score for filtering. - default: false -facets: - type: array - items: + description: Treats singular, plurals, and other forms of declensions as matching terms. + default: false + attributesToTransliterate: + type: array + items: + type: string + description: Specify on which attributes to apply transliteration. + removeStopWords: type: string - summary: Retrieve facets and their facet values. - default: [] -maxValuesPerFacet: - type: integer - summary: Maximum number of facet values to return for each facet during a regular search. - default: 100 -facetingAfterDistinct: - type: boolean - summary: Force faceting to be applied after de-duplication (via the Distinct setting). - default: false -sortFacetValuesBy: - type: string - summary: Controls how facet values are fetched. - default: "count" -attributesToHighlight: - type: array - items: + description: Removes stop (common) words from the query before executing it. + default: false + camelCaseAttributes: + type: array + items: + type: string + description: List of attributes on which to do a decomposition of camel case words. + default: [] + decompoundedAttributes: + type: object + additionalProperties: true + description: Specify on which attributes in your index Algolia should apply word segmentation, also known as decompounding. + default: {} + keepDiacriticsOnCharacters: type: string - summary: List of attributes to highlight. -attributesToSnippet: - type: array - items: + description: List of characters that the engine shouldn’t automatically normalize. + default: "" + customNormalization: + type: object + additionalProperties: true + description: Override the default normalization handled by the engine. + default: {} + queryLanguages: + type: array + items: + type: string + description: Sets the languages to be used by language-specific settings and functionalities such as ignorePlurals, removeStopWords, and CJK word-detection. + default: [] + indexLanguages: + type: array + items: + type: string + description: Sets the languages at the index level for language-specific processing such as tokenization and normalization. + default: [] + naturalLanguages: + type: array + items: + type: string + description: This parameter changes the default values of certain parameters and settings that work best for a natural language query, such as ignorePlurals, removeStopWords, removeWordsIfNoResults, analyticsTags and ruleContexts. These parameters and settings work well together when the query is formatted in natural language instead of keywords, for example when your user performs a voice search. + default: [] + decompoundQuery: + type: boolean + description: Splits compound words into their composing atoms in the query. + default: true + enableRules: + type: boolean + description: Whether Rules should be globally enabled. + default: true + filterPromotes: + type: boolean + description: Whether promoted results should match the filters of the current search, except for geographic filters. + default: false + ruleContexts: + type: array + items: + type: string + description: Enables contextual rules. + default: [] + enablePersonalization: + type: boolean + description: Enable the Personalization feature. + default: false + personalizationImpact: + type: integer + description: Define the impact of the Personalization feature. + default: 100 + userToken: type: string - summary: List of attributes to snippet, with an optional maximum number of words to snippet. - default: [] -highlightPreTag: - type: string - summary: The HTML string to insert before the highlighted parts in all highlight and snippet results. - default: "" -highlightPostTag: - type: string - summary: The HTML string to insert after the highlighted parts in all highlight and snippet results. - default: "" -snippetEllipsisText: - type: string - summary: String used as an ellipsis indicator when a snippet is truncated. - default: "…" -restrictHighlightAndSnippetArrays: - type: boolean - summary: Restrict highlighting and snippeting to items that matched the query. - default: false -page: - type: integer - summary: Specify the page to retrieve. - default: 0 -hitsPerPage: - type: integer - summary: Set the number of hits per page. - default: 20 -offset: - type: integer - summary: Specify the offset of the first hit to return. - default: null -length: - type: integer - summary: Set the number of hits to retrieve (used only with offset). - default: null -paginationLimitedTo: - type: integer - summary: Set the maximum number of hits accessible via pagination. - default: 1000 -minWordSizefor1Typo: - type: integer - summary: Minimum number of characters a word in the query string must contain to accept matches with 1 typo. - default: 4 -minWordSizefor2Typos: - type: integer - summary: Minimum number of characters a word in the query string must contain to accept matches with 2 typos. - default: 8 -typoTolerance: - type: string - enum: [true, false, "min", "strict"] - summary: Controls whether typo tolerance is enabled and how it is applied. - default: true -allowTyposOnNumericTokens: - type: boolean - summary: Whether to allow typos on numbers (“numeric tokens”) in the query string. - default: true -disableTypoToleranceOnAttributes: - type: array - items: + description: Associates a certain user token with the current search. + queryType: type: string - summary: List of attributes on which you want to disable typo tolerance. - default: [] -disableTypoToleranceOnWords: - type: array - items: + enum: ["prefixLast", "prefixAll", "prefixNone"] + description: Controls if and how query words are interpreted as prefixes. + default: "prefixLast" + removeWordsIfNoResults: type: string - summary: A list of words for which you want to turn off typo tolerance. - default: [] -separatorsToIndex: - type: string - summary: Control which separators are indexed. - default: "" -aroundLatLng: - type: string - summary: Search for entries around a central geolocation, enabling a geo search within a circular area. - default: null -aroundLatLngViaIP: - type: boolean - summary: Search for entries around a given location automatically computed from the requester’s IP address. - default: false -aroundRadius: - type: string - summary: Define the maximum radius for a geo search (in meters). - default: null -aroundPrecision: - type: integer - summary: Precision of geo search (in meters), to add grouping by geo location to the ranking formula. - default: 10 -minimumAroundRadius: - type: integer - summary: Minimum radius (in meters) used for a geo search when aroundRadius is not set. - default: null -insideBoundingBox: - type: array - items: - type: float - summary: Search inside a rectangular area (in geo coordinates). - default: null -insidePolygon: - type: array - items: - type: float - summary: Search inside a polygon (in geo coordinates). - default: null -ignorePlurals: - type: string - summary: Treats singular, plurals, and other forms of declensions as matching terms. - default: false -attributesToTransliterate: - type: array - summary: Specify on which attributes to apply transliteration. -removeStopWords: - type: string - summary: Removes stop (common) words from the query before executing it. - default: false -camelCaseAttributes: - type: array - items: + enum: ["none", "lastWords", "firstWords", "allOptional"] + description: Selects a strategy to remove words from the query when it doesn’t match any hits. + default: "none" + advancedSyntax: + type: boolean + description: Enables the advanced query syntax. + default: false + optionalWords: + type: array + items: + type: string + description: A list of words that should be considered as optional when found in the query. + default: [] + disablePrefixOnAttributes: + type: array + items: + type: string + description: List of attributes on which you want to disable prefix matching. + default: [] + disableExactOnAttributes: + type: array + items: + type: string + description: List of attributes on which you want to disable the exact ranking criterion. + default: [] + exactOnSingleWordQuery: type: string - summary: List of attributes on which to do a decomposition of camel case words. - default: [] -decompoundedAttributes: - type: object - additionalProperties: true - summary: Specify on which attributes in your index Algolia should apply word segmentation, also known as decompounding. - default: {} -keepDiacriticsOnCharacters: - type: string - summary: List of characters that the engine shouldn’t automatically normalize. - default: "" -customNormalization: - type: object - additionalProperties: true - summary: Override the default normalization handled by the engine. - default: {} -queryLanguages: - type: array - items: + enum: ["attribute", "none", "word"] + description: Controls how the exact ranking criterion is computed when the query contains only one word. + default: "attribute" + alternativesAsExact: + type: array + items: + type: string + enum: ["ignorePlurals", "singleWordSynonym", "multiWordsSynonym"] + description: List of alternatives that should be considered an exact match by the exact ranking criterion. + default: ["ignorePlurals", "singleWordSynonym"] + advancedSyntaxFeatures: + type: array + items: + type: string + enum: ["exactPhrase", "excludeWords"] + description: Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is enabled. + default: ["exactPhrase", "excludeWords"] + numericAttributesForFiltering: + type: array + items: + type: string + description: List of numeric attributes that can be used as numerical filters. + default: null + allowCompressionOfIntegerArray: + type: boolean + description: Enables compression of large integer arrays. + default: false + attributeForDistinct: type: string - summary: Sets the languages to be used by language-specific settings and functionalities such as ignorePlurals, removeStopWords, and CJK word-detection. - default: [] -indexLanguages: - type: array - items: - type: string - summary: Sets the languages at the index level for language-specific processing such as tokenization and normalization. - default: [] -naturalLanguages: - type: array - items: - type: string - summary: This parameter changes the default values of certain parameters and settings that work best for a natural language query, such as ignorePlurals, removeStopWords, removeWordsIfNoResults, analyticsTags and ruleContexts. These parameters and settings work well together when the query is formatted in natural language instead of keywords, for example when your user performs a voice search. - default: [] -decompoundQuery: - type: boolean - summary: Splits compound words into their composing atoms in the query. - default: true -enableRules: - type: boolean - summary: Whether Rules should be globally enabled. - default: true -filterPromotes: - type: boolean - summary: Whether promoted results should match the filters of the current search, except for geographic filters. - default: false -ruleContexts: - type: array - items: - type: string - summary: Enables contextual rules. - default: [] -enablePersonalization: - type: boolean - summary: Enable the Personalization feature. - default: false -personalizationImpact: - type: integer - summary: Define the impact of the Personalization feature. - default: 100 -userToken: - type: string - summary: Associates a certain user token with the current search. -queryType: - type: string - enum: ["prefixLast", "prefixAll", "prefixNone"] - summary: Controls if and how query words are interpreted as prefixes. - default: "prefixLast" -removeWordsIfNoResults: - type: string - enum: ["none", "lastWords", "firstWords", "allOptional"] - summary: Selects a strategy to remove words from the query when it doesn’t match any hits. - default: "none" -advancedSyntax: - type: boolean - summary: Enables the advanced query syntax. - default: false -optionalWords: - type: array - items: - type: string - summary: A list of words that should be considered as optional when found in the query. - default: [] -disablePrefixOnAttributes: - type: array - items: - type: string - summary: List of attributes on which you want to disable prefix matching. - default: [] -disableExactOnAttributes: - type: array - items: - type: string - summary: List of attributes on which you want to disable the exact ranking criterion. - default: [] -exactOnSingleWordQuery: - type: string - enum: ["attribute", "none", "word"] - summary: Controls how the exact ranking criterion is computed when the query contains only one word. - default: "attribute" -alternativesAsExact: - type: array - items: - type: string - enum: ["ignorePlurals", "singleWordSynonym", "multiWordsSynonym"] - summary: List of alternatives that should be considered an exact match by the exact ranking criterion. - default: ["ignorePlurals", "singleWordSynonym"] -advancedSyntaxFeatures: - type: array - items: - type: string - enums: ["exactPhrase", "excludeWords"] - summary: Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is enabled. - default: ["exactPhrase", "excludeWords"] -numericAttributesForFiltering: - type: array - items: - type: string - summary: List of numeric attributes that can be used as numerical filters. - default: null -allowCompressionOfIntegerArray: - type: boolean - summary: Enables compression of large integer arrays. - default: false -attributeForDistinct: - type: string - summary: Name of the de-duplication attribute to be used with the distinct feature. - default: null -distinct: - type: integer - min: 0 - max: 4 - summary: Enables de-duplication or grouping of results. - default: 0 -getRankingInfo: - type: boolean - summary: Retrieve detailed ranking information. - default: false -clickAnalytics: - type: boolean - summary: Enable the Click Analytics feature. - default: false -analytics: - type: boolean - summary: Whether the current query will be taken into account in the Analytics. - default: true -analyticsTags: - type: array - items: - type: string - summary: List of tags to apply to the query for analytics purposes. - default: [] -synonyms: - type: boolean - summary: Whether to take into account an index’s synonyms for a particular search. - default: true -replaceSynonymsInHighlight: - type: boolean - summary: Whether to highlight and snippet the original word that matches the synonym or the synonym itself. - default: false -minProximity: - type: integer - min: 1 - max: 7 - summary: Precision of the proximity ranking criterion. - default: 1 -responseFields: - type: array - items: - type: string - summary: Choose which fields to return in the API response. This parameters applies to search and browse queries. -maxFacetHits: - type: integer - summary: Maximum number of facet hits to return during a search for facet values. - default: 10 -percentileComputation: - type: boolean - summary: Whether to include or exclude a query from the processing-time percentile computation. - default: true -attributeCriteriaComputedByMinProximity: - type: boolean - summary: When attribute is ranked above proximity in your ranking formula, proximity is used to select which searchable attribute is matched in the attribute ranking stage. - default: false -userData: - type: object - additionalProperties: true - summary: Lets you store custom data in your indices. - default: {} -enableABTest: - type: boolean - summary: Whether this search should participate in running AB tests. - default: true -enableReRanking: - type: boolean - summary: Whether this search should use AI Re-Ranking. - default: true -renderingContent: - type: object - summary: Content defining how the search interface should be rendered. Can be set via the settings for a default value and can be overridden via rules. - default: {} + description: Name of the de-duplication attribute to be used with the distinct feature. + default: null + distinct: + type: integer + minimum: 0 + maximum: 4 + description: Enables de-duplication or grouping of results. + default: 0 + getRankingInfo: + type: boolean + description: Retrieve detailed ranking information. + default: false + clickAnalytics: + type: boolean + description: Enable the Click Analytics feature. + default: false + analytics: + type: boolean + description: Whether the current query will be taken into account in the Analytics. + default: true + analyticsTags: + type: array + items: + type: string + description: List of tags to apply to the query for analytics purposes. + default: [] + synonyms: + type: boolean + description: Whether to take into account an index’s synonyms for a particular search. + default: true + replaceSynonymsInHighlight: + type: boolean + description: Whether to highlight and snippet the original word that matches the synonym or the synonym itself. + default: false + minProximity: + type: integer + minimum: 1 + maximum: 7 + description: Precision of the proximity ranking criterion. + default: 1 + responseFields: + type: array + items: + type: string + description: Choose which fields to return in the API response. This parameters applies to search and browse queries. + maxFacetHits: + type: integer + description: Maximum number of facet hits to return during a search for facet values. + default: 10 + percentileComputation: + type: boolean + description: Whether to include or exclude a query from the processing-time percentile computation. + default: true + attributeCriteriaComputedByMinProximity: + type: boolean + description: When attribute is ranked above proximity in your ranking formula, proximity is used to select which searchable attribute is matched in the attribute ranking stage. + default: false + userData: + type: object + additionalProperties: true + description: Lets you store custom data in your indices. + default: {} + enableABTest: + type: boolean + description: Whether this search should participate in running AB tests. + default: true + enableReRanking: + type: boolean + description: Whether this search should use AI Re-Ranking. + default: true + renderingContent: + type: object + description: Content defining how the search interface should be rendered. Can be set via the settings for a default value and can be overridden via rules. + default: {} From 47fc15dece055f6ba89f82fef3374f80203bdb25 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Tue, 9 Nov 2021 10:51:24 +0100 Subject: [PATCH 5/8] more fixups --- openapi_spec/paths/indexes/batch.yml | 50 +++++++++-------- openapi_spec/paths/indexes/saveObject.yml | 4 +- openapi_spec/paths/indexes/searchMulti.yml | 62 ++++++++++++---------- 3 files changed, 61 insertions(+), 55 deletions(-) diff --git a/openapi_spec/paths/indexes/batch.yml b/openapi_spec/paths/indexes/batch.yml index 0302a020676..e37aafe8dc6 100644 --- a/openapi_spec/paths/indexes/batch.yml +++ b/openapi_spec/paths/indexes/batch.yml @@ -12,33 +12,31 @@ post: content: application/json: schema: - allOf: - - $ref: "../../schemas/SearchParams.yml" - - type: object - properties: - requests: - type: array - items: - title: operation + type: object + properties: + requests: + type: array + items: + title: operation + type: object + additionalProperties: false + properties: + action: + type: string + enum: + - "addObject" + - "updateObject" + - "partialUpdateObject" + - "partialUpdateObjectNoCreate" + - "deleteObject" + - "delete" + - "clear" + description: type of operation + body: type: object - additionalProperties: false - properties: - action: - type: string - enum: - - "addObject" - - "updateObject" - - "partialUpdateObject" - - "partialUpdateObjectNoCreate" - - "deleteObject" - - "delete" - - "clear" - description: type of operation - body: - type: object - # this could be a long oneOf with every possibilities - additionalProperties: true - description: arguments to the operation (depends on the type of the operation) + # this could be a long oneOf with every possibilities + additionalProperties: true + description: arguments to the operation (depends on the type of the operation) responses: "200": description: OK diff --git a/openapi_spec/paths/indexes/saveObject.yml b/openapi_spec/paths/indexes/saveObject.yml index 0ada4fb698f..d4b95cff9e5 100644 --- a/openapi_spec/paths/indexes/saveObject.yml +++ b/openapi_spec/paths/indexes/saveObject.yml @@ -24,8 +24,10 @@ post: type: object additionalProperties: false properties: + createdAt: + type: string taskID: - type: number + type: integer objectID: type: string "400": diff --git a/openapi_spec/paths/indexes/searchMulti.yml b/openapi_spec/paths/indexes/searchMulti.yml index 7df1638c6eb..ac5a3ba0cc1 100644 --- a/openapi_spec/paths/indexes/searchMulti.yml +++ b/openapi_spec/paths/indexes/searchMulti.yml @@ -11,35 +11,41 @@ post: content: application/json: schema: - type: array - items: - title: multipleQueries - type: object - additionalProperties: false - properties: - indexName: - type: string - example: products - description: The Algolia index name - query: - type: string - description: The query to search for - type: - type: string - enum: [default, facet] - default: default - description: Perform a search query with `default`, will search for facet values if `facet` is given - facet: - type: string - description: The `facet` name - params: + type: object + additionalProperties: false + properties: + requests: + type: array + items: + title: multipleQueries type: object - additionalProperties: true - description: A key-value mapping of additional search parameters - example: - filters: "in_stock:true" - required: - - indexName + additionalProperties: false + properties: + indexName: + type: string + example: products + description: The Algolia index name + query: + type: string + description: The query to search for + type: + type: string + enum: [default, facet] + default: default + description: Perform a search query with `default`, will search for facet values if `facet` is given + facet: + type: string + description: The `facet` name + params: + type: string + description: A query string of search parameters + required: + - indexName + strategy: + type: string + enum: ["none", "stopIfEnoughMatches"] + required: + - requests responses: "200": description: OK From cb2e4996322b349aefa040df4b233f88ab2e5d51 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Tue, 9 Nov 2021 14:47:14 +0100 Subject: [PATCH 6/8] use simple quote and change tags --- openapi_spec/parameters.yml | 10 ++-- openapi_spec/paths/indexes/batch.yml | 32 +++++----- .../{searchMulti.yml => multipleQueries.yml} | 20 +++---- openapi_spec/paths/indexes/saveObject.yml | 16 ++--- openapi_spec/paths/indexes/search.yml | 20 +++---- openapi_spec/responses/BadRequest.yml | 2 +- openapi_spec/responses/IndexNotFound.yml | 2 +- openapi_spec/schemas/Error.yml | 2 +- openapi_spec/schemas/SearchParams.yml | 60 +++++++++---------- openapi_spec/spec.yml | 6 +- openapitools.json | 3 +- 11 files changed, 86 insertions(+), 87 deletions(-) rename openapi_spec/paths/indexes/{searchMulti.yml => multipleQueries.yml} (87%) diff --git a/openapi_spec/parameters.yml b/openapi_spec/parameters.yml index ae77ae2257a..226ccfb473d 100644 --- a/openapi_spec/parameters.yml +++ b/openapi_spec/parameters.yml @@ -5,8 +5,8 @@ AppId: required: true schema: type: string - pattern: "^(?:beta|testing)?[A-Z0-9]{10}$" - example: "DJNVGS47DK" + pattern: '^(?:beta|testing)?[A-Z0-9]{10}$' + example: 'DJNVGS47DK' ApiKey: name: X-Algolia-API-Key in: header @@ -14,8 +14,8 @@ ApiKey: required: true schema: type: string - pattern: "^[a-f0-9]{32}$" - example: "43b15df305339e827f0ac0bdc5ebcaa7" + pattern: '^[a-f0-9]{32}$' + example: '43b15df305339e827f0ac0bdc5ebcaa7' IndexName: name: indexName in: path @@ -23,4 +23,4 @@ IndexName: required: true schema: type: string - example: "myIndexName" + example: 'myIndexName' diff --git a/openapi_spec/paths/indexes/batch.yml b/openapi_spec/paths/indexes/batch.yml index e37aafe8dc6..c0854784d9d 100644 --- a/openapi_spec/paths/indexes/batch.yml +++ b/openapi_spec/paths/indexes/batch.yml @@ -1,12 +1,12 @@ post: tags: - - object + - search operationId: batch summary: Performs multiple write operations in a single API call parameters: - - $ref: "../../parameters.yml#/AppId" - - $ref: "../../parameters.yml#/ApiKey" - - $ref: "../../parameters.yml#/IndexName" + - $ref: '../../parameters.yml#/AppId' + - $ref: '../../parameters.yml#/ApiKey' + - $ref: '../../parameters.yml#/IndexName' requestBody: required: true content: @@ -24,13 +24,13 @@ post: action: type: string enum: - - "addObject" - - "updateObject" - - "partialUpdateObject" - - "partialUpdateObjectNoCreate" - - "deleteObject" - - "delete" - - "clear" + - 'addObject' + - 'updateObject' + - 'partialUpdateObject' + - 'partialUpdateObjectNoCreate' + - 'deleteObject' + - 'delete' + - 'clear' description: type of operation body: type: object @@ -38,7 +38,7 @@ post: additionalProperties: true description: arguments to the operation (depends on the type of the operation) responses: - "200": + '200': description: OK content: application/json: @@ -52,7 +52,7 @@ post: type: array items: type: string - "400": - $ref: "../../responses/BadRequest.yml" - "404": - $ref: "../../responses/IndexNotFound.yml" + '400': + $ref: '../../responses/BadRequest.yml' + '404': + $ref: '../../responses/IndexNotFound.yml' diff --git a/openapi_spec/paths/indexes/searchMulti.yml b/openapi_spec/paths/indexes/multipleQueries.yml similarity index 87% rename from openapi_spec/paths/indexes/searchMulti.yml rename to openapi_spec/paths/indexes/multipleQueries.yml index ac5a3ba0cc1..1dd7675d06d 100644 --- a/openapi_spec/paths/indexes/searchMulti.yml +++ b/openapi_spec/paths/indexes/multipleQueries.yml @@ -1,11 +1,11 @@ post: tags: - search - operationId: searchMulti + operationId: multipleQueries summary: Get search results for the given requests. parameters: - - $ref: "../../parameters.yml#/AppId" - - $ref: "../../parameters.yml#/ApiKey" + - $ref: '../../parameters.yml#/AppId' + - $ref: '../../parameters.yml#/ApiKey' requestBody: required: true content: @@ -43,11 +43,11 @@ post: - indexName strategy: type: string - enum: ["none", "stopIfEnoughMatches"] + enum: ['none', 'stopIfEnoughMatches'] required: - requests responses: - "200": + '200': description: OK content: application/json: @@ -75,9 +75,9 @@ post: type: integer queryID: type: string - pattern: "[a-f0-9]{32}" + pattern: '[a-f0-9]{32}' example: 43b15df305339e827f0ac0bdc5ebcaa7 - "400": - $ref: "../../responses/BadRequest.yml" - "404": - $ref: "../../responses/IndexNotFound.yml" + '400': + $ref: '../../responses/BadRequest.yml' + '404': + $ref: '../../responses/IndexNotFound.yml' diff --git a/openapi_spec/paths/indexes/saveObject.yml b/openapi_spec/paths/indexes/saveObject.yml index d4b95cff9e5..8942065cec2 100644 --- a/openapi_spec/paths/indexes/saveObject.yml +++ b/openapi_spec/paths/indexes/saveObject.yml @@ -5,9 +5,9 @@ post: summary: Save object description: Add an object to the index, automatically assigning it an object ID parameters: - - $ref: "../../parameters.yml#/AppId" - - $ref: "../../parameters.yml#/ApiKey" - - $ref: "../../parameters.yml#/IndexName" + - $ref: '../../parameters.yml#/AppId' + - $ref: '../../parameters.yml#/ApiKey' + - $ref: '../../parameters.yml#/IndexName' requestBody: required: true content: @@ -16,7 +16,7 @@ post: type: object additionalProperties: true responses: - "200": + '200': description: OK content: application/json: @@ -30,7 +30,7 @@ post: type: integer objectID: type: string - "400": - $ref: "../../responses/BadRequest.yml" - "404": - $ref: "../../responses/IndexNotFound.yml" + '400': + $ref: '../../responses/BadRequest.yml' + '404': + $ref: '../../responses/IndexNotFound.yml' diff --git a/openapi_spec/paths/indexes/search.yml b/openapi_spec/paths/indexes/search.yml index 3d43ecb7170..ee44d8af4f0 100644 --- a/openapi_spec/paths/indexes/search.yml +++ b/openapi_spec/paths/indexes/search.yml @@ -4,13 +4,13 @@ post: operationId: search summary: Get search results parameters: - - $ref: "../../parameters.yml#/AppId" - - $ref: "../../parameters.yml#/ApiKey" - - $ref: "../../parameters.yml#/IndexName" + - $ref: '../../parameters.yml#/AppId' + - $ref: '../../parameters.yml#/ApiKey' + - $ref: '../../parameters.yml#/IndexName' requestBody: - $ref: "../../schemas/SearchParams.yml" + $ref: '../../schemas/SearchParams.yml' responses: - "200": + '200': description: OK content: application/json: @@ -32,9 +32,9 @@ post: type: integer queryID: type: string - pattern: "[a-f0-9]{32}" + pattern: '[a-f0-9]{32}' example: 43b15df305339e827f0ac0bdc5ebcaa7 - "400": - $ref: "../../responses/BadRequest.yml" - "404": - $ref: "../../responses/IndexNotFound.yml" + '400': + $ref: '../../responses/BadRequest.yml' + '404': + $ref: '../../responses/IndexNotFound.yml' diff --git a/openapi_spec/responses/BadRequest.yml b/openapi_spec/responses/BadRequest.yml index 112fbe73f58..b811bc1e78f 100644 --- a/openapi_spec/responses/BadRequest.yml +++ b/openapi_spec/responses/BadRequest.yml @@ -2,4 +2,4 @@ description: Bad request or request arguments content: application/json: schema: - $ref: "../schemas/Error.yml" + $ref: '../schemas/Error.yml' diff --git a/openapi_spec/responses/IndexNotFound.yml b/openapi_spec/responses/IndexNotFound.yml index 0ac5e0980f3..73fd650f77a 100644 --- a/openapi_spec/responses/IndexNotFound.yml +++ b/openapi_spec/responses/IndexNotFound.yml @@ -2,4 +2,4 @@ description: Index not found content: application/json: schema: - $ref: "../schemas/Error.yml" + $ref: '../schemas/Error.yml' diff --git a/openapi_spec/schemas/Error.yml b/openapi_spec/schemas/Error.yml index 214c152880b..4f2ed33d164 100644 --- a/openapi_spec/schemas/Error.yml +++ b/openapi_spec/schemas/Error.yml @@ -4,4 +4,4 @@ additionalProperties: true properties: message: type: string - example: "Invalid application id" + example: 'Invalid application id' diff --git a/openapi_spec/schemas/SearchParams.yml b/openapi_spec/schemas/SearchParams.yml index e45a88ed52f..4dfa2cd3450 100644 --- a/openapi_spec/schemas/SearchParams.yml +++ b/openapi_spec/schemas/SearchParams.yml @@ -4,11 +4,11 @@ properties: query: type: string description: The text to search in the index. - default: "" + default: '' similarQuery: type: string - description: Overrides the query parameter and performs a more generic search that can be used to find “similar” results. - default: "" + description: Overrides the query parameter and performs a more generic search that can be used to find "similar" results. + default: '' searchableAttributes: type: array items: @@ -32,7 +32,7 @@ properties: items: type: string description: This parameter controls which attributes to retrieve and which not to retrieve. - default: ["*"] + default: ['*'] restrictSearchableAttributes: type: array items: @@ -45,14 +45,14 @@ properties: type: string description: Controls how Algolia should sort your results. default: - - "typo" - - "geo" - - "words" - - "filters" - - "proximity" - - "attribute" - - "exact" - - "custom" + - 'typo' + - 'geo' + - 'words' + - 'filters' + - 'proximity' + - 'attribute' + - 'exact' + - 'custom' customRanking: type: array items: @@ -72,7 +72,7 @@ properties: filters: type: string description: Filter the query with numeric, facet and/or tag filters. - default: "" + default: '' # There could be a pattern for this one (complicated one) facetFilters: type: array @@ -119,7 +119,7 @@ properties: sortFacetValuesBy: type: string description: Controls how facet values are fetched. - default: "count" + default: 'count' attributesToHighlight: type: array items: @@ -134,15 +134,15 @@ properties: highlightPreTag: type: string description: The HTML string to insert before the highlighted parts in all highlight and snippet results. - default: "" + default: '' highlightPostTag: type: string description: The HTML string to insert after the highlighted parts in all highlight and snippet results. - default: "" + default: '' snippetEllipsisText: type: string description: String used as an ellipsis indicator when a snippet is truncated. - default: "…" + default: '…' restrictHighlightAndSnippetArrays: type: boolean description: Restrict highlighting and snippeting to items that matched the query. @@ -177,7 +177,7 @@ properties: default: 8 typoTolerance: type: string - enum: [true, false, "min", "strict"] + enum: [true, false, 'min', 'strict'] description: Controls whether typo tolerance is enabled and how it is applied. default: true allowTyposOnNumericTokens: @@ -199,7 +199,7 @@ properties: separatorsToIndex: type: string description: Control which separators are indexed. - default: "" + default: '' aroundLatLng: type: string description: Search for entries around a central geolocation, enabling a geo search within a circular area. @@ -259,7 +259,7 @@ properties: keepDiacriticsOnCharacters: type: string description: List of characters that the engine shouldn’t automatically normalize. - default: "" + default: '' customNormalization: type: object additionalProperties: true @@ -314,14 +314,14 @@ properties: description: Associates a certain user token with the current search. queryType: type: string - enum: ["prefixLast", "prefixAll", "prefixNone"] + enum: ['prefixLast', 'prefixAll', 'prefixNone'] description: Controls if and how query words are interpreted as prefixes. - default: "prefixLast" + default: 'prefixLast' removeWordsIfNoResults: type: string - enum: ["none", "lastWords", "firstWords", "allOptional"] + enum: ['none', 'lastWords', 'firstWords', 'allOptional'] description: Selects a strategy to remove words from the query when it doesn’t match any hits. - default: "none" + default: 'none' advancedSyntax: type: boolean description: Enables the advanced query syntax. @@ -346,23 +346,23 @@ properties: default: [] exactOnSingleWordQuery: type: string - enum: ["attribute", "none", "word"] + enum: ['attribute', 'none', 'word'] description: Controls how the exact ranking criterion is computed when the query contains only one word. - default: "attribute" + default: 'attribute' alternativesAsExact: type: array items: type: string - enum: ["ignorePlurals", "singleWordSynonym", "multiWordsSynonym"] + enum: ['ignorePlurals', 'singleWordSynonym', 'multiWordsSynonym'] description: List of alternatives that should be considered an exact match by the exact ranking criterion. - default: ["ignorePlurals", "singleWordSynonym"] + default: ['ignorePlurals', 'singleWordSynonym'] advancedSyntaxFeatures: type: array items: type: string - enum: ["exactPhrase", "excludeWords"] + enum: ['exactPhrase', 'excludeWords'] description: Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is enabled. - default: ["exactPhrase", "excludeWords"] + default: ['exactPhrase', 'excludeWords'] numericAttributesForFiltering: type: array items: diff --git a/openapi_spec/spec.yml b/openapi_spec/spec.yml index dd38e0ac783..c6ac21cebdb 100644 --- a/openapi_spec/spec.yml +++ b/openapi_spec/spec.yml @@ -25,8 +25,8 @@ paths: # /1/indexes/{indexName}/query: # $ref: "./paths/indexes/search.yml" /1/indexes/*/queries: - $ref: "./paths/indexes/searchMulti.yml" + $ref: './paths/indexes/multipleQueries.yml' /1/indexes/{indexName}: - $ref: "./paths/indexes/saveObject.yml" + $ref: './paths/indexes/saveObject.yml' /1/indexes/{indexName}/batch: - $ref: "./paths/indexes/batch.yml" + $ref: './paths/indexes/batch.yml' diff --git a/openapitools.json b/openapitools.json index 57e1cc283ab..fb51cbe9232 100644 --- a/openapitools.json +++ b/openapitools.json @@ -9,10 +9,9 @@ "config": "#{cwd}/openapitools.json", "enablePostProcessFile": true, "httpUserAgent": "Algolia for JavaScript ({packageVersion});", - "apiPackage": "client-search", "output": "#{cwd}/output/", - "glob": "search_spec.yml", + "glob": "openapi_spec/spec.yml", "gitHost": "algolia", "gitUserId": "algolia", "gitRepoId": "algoliasearch-client-javascript", From f2a4845df44ab8e3a54fd29251626857ec7ddb0c Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Tue, 9 Nov 2021 17:59:22 +0100 Subject: [PATCH 7/8] real error --- openapi_spec/schemas/Error.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi_spec/schemas/Error.yml b/openapi_spec/schemas/Error.yml index 4f2ed33d164..f14e514b7fa 100644 --- a/openapi_spec/schemas/Error.yml +++ b/openapi_spec/schemas/Error.yml @@ -4,4 +4,4 @@ additionalProperties: true properties: message: type: string - example: 'Invalid application id' + example: 'Invalid Application-Id or API-Key' From 49662518b99ece9c0671475e52766c09851020d6 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Wed, 10 Nov 2021 12:01:16 +0100 Subject: [PATCH 8/8] create common response file with taskID and objectID --- openapi_spec/paths/indexes/batch.yml | 6 ++---- openapi_spec/paths/indexes/multipleQueries.yml | 7 ++----- openapi_spec/paths/indexes/saveObject.yml | 4 ++-- openapi_spec/paths/indexes/search.yml | 5 ++--- openapi_spec/responses/common.yml | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 openapi_spec/responses/common.yml diff --git a/openapi_spec/paths/indexes/batch.yml b/openapi_spec/paths/indexes/batch.yml index c0854784d9d..2e64b8ecc91 100644 --- a/openapi_spec/paths/indexes/batch.yml +++ b/openapi_spec/paths/indexes/batch.yml @@ -47,11 +47,9 @@ post: additionalProperties: false properties: taskID: - type: integer + $ref: '../../responses/common.yml#/taskID' objectIDs: - type: array - items: - type: string + $ref: '../../responses/common.yml#/objectIDs' '400': $ref: '../../responses/BadRequest.yml' '404': diff --git a/openapi_spec/paths/indexes/multipleQueries.yml b/openapi_spec/paths/indexes/multipleQueries.yml index 1dd7675d06d..743e6c92199 100644 --- a/openapi_spec/paths/indexes/multipleQueries.yml +++ b/openapi_spec/paths/indexes/multipleQueries.yml @@ -69,14 +69,11 @@ post: additionalProperties: false properties: objectID: - type: string - example: objectID1 + $ref: '../../responses/common.yml#/objectID' nbHits: type: integer queryID: - type: string - pattern: '[a-f0-9]{32}' - example: 43b15df305339e827f0ac0bdc5ebcaa7 + $ref: '../../responses/common.yml#/queryID' '400': $ref: '../../responses/BadRequest.yml' '404': diff --git a/openapi_spec/paths/indexes/saveObject.yml b/openapi_spec/paths/indexes/saveObject.yml index 8942065cec2..341f3031a58 100644 --- a/openapi_spec/paths/indexes/saveObject.yml +++ b/openapi_spec/paths/indexes/saveObject.yml @@ -27,9 +27,9 @@ post: createdAt: type: string taskID: - type: integer + $ref: '../../responses/common.yml#/taskID' objectID: - type: string + $ref: '../../responses/common.yml#/objectID' '400': $ref: '../../responses/BadRequest.yml' '404': diff --git a/openapi_spec/paths/indexes/search.yml b/openapi_spec/paths/indexes/search.yml index ee44d8af4f0..28008eb7f6c 100644 --- a/openapi_spec/paths/indexes/search.yml +++ b/openapi_spec/paths/indexes/search.yml @@ -26,13 +26,12 @@ post: additionalProperties: false properties: objectID: - type: string - example: objectID1 + $ref: '../../responses/common.yml#/objectID' nbHits: type: integer queryID: type: string - pattern: '[a-f0-9]{32}' + pattern: '^[a-f0-9]{32}$' example: 43b15df305339e827f0ac0bdc5ebcaa7 '400': $ref: '../../responses/BadRequest.yml' diff --git a/openapi_spec/responses/common.yml b/openapi_spec/responses/common.yml new file mode 100644 index 00000000000..5f32d367655 --- /dev/null +++ b/openapi_spec/responses/common.yml @@ -0,0 +1,15 @@ +taskID: + type: integer + description: taskID of the indexing task to wait for. +objectID: + type: string + description: Unique identifier of the object +objectIDs: + type: array + items: + type: string + description: List of objectID +queryID: + type: string + pattern: '^[a-f0-9]{32}$' + example: 43b15df305339e827f0ac0bdc5ebcaa7