-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathFile.liquid
154 lines (126 loc) · 5.21 KB
/
File.liquid
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
//----------------------
// <auto-generated>
// Generated using the NSwag toolchain v{{ ToolchainVersion }} (http://NSwag.org)
// </auto-generated>
//----------------------
{% for usage in NamespaceUsages -%}
using {{ usage }};
{% endfor -%}
namespace {{ Namespace }}
{
#pragma warning disable // Disable all warnings
{{ Clients | tab }}
{% if GenerateContracts -%}
{{ Classes | tab }}
{% if RequiresFileParameterType -%}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")]
public partial class FileParameter
{
public FileParameter(System.IO.Stream data)
: this (data, null)
{
}
public FileParameter(System.IO.Stream data, string fileName)
{
Data = data;
FileName = fileName;
}
public System.IO.Stream Data { get; private set; }
public string FileName { get; private set; }
}
{% endif -%}
{% if GenerateFileResponseClass -%}
public partial class FileResponse : System.IDisposable
{
private System.IDisposable _client;
private System.IDisposable _response;
public string StatusCode { get; private set; }
public System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> Headers { get; private set; }
public System.IO.Stream Stream { get; private set; }
public bool IsPartial
{
get { return StatusCode == "206"; }
}
public FileResponse(string statusCode, System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.IO.Stream stream, System.IDisposable client, System.IDisposable response)
{
StatusCode = statusCode;
Headers = headers;
Stream = stream;
_client = client;
_response = response;
}
public void Dispose()
{
if (Stream != null)
Stream.Dispose();
if (_response != null)
_response.Dispose();
if (_client != null)
_client.Dispose();
}
}
{% endif -%}
{% if WrapResponses and GenerateResponseClasses -%}
{% for responseClassName in ResponseClassNames -%}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")]
public partial class {{ responseClassName }}
{
public string StatusCode { get; private set; }
public System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> Headers { get; private set; }
public {{ responseClassName }}(string statusCode, System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> headers)
{
StatusCode = statusCode;
Headers = headers;
}
}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")]
public partial class {{ responseClassName }}<TResult> : {{ responseClassName }}
{
public TResult Result { get; private set; }
public {{ responseClassName }}(string statusCode, System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> headers, TResult result)
: base(statusCode, headers)
{
Result = result;
}
}
{% endfor %}
{% endif -%}
{% if GenerateExceptionClasses -%}
{% for exceptionClassName in ExceptionClassNames -%}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")]
public partial class {{ exceptionClassName }} : System.Exception
{
public string StatusCode { get; private set; }
public string Response { get; private set; }
public System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> Headers { get; private set; }
public {{ exceptionClassName }}(string message, string statusCode, string response, System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.Exception innerException)
: base(message, innerException)
{
StatusCode = statusCode;
Response = response;
Headers = headers;
}
public override string ToString()
{
return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString());
}
}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")]
public partial class {{ exceptionClassName }}<TResult> : {{ exceptionClassName }}
{
public TResult Result { get; private set; }
public {{ exceptionClassName }}(string message, string statusCode, string response, System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>> headers, TResult result, System.Exception innerException)
: base(message, statusCode, response, headers, innerException)
{
Result = result;
}
}
{% endfor -%}
{% endif -%}
{% endif -%}
{% if GenerateImplementation -%}
{% if RequiresJsonExceptionConverter -%}
{% template JsonExceptionConverter %}
{% endif -%}
{% endif -%}
}