|
| 1 | +// <auto-generated> |
| 2 | +/* |
| 3 | + * fruity |
| 4 | + * |
| 5 | + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) |
| 6 | + * |
| 7 | + * The version of the OpenAPI document: 0.0.1 |
| 8 | + * Generated by: https://github.com/openapitools/openapi-generator.git |
| 9 | + */ |
| 10 | + |
| 11 | +using System; |
| 12 | +using System.Collections; |
| 13 | +using System.Collections.Generic; |
| 14 | +using System.Collections.ObjectModel; |
| 15 | +using System.Linq; |
| 16 | +using System.IO; |
| 17 | +using System.Text; |
| 18 | +using System.Text.RegularExpressions; |
| 19 | +using System.Text.Json; |
| 20 | +using System.Text.Json.Serialization; |
| 21 | +using System.ComponentModel.DataAnnotations; |
| 22 | +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; |
| 23 | +using Org.OpenAPITools.Client; |
| 24 | + |
| 25 | +namespace Org.OpenAPITools.Model |
| 26 | +{ |
| 27 | + /// <summary> |
| 28 | + /// Apple |
| 29 | + /// </summary> |
| 30 | + public partial class Apple : IValidatableObject |
| 31 | + { |
| 32 | + /// <summary> |
| 33 | + /// Initializes a new instance of the <see cref="Apple" /> class. |
| 34 | + /// </summary> |
| 35 | + /// <param name="kind">kind</param> |
| 36 | + [JsonConstructor] |
| 37 | + public Apple(Option<string> kind = default) |
| 38 | + { |
| 39 | + KindOption = kind; |
| 40 | + OnCreated(); |
| 41 | + } |
| 42 | + |
| 43 | + partial void OnCreated(); |
| 44 | + |
| 45 | + /// <summary> |
| 46 | + /// Used to track the state of Kind |
| 47 | + /// </summary> |
| 48 | + [JsonIgnore] |
| 49 | + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] |
| 50 | + public Option<string> KindOption { get; private set; } |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// Gets or Sets Kind |
| 54 | + /// </summary> |
| 55 | + [JsonPropertyName("kind")] |
| 56 | + public string Kind { get { return this.KindOption; } set { this.KindOption = new Option<string>(value); } } |
| 57 | + |
| 58 | + /// <summary> |
| 59 | + /// Gets or Sets additional properties |
| 60 | + /// </summary> |
| 61 | + [JsonExtensionData] |
| 62 | + public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>(); |
| 63 | + |
| 64 | + /// <summary> |
| 65 | + /// Returns the string presentation of the object |
| 66 | + /// </summary> |
| 67 | + /// <returns>String presentation of the object</returns> |
| 68 | + public override string ToString() |
| 69 | + { |
| 70 | + StringBuilder sb = new StringBuilder(); |
| 71 | + sb.Append("class Apple {\n"); |
| 72 | + sb.Append(" Kind: ").Append(Kind).Append("\n"); |
| 73 | + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); |
| 74 | + sb.Append("}\n"); |
| 75 | + return sb.ToString(); |
| 76 | + } |
| 77 | + |
| 78 | + /// <summary> |
| 79 | + /// To validate all properties of the instance |
| 80 | + /// </summary> |
| 81 | + /// <param name="validationContext">Validation context</param> |
| 82 | + /// <returns>Validation Result</returns> |
| 83 | + IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext) |
| 84 | + { |
| 85 | + yield break; |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + /// <summary> |
| 90 | + /// A Json converter for type <see cref="Apple" /> |
| 91 | + /// </summary> |
| 92 | + public class AppleJsonConverter : JsonConverter<Apple> |
| 93 | + { |
| 94 | + /// <summary> |
| 95 | + /// Deserializes json to <see cref="Apple" /> |
| 96 | + /// </summary> |
| 97 | + /// <param name="utf8JsonReader"></param> |
| 98 | + /// <param name="typeToConvert"></param> |
| 99 | + /// <param name="jsonSerializerOptions"></param> |
| 100 | + /// <returns></returns> |
| 101 | + /// <exception cref="JsonException"></exception> |
| 102 | + public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) |
| 103 | + { |
| 104 | + int currentDepth = utf8JsonReader.CurrentDepth; |
| 105 | + |
| 106 | + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) |
| 107 | + throw new JsonException(); |
| 108 | + |
| 109 | + JsonTokenType startingTokenType = utf8JsonReader.TokenType; |
| 110 | + |
| 111 | + Option<string> kind = default; |
| 112 | + |
| 113 | + while (utf8JsonReader.Read()) |
| 114 | + { |
| 115 | + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) |
| 116 | + break; |
| 117 | + |
| 118 | + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) |
| 119 | + break; |
| 120 | + |
| 121 | + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) |
| 122 | + { |
| 123 | + string localVarJsonPropertyName = utf8JsonReader.GetString(); |
| 124 | + utf8JsonReader.Read(); |
| 125 | + |
| 126 | + switch (localVarJsonPropertyName) |
| 127 | + { |
| 128 | + case "kind": |
| 129 | + kind = new Option<string>(utf8JsonReader.GetString()); |
| 130 | + break; |
| 131 | + default: |
| 132 | + break; |
| 133 | + } |
| 134 | + } |
| 135 | + } |
| 136 | + |
| 137 | + if (kind.IsSet && kind.Value == null) |
| 138 | + throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple."); |
| 139 | + |
| 140 | + return new Apple(kind); |
| 141 | + } |
| 142 | + |
| 143 | + /// <summary> |
| 144 | + /// Serializes a <see cref="Apple" /> |
| 145 | + /// </summary> |
| 146 | + /// <param name="writer"></param> |
| 147 | + /// <param name="apple"></param> |
| 148 | + /// <param name="jsonSerializerOptions"></param> |
| 149 | + /// <exception cref="NotImplementedException"></exception> |
| 150 | + public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) |
| 151 | + { |
| 152 | + writer.WriteStartObject(); |
| 153 | + |
| 154 | + WriteProperties(writer, apple, jsonSerializerOptions); |
| 155 | + writer.WriteEndObject(); |
| 156 | + } |
| 157 | + |
| 158 | + /// <summary> |
| 159 | + /// Serializes the properties of <see cref="Apple" /> |
| 160 | + /// </summary> |
| 161 | + /// <param name="writer"></param> |
| 162 | + /// <param name="apple"></param> |
| 163 | + /// <param name="jsonSerializerOptions"></param> |
| 164 | + /// <exception cref="NotImplementedException"></exception> |
| 165 | + public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions) |
| 166 | + { |
| 167 | + if (apple.KindOption.IsSet && apple.Kind == null) |
| 168 | + throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple."); |
| 169 | + |
| 170 | + if (apple.KindOption.IsSet) |
| 171 | + writer.WriteString("kind", apple.Kind); |
| 172 | + } |
| 173 | + } |
| 174 | +} |
0 commit comments