| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System.Collections.Generic; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.Search.Documents.Indexes.Models |
| | 13 | | { |
| | 14 | | public partial class KeyPhraseExtractionSkill : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 4 | 18 | | writer.WriteStartObject(); |
| 4 | 19 | | if (Optional.IsDefined(DefaultLanguageCode)) |
| | 20 | | { |
| 4 | 21 | | writer.WritePropertyName("defaultLanguageCode"); |
| 4 | 22 | | writer.WriteStringValue(DefaultLanguageCode.Value.ToString()); |
| | 23 | | } |
| 4 | 24 | | if (Optional.IsDefined(MaxKeyPhraseCount)) |
| | 25 | | { |
| 0 | 26 | | if (MaxKeyPhraseCount != null) |
| | 27 | | { |
| 0 | 28 | | writer.WritePropertyName("maxKeyPhraseCount"); |
| 0 | 29 | | writer.WriteNumberValue(MaxKeyPhraseCount.Value); |
| | 30 | | } |
| | 31 | | else |
| | 32 | | { |
| 0 | 33 | | writer.WriteNull("maxKeyPhraseCount"); |
| | 34 | | } |
| | 35 | | } |
| 4 | 36 | | writer.WritePropertyName("@odata.type"); |
| 4 | 37 | | writer.WriteStringValue(ODataType); |
| 4 | 38 | | if (Optional.IsDefined(Name)) |
| | 39 | | { |
| 0 | 40 | | writer.WritePropertyName("name"); |
| 0 | 41 | | writer.WriteStringValue(Name); |
| | 42 | | } |
| 4 | 43 | | if (Optional.IsDefined(Description)) |
| | 44 | | { |
| 0 | 45 | | writer.WritePropertyName("description"); |
| 0 | 46 | | writer.WriteStringValue(Description); |
| | 47 | | } |
| 4 | 48 | | if (Optional.IsDefined(Context)) |
| | 49 | | { |
| 4 | 50 | | writer.WritePropertyName("context"); |
| 4 | 51 | | writer.WriteStringValue(Context); |
| | 52 | | } |
| 4 | 53 | | writer.WritePropertyName("inputs"); |
| 4 | 54 | | writer.WriteStartArray(); |
| 24 | 55 | | foreach (var item in Inputs) |
| | 56 | | { |
| 8 | 57 | | writer.WriteObjectValue(item); |
| | 58 | | } |
| 4 | 59 | | writer.WriteEndArray(); |
| 4 | 60 | | writer.WritePropertyName("outputs"); |
| 4 | 61 | | writer.WriteStartArray(); |
| 16 | 62 | | foreach (var item in Outputs) |
| | 63 | | { |
| 4 | 64 | | writer.WriteObjectValue(item); |
| | 65 | | } |
| 4 | 66 | | writer.WriteEndArray(); |
| 4 | 67 | | writer.WriteEndObject(); |
| 4 | 68 | | } |
| | 69 | |
|
| | 70 | | internal static KeyPhraseExtractionSkill DeserializeKeyPhraseExtractionSkill(JsonElement element) |
| | 71 | | { |
| 6 | 72 | | Optional<KeyPhraseExtractionSkillLanguage> defaultLanguageCode = default; |
| 6 | 73 | | Optional<int?> maxKeyPhraseCount = default; |
| 6 | 74 | | string odataType = default; |
| 6 | 75 | | Optional<string> name = default; |
| 6 | 76 | | Optional<string> description = default; |
| 6 | 77 | | Optional<string> context = default; |
| 6 | 78 | | IList<InputFieldMappingEntry> inputs = default; |
| 6 | 79 | | IList<OutputFieldMappingEntry> outputs = default; |
| 108 | 80 | | foreach (var property in element.EnumerateObject()) |
| | 81 | | { |
| 48 | 82 | | if (property.NameEquals("defaultLanguageCode")) |
| | 83 | | { |
| 6 | 84 | | defaultLanguageCode = new KeyPhraseExtractionSkillLanguage(property.Value.GetString()); |
| 6 | 85 | | continue; |
| | 86 | | } |
| 42 | 87 | | if (property.NameEquals("maxKeyPhraseCount")) |
| | 88 | | { |
| 6 | 89 | | if (property.Value.ValueKind == JsonValueKind.Null) |
| | 90 | | { |
| 6 | 91 | | maxKeyPhraseCount = null; |
| 6 | 92 | | continue; |
| | 93 | | } |
| 0 | 94 | | maxKeyPhraseCount = property.Value.GetInt32(); |
| 0 | 95 | | continue; |
| | 96 | | } |
| 36 | 97 | | if (property.NameEquals("@odata.type")) |
| | 98 | | { |
| 6 | 99 | | odataType = property.Value.GetString(); |
| 6 | 100 | | continue; |
| | 101 | | } |
| 30 | 102 | | if (property.NameEquals("name")) |
| | 103 | | { |
| 6 | 104 | | name = property.Value.GetString(); |
| 6 | 105 | | continue; |
| | 106 | | } |
| 24 | 107 | | if (property.NameEquals("description")) |
| | 108 | | { |
| 6 | 109 | | description = property.Value.GetString(); |
| 6 | 110 | | continue; |
| | 111 | | } |
| 18 | 112 | | if (property.NameEquals("context")) |
| | 113 | | { |
| 6 | 114 | | context = property.Value.GetString(); |
| 6 | 115 | | continue; |
| | 116 | | } |
| 12 | 117 | | if (property.NameEquals("inputs")) |
| | 118 | | { |
| 6 | 119 | | List<InputFieldMappingEntry> array = new List<InputFieldMappingEntry>(); |
| 36 | 120 | | foreach (var item in property.Value.EnumerateArray()) |
| | 121 | | { |
| 12 | 122 | | array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); |
| | 123 | | } |
| 6 | 124 | | inputs = array; |
| 6 | 125 | | continue; |
| | 126 | | } |
| 6 | 127 | | if (property.NameEquals("outputs")) |
| | 128 | | { |
| 6 | 129 | | List<OutputFieldMappingEntry> array = new List<OutputFieldMappingEntry>(); |
| 24 | 130 | | foreach (var item in property.Value.EnumerateArray()) |
| | 131 | | { |
| 6 | 132 | | array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); |
| | 133 | | } |
| 6 | 134 | | outputs = array; |
| | 135 | | continue; |
| | 136 | | } |
| | 137 | | } |
| 6 | 138 | | return new KeyPhraseExtractionSkill(odataType, name.Value, description.Value, context.Value, inputs, outputs |
| | 139 | | } |
| | 140 | | } |
| | 141 | | } |