| | 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 OcrSkill : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 0 | 18 | | writer.WriteStartObject(); |
| 0 | 19 | | if (Optional.IsDefined(DefaultLanguageCode)) |
| | 20 | | { |
| 0 | 21 | | writer.WritePropertyName("defaultLanguageCode"); |
| 0 | 22 | | writer.WriteStringValue(DefaultLanguageCode.Value.ToString()); |
| | 23 | | } |
| 0 | 24 | | if (Optional.IsDefined(ShouldDetectOrientation)) |
| | 25 | | { |
| 0 | 26 | | writer.WritePropertyName("detectOrientation"); |
| 0 | 27 | | writer.WriteBooleanValue(ShouldDetectOrientation.Value); |
| | 28 | | } |
| 0 | 29 | | writer.WritePropertyName("@odata.type"); |
| 0 | 30 | | writer.WriteStringValue(ODataType); |
| 0 | 31 | | if (Optional.IsDefined(Name)) |
| | 32 | | { |
| 0 | 33 | | writer.WritePropertyName("name"); |
| 0 | 34 | | writer.WriteStringValue(Name); |
| | 35 | | } |
| 0 | 36 | | if (Optional.IsDefined(Description)) |
| | 37 | | { |
| 0 | 38 | | writer.WritePropertyName("description"); |
| 0 | 39 | | writer.WriteStringValue(Description); |
| | 40 | | } |
| 0 | 41 | | if (Optional.IsDefined(Context)) |
| | 42 | | { |
| 0 | 43 | | writer.WritePropertyName("context"); |
| 0 | 44 | | writer.WriteStringValue(Context); |
| | 45 | | } |
| 0 | 46 | | writer.WritePropertyName("inputs"); |
| 0 | 47 | | writer.WriteStartArray(); |
| 0 | 48 | | foreach (var item in Inputs) |
| | 49 | | { |
| 0 | 50 | | writer.WriteObjectValue(item); |
| | 51 | | } |
| 0 | 52 | | writer.WriteEndArray(); |
| 0 | 53 | | writer.WritePropertyName("outputs"); |
| 0 | 54 | | writer.WriteStartArray(); |
| 0 | 55 | | foreach (var item in Outputs) |
| | 56 | | { |
| 0 | 57 | | writer.WriteObjectValue(item); |
| | 58 | | } |
| 0 | 59 | | writer.WriteEndArray(); |
| 0 | 60 | | writer.WriteEndObject(); |
| 0 | 61 | | } |
| | 62 | |
|
| | 63 | | internal static OcrSkill DeserializeOcrSkill(JsonElement element) |
| | 64 | | { |
| 0 | 65 | | Optional<OcrSkillLanguage> defaultLanguageCode = default; |
| 0 | 66 | | Optional<bool> detectOrientation = default; |
| 0 | 67 | | string odataType = default; |
| 0 | 68 | | Optional<string> name = default; |
| 0 | 69 | | Optional<string> description = default; |
| 0 | 70 | | Optional<string> context = default; |
| 0 | 71 | | IList<InputFieldMappingEntry> inputs = default; |
| 0 | 72 | | IList<OutputFieldMappingEntry> outputs = default; |
| 0 | 73 | | foreach (var property in element.EnumerateObject()) |
| | 74 | | { |
| 0 | 75 | | if (property.NameEquals("defaultLanguageCode")) |
| | 76 | | { |
| 0 | 77 | | defaultLanguageCode = new OcrSkillLanguage(property.Value.GetString()); |
| 0 | 78 | | continue; |
| | 79 | | } |
| 0 | 80 | | if (property.NameEquals("detectOrientation")) |
| | 81 | | { |
| 0 | 82 | | detectOrientation = property.Value.GetBoolean(); |
| 0 | 83 | | continue; |
| | 84 | | } |
| 0 | 85 | | if (property.NameEquals("@odata.type")) |
| | 86 | | { |
| 0 | 87 | | odataType = property.Value.GetString(); |
| 0 | 88 | | continue; |
| | 89 | | } |
| 0 | 90 | | if (property.NameEquals("name")) |
| | 91 | | { |
| 0 | 92 | | name = property.Value.GetString(); |
| 0 | 93 | | continue; |
| | 94 | | } |
| 0 | 95 | | if (property.NameEquals("description")) |
| | 96 | | { |
| 0 | 97 | | description = property.Value.GetString(); |
| 0 | 98 | | continue; |
| | 99 | | } |
| 0 | 100 | | if (property.NameEquals("context")) |
| | 101 | | { |
| 0 | 102 | | context = property.Value.GetString(); |
| 0 | 103 | | continue; |
| | 104 | | } |
| 0 | 105 | | if (property.NameEquals("inputs")) |
| | 106 | | { |
| 0 | 107 | | List<InputFieldMappingEntry> array = new List<InputFieldMappingEntry>(); |
| 0 | 108 | | foreach (var item in property.Value.EnumerateArray()) |
| | 109 | | { |
| 0 | 110 | | array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item)); |
| | 111 | | } |
| 0 | 112 | | inputs = array; |
| 0 | 113 | | continue; |
| | 114 | | } |
| 0 | 115 | | if (property.NameEquals("outputs")) |
| | 116 | | { |
| 0 | 117 | | List<OutputFieldMappingEntry> array = new List<OutputFieldMappingEntry>(); |
| 0 | 118 | | foreach (var item in property.Value.EnumerateArray()) |
| | 119 | | { |
| 0 | 120 | | array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item)); |
| | 121 | | } |
| 0 | 122 | | outputs = array; |
| | 123 | | continue; |
| | 124 | | } |
| | 125 | | } |
| 0 | 126 | | return new OcrSkill(odataType, name.Value, description.Value, context.Value, inputs, outputs, Optional.ToNul |
| | 127 | | } |
| | 128 | | } |
| | 129 | | } |