-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCustomFile.cs
More file actions
180 lines (157 loc) · 6.28 KB
/
CustomFile.cs
File metadata and controls
180 lines (157 loc) · 6.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// <auto-generated>
/*
* DocSpring API
*
* Use DocSpring's API to programmatically fill out PDF forms, convert HTML to PDFs, merge PDFs, or request legally binding e-signatures.
*
* The version of the OpenAPI document: v1
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.ComponentModel.DataAnnotations;
using DocSpring.Client.Client;
namespace DocSpring.Client.Model
{
/// <summary>
/// CustomFile
/// </summary>
public partial class CustomFile : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="CustomFile" /> class.
/// </summary>
/// <param name="id">id</param>
/// <param name="url">url</param>
[JsonConstructor]
public CustomFile(string id = default, string url = default)
{
this.id = id;
this.url = url;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Gets or Sets id
/// </summary>
[JsonPropertyName("id")]
public string id { get; set; }
/// <summary>
/// Gets or Sets url
/// </summary>
[JsonPropertyName("url")]
public string url { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("class CustomFile {\n");
sb.Append(" id: ").Append(id).Append("\n");
sb.Append(" url: ").Append(url).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="CustomFile" />
/// </summary>
public class CustomFileJsonConverter : JsonConverter<CustomFile>
{
/// <summary>
/// Deserializes json to <see cref="CustomFile" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
public override CustomFile Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
{
int currentDepth = utf8JsonReader.CurrentDepth;
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
throw new JsonException();
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
Option<string> id = default;
Option<string> url = default;
while (utf8JsonReader.Read())
{
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
break;
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
{
string localVarJsonPropertyName = utf8JsonReader.GetString();
utf8JsonReader.Read();
switch (localVarJsonPropertyName)
{
case "id":
id = new Option<string>(utf8JsonReader.GetString());
break;
case "url":
url = new Option<string>(utf8JsonReader.GetString());
break;
default:
break;
}
}
}
if (!id.IsSet)
throw new ArgumentException("Property is required for class CustomFile.", nameof(id));
if (!url.IsSet)
throw new ArgumentException("Property is required for class CustomFile.", nameof(url));
return new CustomFile(id.Value, url.Value);
}
/// <summary>
/// Serializes a <see cref="CustomFile" />
/// </summary>
/// <param name="writer"></param>
/// <param name="customFile"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, CustomFile customFile, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, customFile, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="CustomFile" />
/// </summary>
/// <param name="writer"></param>
/// <param name="customFile"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(Utf8JsonWriter writer, CustomFile customFile, JsonSerializerOptions jsonSerializerOptions)
{
if (customFile.id != null)
writer.WriteString("id", customFile.id);
else
writer.WriteNull("id");
if (customFile.url != null)
writer.WriteString("url", customFile.url);
else
writer.WriteNull("url");
}
}
}