Skip to content

Commit 42617d9

Browse files
algolia-botkai687millotp
committed
fix(specs): built-in ops accept also int (generated)
algolia/api-clients-automation#3450 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Kai Welke <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent fba53af commit 42617d9

File tree

3 files changed

+75
-5
lines changed

3 files changed

+75
-5
lines changed

src/main/scala/algoliasearch/search/BuiltInOperation.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,8 @@ package algoliasearch.search
3636
import algoliasearch.search.BuiltInOperationType._
3737

3838
/** Update to perform on the attribute.
39-
*
40-
* @param value
41-
* Value that corresponds to the operation, for example an `Increment` or `Decrement` step, or an `Add` or `Remove`
42-
* value.
4339
*/
4440
case class BuiltInOperation(
4541
_operation: BuiltInOperationType,
46-
value: String
42+
value: BuiltInOperationValue
4743
) extends AttributeToUpdateTrait
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/** Search API The Algolia Search API lets you search, configure, and mange your indices and records. ## Client
2+
* libraries Use Algolia's API clients and libraries to reliably integrate Algolia's APIs with your apps. The official
3+
* API clients are covered by Algolia's [Service Level Agreement](https://www.algolia.com/policies/sla/). See:
4+
* [Algolia's ecosystem](https://www.algolia.com/doc/guides/getting-started/how-algolia-works/in-depth/ecosystem/) ##
5+
* Base URLs The base URLs for requests to the Search API are: - `https://{APPLICATION_ID}.algolia.net` -
6+
* `https://{APPLICATION_ID}-dsn.algolia.net`. If your subscription includes a [Distributed Search
7+
* Network](https://dashboard.algolia.com/infra), this ensures that requests are sent to servers closest to users. Both
8+
* URLs provide high availability by distributing requests with load balancing. **All requests must use HTTPS.** ##
9+
* Retry strategy To guarantee a high availability, implement a retry strategy for all API requests using the URLs of
10+
* your servers as fallbacks: - `https://{APPLICATION_ID}-1.algolianet.com` -
11+
* `https://{APPLICATION_ID}-2.algolianet.com` - `https://{APPLICATION_ID}-3.algolianet.com` These URLs use a different
12+
* DNS provider than the primary URLs. You should randomize this list to ensure an even load across the three servers.
13+
* All Algolia API clients implement this retry strategy. ## Authentication To authenticate your API requests, add
14+
* these headers: - `x-algolia-application-id`. Your Algolia application ID. - `x-algolia-api-key`. An API key with the
15+
* necessary permissions to make the request. The required access control list (ACL) to make a request is listed in
16+
* each endpoint's reference. You can find your application ID and API key in the [Algolia
17+
* dashboard](https://dashboard.algolia.com/account). ## Request format Depending on the endpoint, request bodies are
18+
* either JSON objects or arrays of JSON objects, ## Parameters Parameters are passed as query parameters for GET and
19+
* DELETE requests, and in the request body for POST and PUT requests. Query parameters must be
20+
* [URL-encoded](https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding). Non-ASCII characters must be
21+
* UTF-8 encoded. Plus characters (`+`) are interpreted as spaces. Arrays as query parameters must be one of: - A
22+
* comma-separated string: `attributesToRetrieve=title,description` - A URL-encoded JSON array:
23+
* `attributesToRetrieve=%5B%22title%22,%22description%22%D` ## Response status and errors The Search API returns JSON
24+
* responses. Since JSON doesn't guarantee any specific ordering, don't rely on the order of attributes in the API
25+
* response. Successful responses return a `2xx` status. Client errors return a `4xx` status. Server errors are
26+
* indicated by a `5xx` status. Error responses have a `message` property with more information. ## Version The current
27+
* version of the Search API is version 1, as indicated by the `/1/` in each endpoint's URL.
28+
*
29+
* The version of the OpenAPI document: 1.0.0
30+
*
31+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
32+
* https://openapi-generator.tech Do not edit the class manually.
33+
*/
34+
package algoliasearch.search
35+
36+
import org.json4s._
37+
38+
/** BuiltInOperationValue
39+
*/
40+
sealed trait BuiltInOperationValue
41+
42+
object BuiltInOperationValue {
43+
44+
case class StringValue(value: String) extends BuiltInOperationValue
45+
case class IntValue(value: Int) extends BuiltInOperationValue
46+
47+
def apply(value: String): BuiltInOperationValue = {
48+
BuiltInOperationValue.StringValue(value)
49+
}
50+
def apply(value: Int): BuiltInOperationValue = {
51+
BuiltInOperationValue.IntValue(value)
52+
}
53+
}
54+
55+
object BuiltInOperationValueSerializer extends Serializer[BuiltInOperationValue] {
56+
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), BuiltInOperationValue] = {
57+
58+
case (TypeInfo(clazz, _), json) if clazz == classOf[BuiltInOperationValue] =>
59+
json match {
60+
case JString(value) => BuiltInOperationValue.StringValue(value)
61+
case JInt(value) => BuiltInOperationValue.IntValue(value.toInt)
62+
case _ => throw new MappingException("Can't convert " + json + " to BuiltInOperationValue")
63+
}
64+
}
65+
66+
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {
67+
case value: BuiltInOperationValue =>
68+
value match {
69+
case BuiltInOperationValue.StringValue(value) => JString(value)
70+
case BuiltInOperationValue.IntValue(value) => JInt(value)
71+
}
72+
}
73+
}

src/main/scala/algoliasearch/search/JsonSupport.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ object JsonSupport {
7272
AttributeToUpdateSerializer :+
7373
AutomaticFacetFiltersSerializer :+
7474
BrowseParamsSerializer :+
75+
BuiltInOperationValueSerializer :+
7576
ConsequenceQuerySerializer :+
7677
DistinctSerializer :+
7778
FacetFiltersSerializer :+

0 commit comments

Comments
 (0)