Skip to content

Commit dfb2aa7

Browse files
algolia-botkai687millotp
committed
fix(specs): required prop for dictionaryEntry (#3449) (generated) [skip ci]
Co-authored-by: Kai Welke <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 9a2e7a8 commit dfb2aa7

File tree

37 files changed

+94
-297
lines changed

37 files changed

+94
-297
lines changed

clients/algoliasearch-client-csharp/algoliasearch/Models/Search/DictionaryEntry.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ public DictionaryEntry()
4040
/// Initializes a new instance of the DictionaryEntry class.
4141
/// </summary>
4242
/// <param name="objectID">Unique identifier for the dictionary entry. (required).</param>
43-
/// <param name="language">language (required).</param>
44-
public DictionaryEntry(string objectID, SupportedLanguage? language)
43+
public DictionaryEntry(string objectID)
4544
{
4645
ObjectID = objectID ?? throw new ArgumentNullException(nameof(objectID));
47-
Language = language;
4846
AdditionalProperties = new Dictionary<string, object>();
4947
}
5048

clients/algoliasearch-client-dart/packages/client_search/lib/src/model/dictionary_entry.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ final class DictionaryEntry extends DelegatingMap<String, dynamic> {
1313
/// Returns a new [DictionaryEntry] instance.
1414
const DictionaryEntry({
1515
required this.objectID,
16-
required this.language,
16+
this.language,
1717
this.word,
1818
this.words,
1919
this.decomposition,
@@ -26,7 +26,7 @@ final class DictionaryEntry extends DelegatingMap<String, dynamic> {
2626
final String objectID;
2727

2828
@JsonKey(name: r'language')
29-
final SupportedLanguage language;
29+
final SupportedLanguage? language;
3030

3131
/// Matching dictionary word for `stopwords` and `compounds` dictionaries.
3232
@JsonKey(name: r'word')

clients/algoliasearch-client-dart/packages/client_search/lib/src/model/dictionary_entry.g.dart

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/algoliasearch-client-go/algolia/search/model_dictionary_entry.go

+27-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/model/search/DictionaryEntry.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public DictionaryEntry setLanguage(SupportedLanguage language) {
6262
}
6363

6464
/** Get language */
65-
@javax.annotation.Nonnull
65+
@javax.annotation.Nullable
6666
public SupportedLanguage getLanguage() {
6767
return language;
6868
}

clients/algoliasearch-client-javascript/packages/client-search/model/dictionaryEntry.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type DictionaryEntry = Record<string, any> & {
1212
*/
1313
objectID: string;
1414

15-
language: SupportedLanguage;
15+
language?: SupportedLanguage;
1616

1717
/**
1818
* Matching dictionary word for `stopwords` and `compounds` dictionaries.

clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/model/search/DictionaryEntry.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public data class DictionaryEntry(
2323
/** Unique identifier for the dictionary entry. */
2424
val objectID: String,
2525

26-
val language: SupportedLanguage,
26+
val language: SupportedLanguage? = null,
2727

2828
/** Matching dictionary word for `stopwords` and `compounds` dictionaries. */
2929
val word: String? = null,
@@ -43,7 +43,7 @@ internal object DictionaryEntrySerializer : KSerializer<DictionaryEntry> {
4343

4444
override val descriptor: SerialDescriptor = buildClassSerialDescriptor("DictionaryEntry") {
4545
element<String>("objectID")
46-
element<SupportedLanguage>("language")
46+
element<SupportedLanguage>("language", isOptional = true)
4747
element<String>("word", isOptional = true)
4848
element<List<String>>("words", isOptional = true)
4949
element<List<String>>("decomposition", isOptional = true)
@@ -55,7 +55,7 @@ internal object DictionaryEntrySerializer : KSerializer<DictionaryEntry> {
5555
val tree = input.decodeJsonObject()
5656
return DictionaryEntry(
5757
objectID = tree.getValue("objectID").let { input.json.decodeFromJsonElement(it) },
58-
language = tree.getValue("language").let { input.json.decodeFromJsonElement(it) },
58+
language = tree["language"]?.let { input.json.decodeFromJsonElement(it) },
5959
word = tree["word"]?.let { input.json.decodeFromJsonElement(it) },
6060
words = tree["words"]?.let { input.json.decodeFromJsonElement(it) },
6161
decomposition = tree["decomposition"]?.let { input.json.decodeFromJsonElement(it) },
@@ -68,7 +68,7 @@ internal object DictionaryEntrySerializer : KSerializer<DictionaryEntry> {
6868
val output = encoder.asJsonEncoder()
6969
val json = buildJsonObject {
7070
put("objectID", output.json.encodeToJsonElement(value.objectID))
71-
put("language", output.json.encodeToJsonElement(value.language))
71+
value.language?.let { put("language", output.json.encodeToJsonElement(it)) }
7272
value.word?.let { put("word", output.json.encodeToJsonElement(it)) }
7373
value.words?.let { put("words", output.json.encodeToJsonElement(it)) }
7474
value.decomposition?.let { put("decomposition", output.json.encodeToJsonElement(it)) }

clients/algoliasearch-client-php/lib/Model/Search/DictionaryEntry.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ public function listInvalidProperties()
183183
if (!isset($this->container['objectID']) || null === $this->container['objectID']) {
184184
$invalidProperties[] = "'objectID' can't be null";
185185
}
186-
if (!isset($this->container['language']) || null === $this->container['language']) {
187-
$invalidProperties[] = "'language' can't be null";
188-
}
189186

190187
return $invalidProperties;
191188
}
@@ -228,7 +225,7 @@ public function setObjectID($objectID)
228225
/**
229226
* Gets language.
230227
*
231-
* @return SupportedLanguage
228+
* @return null|SupportedLanguage
232229
*/
233230
public function getLanguage()
234231
{
@@ -238,7 +235,7 @@ public function getLanguage()
238235
/**
239236
* Sets language.
240237
*
241-
* @param SupportedLanguage $language language
238+
* @param null|SupportedLanguage $language language
242239
*
243240
* @return self
244241
*/

clients/algoliasearch-client-python/algoliasearch/search/models/dictionary_entry.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DictionaryEntry(BaseModel):
2323
object_id: StrictStr = Field(
2424
description="Unique identifier for the dictionary entry.", alias="objectID"
2525
)
26-
language: SupportedLanguage
26+
language: Optional[SupportedLanguage] = None
2727
word: Optional[StrictStr] = Field(
2828
default=None,
2929
description="Matching dictionary word for `stopwords` and `compounds` dictionaries.",

clients/algoliasearch-client-ruby/lib/algolia/models/search/dictionary_entry.rb

-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ def initialize(attributes = {})
101101

102102
if attributes.key?(:language)
103103
self.language = attributes[:language]
104-
else
105-
self.language = nil
106104
end
107105

108106
if attributes.key?(:word)

clients/algoliasearch-client-scala/src/main/scala/algoliasearch/search/DictionaryEntry.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import org.json4s.{Extraction, Formats, JField, JObject, JValue, Serializer, Typ
5252
*/
5353
case class DictionaryEntry(
5454
objectID: String,
55-
language: SupportedLanguage,
55+
language: Option[SupportedLanguage] = scala.None,
5656
word: Option[String] = scala.None,
5757
words: Option[Seq[String]] = scala.None,
5858
decomposition: Option[Seq[String]] = scala.None,

clients/algoliasearch-client-swift/Sources/Search/Models/DictionaryEntry.swift

+7-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010
public struct DictionaryEntry: Codable, JSONEncodable {
1111
/// Unique identifier for the dictionary entry.
1212
public var objectID: String
13-
public var language: SearchSupportedLanguage
13+
public var language: SearchSupportedLanguage?
1414
/// Matching dictionary word for `stopwords` and `compounds` dictionaries.
1515
public var word: String?
1616
/// Matching words in the `plurals` dictionary including declensions.
@@ -21,7 +21,7 @@ public struct DictionaryEntry: Codable, JSONEncodable {
2121

2222
public init(
2323
objectID: String,
24-
language: SearchSupportedLanguage,
24+
language: SearchSupportedLanguage? = nil,
2525
word: String? = nil,
2626
words: [String]? = nil,
2727
decomposition: [String]? = nil,
@@ -64,10 +64,8 @@ public struct DictionaryEntry: Codable, JSONEncodable {
6464
throw GenericError(description: "Failed to cast")
6565
}
6666
self.objectID = objectID
67-
guard let language = dictionary["language"]?.value as? SearchSupportedLanguage else {
68-
throw GenericError(description: "Failed to cast")
69-
}
70-
self.language = language
67+
self.language = dictionary["language"]?.value as? SearchSupportedLanguage
68+
7169
self.word = dictionary["word"]?.value as? String
7270

7371
self.words = dictionary["words"]?.value as? [String]
@@ -91,7 +89,7 @@ public struct DictionaryEntry: Codable, JSONEncodable {
9189
public func encode(to encoder: Encoder) throws {
9290
var container = encoder.container(keyedBy: CodingKeys.self)
9391
try container.encode(self.objectID, forKey: .objectID)
94-
try container.encode(self.language, forKey: .language)
92+
try container.encodeIfPresent(self.language, forKey: .language)
9593
try container.encodeIfPresent(self.word, forKey: .word)
9694
try container.encodeIfPresent(self.words, forKey: .words)
9795
try container.encodeIfPresent(self.decomposition, forKey: .decomposition)
@@ -106,7 +104,7 @@ public struct DictionaryEntry: Codable, JSONEncodable {
106104
let container = try decoder.container(keyedBy: CodingKeys.self)
107105

108106
self.objectID = try container.decode(String.self, forKey: .objectID)
109-
self.language = try container.decode(SearchSupportedLanguage.self, forKey: .language)
107+
self.language = try container.decodeIfPresent(SearchSupportedLanguage.self, forKey: .language)
110108
self.word = try container.decodeIfPresent(String.self, forKey: .word)
111109
self.words = try container.decodeIfPresent([String].self, forKey: .words)
112110
self.decomposition = try container.decodeIfPresent([String].self, forKey: .decomposition)
@@ -141,7 +139,7 @@ extension DictionaryEntry: Equatable {
141139
extension DictionaryEntry: Hashable {
142140
public func hash(into hasher: inout Hasher) {
143141
hasher.combine(self.objectID.hashValue)
144-
hasher.combine(self.language.hashValue)
142+
hasher.combine(self.language?.hashValue)
145143
hasher.combine(self.word?.hashValue)
146144
hasher.combine(self.words?.hashValue)
147145
hasher.combine(self.decomposition?.hashValue)

snippets/csharp/src/Search.cs

+1-9
Original file line numberDiff line numberDiff line change
@@ -381,15 +381,7 @@ public async Task SnippetForSearchClientBatchDictionaryEntries1()
381381
new BatchDictionaryEntriesRequest
382382
{
383383
Action = Enum.Parse<DictionaryAction>("DeleteEntry"),
384-
Body = new DictionaryEntry
385-
{
386-
ObjectID = "1",
387-
Language = Enum.Parse<SupportedLanguage>("En"),
388-
Word = "fancy",
389-
Words = new List<string> { "believe", "algolia" },
390-
Decomposition = new List<string> { "trust", "algolia" },
391-
State = Enum.Parse<DictionaryEntryState>("Enabled"),
392-
},
384+
Body = new DictionaryEntry { ObjectID = "1", },
393385
}
394386
},
395387
}

snippets/dart/lib/search.dart

-11
Original file line numberDiff line numberDiff line change
@@ -342,17 +342,6 @@ void snippetForbatchDictionaryEntries1() async {
342342
action: DictionaryAction.fromJson("deleteEntry"),
343343
body: DictionaryEntry(
344344
objectID: "1",
345-
language: SupportedLanguage.fromJson("en"),
346-
word: "fancy",
347-
words: [
348-
"believe",
349-
"algolia",
350-
],
351-
decomposition: [
352-
"trust",
353-
"algolia",
354-
],
355-
state: DictionaryEntryState.fromJson("enabled"),
356345
),
357346
),
358347
],

snippets/go/src/search.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)