@autorest/powershell 4.0.0-dev.6 → 4.0.0-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +42 -33
- package/.rush/temp/shrinkwrap-deps.json +2 -2
- package/autorest-configuration-for-sdk.md +14 -2
- package/autorest-configuration.md +1 -0
- package/dist/cmdlets/class.d.ts.map +1 -1
- package/dist/cmdlets/class.js +42 -6
- package/dist/cmdlets/class.js.map +1 -1
- package/dist/internal/powershell-declarations.d.ts +1 -0
- package/dist/internal/powershell-declarations.d.ts.map +1 -1
- package/dist/internal/powershell-declarations.js +2 -1
- package/dist/internal/powershell-declarations.js.map +1 -1
- package/dist/internal/project.d.ts +1 -0
- package/dist/internal/project.d.ts.map +1 -1
- package/dist/internal/project.js +27 -12
- package/dist/internal/project.js.map +1 -1
- package/dist/llcsharp/code-model.d.ts +1 -0
- package/dist/llcsharp/code-model.d.ts.map +1 -1
- package/dist/llcsharp/operation/method.js +2 -1
- package/dist/llcsharp/operation/method.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +4 -0
- package/dist/main.js.map +1 -1
- package/dist/plugins/plugin-create-inline-properties.js +1 -1
- package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
- package/dist/plugins/powershell-v2.d.ts.map +1 -1
- package/dist/plugins/powershell-v2.js +5 -10
- package/dist/plugins/powershell-v2.js.map +1 -1
- package/dist/plugins/sdk-create-inline-properties.d.ts +4 -0
- package/dist/plugins/sdk-create-inline-properties.d.ts.map +1 -0
- package/dist/plugins/sdk-create-inline-properties.js +526 -0
- package/dist/plugins/sdk-create-inline-properties.js.map +1 -0
- package/dist/plugins/sdk-cs-namer.d.ts.map +1 -1
- package/dist/plugins/sdk-cs-namer.js +178 -14
- package/dist/plugins/sdk-cs-namer.js.map +1 -1
- package/dist/plugins/sdk-cs-simplifier.d.ts +3 -0
- package/dist/plugins/sdk-cs-simplifier.d.ts.map +1 -0
- package/dist/plugins/sdk-cs-simplifier.js +154 -0
- package/dist/plugins/sdk-cs-simplifier.js.map +1 -0
- package/dist/plugins/sdk-generate.d.ts.map +1 -1
- package/dist/plugins/sdk-generate.js +49 -3
- package/dist/plugins/sdk-generate.js.map +1 -1
- package/dist/plugins/sdk-tweak-model.d.ts.map +1 -1
- package/dist/plugins/sdk-tweak-model.js +188 -37
- package/dist/plugins/sdk-tweak-model.js.map +1 -1
- package/dist/sdk/project.d.ts +1 -0
- package/dist/sdk/project.d.ts.map +1 -1
- package/dist/sdk/project.js +11 -0
- package/dist/sdk/project.js.map +1 -1
- package/dist/sdk/utility.d.ts +27 -0
- package/dist/sdk/utility.d.ts.map +1 -1
- package/dist/sdk/utility.js +402 -5
- package/dist/sdk/utility.js.map +1 -1
- package/dist/utils/SdkModel.d.ts.map +1 -1
- package/dist/utils/SdkModel.js.map +1 -1
- package/dist/utils/TrieNode.d.ts +10 -0
- package/dist/utils/TrieNode.d.ts.map +1 -0
- package/dist/utils/TrieNode.js +45 -0
- package/dist/utils/TrieNode.js.map +1 -0
- package/dist/utils/WrapComments.d.ts +2 -0
- package/dist/utils/WrapComments.d.ts.map +1 -0
- package/dist/utils/WrapComments.js +46 -0
- package/dist/utils/WrapComments.js.map +1 -0
- package/dist/utils/code-namer.d.ts +3 -0
- package/dist/utils/code-namer.d.ts.map +1 -0
- package/dist/utils/code-namer.js +38 -0
- package/dist/utils/code-namer.js.map +1 -0
- package/dist/utils/schema.d.ts +4 -0
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +28 -1
- package/dist/utils/schema.js.map +1 -1
- package/package.json +1 -1
- package/resources/assets/build-module.ps1 +9 -1
- package/resources/assets/generate-portal-ux.ps1 +379 -0
- package/resources/psruntime/BuildTime/PsAttributes.cs +7 -0
- package/resources/templates/azureMethod.ejs +3 -2
- package/resources/templates/azureMethodGroup.ejs +2 -1
- package/resources/templates/azureServiceClient.ejs +13 -4
- package/resources/templates/enum.ejs +73 -0
- package/resources/templates/exception.ejs +52 -0
- package/resources/templates/extensionMethod.ejs +22 -11
- package/resources/templates/extensions.ejs +4 -4
- package/resources/templates/longRunningOperationMethod.ejs +43 -0
- package/resources/templates/method.ejs +21 -2
- package/resources/templates/methodBodyRestCall.ejs +154 -20
- package/resources/templates/methodGroupInterface.ejs +28 -4
- package/resources/templates/model.ejs +133 -20
- package/resources/templates/page.ejs +40 -0
- package/resources/templates/serviceClientBody.ejs +12 -14
- package/resources/templates/serviceClientInterface.ejs +4 -3
- package/resources/templates/methodGroup.ejs +0 -7
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<%- project.commentHeader %>
|
|
2
|
+
|
|
3
|
+
namespace <%- project.namespace %>.Models
|
|
4
|
+
{
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Defines values for <%-model.language.default.name%>.
|
|
8
|
+
/// </summary>
|
|
9
|
+
<%#ToDo need to figure out when !Model.OldModelAsString is applied%>
|
|
10
|
+
<%#ToDo GetObsoleteAttribute%>
|
|
11
|
+
<% if (!model.extensions['x-ms-model-as-string']) { -%>
|
|
12
|
+
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
|
13
|
+
public enum <%-model.language.default.name%>
|
|
14
|
+
{
|
|
15
|
+
<% var last = model.choices[model.choices.length - 1]-%>
|
|
16
|
+
<% model.choices.forEach(function(item) {
|
|
17
|
+
if (item.language.default.description) {
|
|
18
|
+
-%>
|
|
19
|
+
/// <summary>
|
|
20
|
+
/// <%-item.language.default.description%>
|
|
21
|
+
/// </summary>
|
|
22
|
+
<% } -%>
|
|
23
|
+
[System.Runtime.Serialization.EnumMember(Value = "<%-item.value%>")]
|
|
24
|
+
<% if (item == last) {-%>
|
|
25
|
+
<%-item.language.default.name.replace(/\//g, '-')%>
|
|
26
|
+
<% } else {-%>
|
|
27
|
+
<%-item.language.default.name.replace(/\//g, '-')%>,
|
|
28
|
+
<% }-%>
|
|
29
|
+
<% });-%>
|
|
30
|
+
}
|
|
31
|
+
internal static class <%-model.language.default.name%>EnumExtension
|
|
32
|
+
{
|
|
33
|
+
internal static string ToSerializedValue(this <%-model.language.default.name%>? value)
|
|
34
|
+
{
|
|
35
|
+
return value == null ? null : ((<%-model.language.default.name%>)value).ToSerializedValue();
|
|
36
|
+
}
|
|
37
|
+
internal static string ToSerializedValue(this <%-model.language.default.name%> value)
|
|
38
|
+
{
|
|
39
|
+
switch( value )
|
|
40
|
+
{
|
|
41
|
+
<% for (var i = 0; i < model.choices.length; i++) {-%>
|
|
42
|
+
case <%-model.language.default.name%>.<%-model.choices[i].language.default.name.replace(/\//g, '-')%>:
|
|
43
|
+
return "<%-model.choices[i].value%>";
|
|
44
|
+
<% }-%>
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
internal static <%-model.language.default.name%>? Parse<%-model.language.default.name%>(this string value)
|
|
49
|
+
{
|
|
50
|
+
switch( value )
|
|
51
|
+
{
|
|
52
|
+
<% for (var i = 0; i < model.choices.length; i++) {-%>
|
|
53
|
+
case "<%-model.choices[i].value%>":
|
|
54
|
+
return <%-model.language.default.name%>.<%-model.choices[i].language.default.name.replace(/\//g, '-')%>;
|
|
55
|
+
<% }-%>
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
<%} else {-%>
|
|
61
|
+
public static class <%-model.language.default.name%>
|
|
62
|
+
{
|
|
63
|
+
<%model.choices.forEach(function(choice){-%>
|
|
64
|
+
<%if(choice.language.default.description){-%>
|
|
65
|
+
/// <summary>
|
|
66
|
+
/// <%-choice.language.default.description%>
|
|
67
|
+
/// </summary>
|
|
68
|
+
<%}-%>
|
|
69
|
+
public const string <%-choice.language.default.name%> = "<%-choice.value%>";
|
|
70
|
+
<%});-%>
|
|
71
|
+
}
|
|
72
|
+
<% } -%>
|
|
73
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<%- project.commentHeader %>
|
|
2
|
+
|
|
3
|
+
namespace <%- project.namespace %>.Models
|
|
4
|
+
{
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Exception thrown for an invalid response with <%-exception.schema.language.default.name%> information.
|
|
8
|
+
/// </summary>
|
|
9
|
+
public partial class <%-exception.schema.language.default.name%>Exception : Microsoft.Rest.RestException
|
|
10
|
+
{
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// Gets information about the associated HTTP request.
|
|
13
|
+
/// </summary>
|
|
14
|
+
public Microsoft.Rest.HttpRequestMessageWrapper Request { get; set; }
|
|
15
|
+
|
|
16
|
+
/// <summary>
|
|
17
|
+
/// Gets information about the associated HTTP response.
|
|
18
|
+
/// </summary>
|
|
19
|
+
public Microsoft.Rest.HttpResponseMessageWrapper Response { get; set; }
|
|
20
|
+
|
|
21
|
+
/// <summary>
|
|
22
|
+
/// Gets or sets the body object.
|
|
23
|
+
/// </summary>
|
|
24
|
+
public <%-exception.schema.language.default.name%> Body { get; set; }
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
/// Initializes a new instance of the <%-exception.schema.language.default.name%>Exception class.
|
|
28
|
+
/// </summary>
|
|
29
|
+
public <%-exception.schema.language.default.name%>Exception()
|
|
30
|
+
{
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
/// Initializes a new instance of the <%-exception.schema.language.default.name%> class.
|
|
35
|
+
/// </summary>
|
|
36
|
+
/// <param name="message">The exception message.</param>
|
|
37
|
+
public <%-exception.schema.language.default.name%>Exception(string message)
|
|
38
|
+
: this(message, null)
|
|
39
|
+
{
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
/// Initializes a new instance of the <%-exception.schema.language.default.name%> class.
|
|
44
|
+
/// </summary>
|
|
45
|
+
/// <param name="message">The exception message.</param>
|
|
46
|
+
/// <param name="innerException">Inner exception.</param>
|
|
47
|
+
public <%-exception.schema.language.default.name%>Exception(string message, System.Exception innerException)
|
|
48
|
+
: base(message, innerException)
|
|
49
|
+
{
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<% var key = methodGroup.$key == 'Operations' ? '' : methodGroup.$key-%>
|
|
1
2
|
<%# ToDo: currently assume the SyncMethodsGenerationMode is Essential type, and need to add support for other types -%>
|
|
2
3
|
/// <summary>
|
|
3
4
|
/// <%=method.language.default.description%>
|
|
@@ -7,20 +8,25 @@
|
|
|
7
8
|
/// <param name='operations'>
|
|
8
9
|
/// The operations group for this extension method.
|
|
9
10
|
/// </param>
|
|
10
|
-
<%
|
|
11
|
-
/// <param name='<%-parameter.language.default.
|
|
11
|
+
<% if(method.parameters && !method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function (parameter) {-%>
|
|
12
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
12
13
|
/// <%=parameter.language.default.description%>
|
|
13
14
|
/// </param>
|
|
14
15
|
<% });}-%>
|
|
16
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
17
|
+
/// <param name='nextPageLink'>
|
|
18
|
+
/// The NextLink from the previous successful call to List operation.
|
|
19
|
+
/// </param>
|
|
20
|
+
<% } -%>
|
|
15
21
|
<%# ToDo: add support for GetObsoleteAttribute-%>
|
|
16
22
|
<%# ToDo: add support for AccessModifier, assume public for the time being-%>
|
|
17
|
-
public static <%-method.language.default.returnType%> <%-method.language.default.name%>(this I<%-
|
|
23
|
+
public static <%-method.language.default.returnType%> <%-method.language.default.name%>(this I<%-project.helper.PascalCase(key)%>Operations operations<%- method.language.default.syncMethodParameterDeclaration ? ', ' + method.language.default.syncMethodParameterDeclaration: '' %>)
|
|
18
24
|
{
|
|
19
25
|
<%# ToDo: need to handle different return type, body, header and the others including no return type-%>
|
|
20
26
|
<% if(method.language.default.returnType != 'void') {-%>
|
|
21
|
-
return ((I<%-
|
|
27
|
+
return ((I<%-project.helper.PascalCase(key)%>Operations)operations).<%-method.language.default.name%>Async(<%-method.language.default.syncMethodInvocationArgs%>).GetAwaiter().GetResult();
|
|
22
28
|
<% } else { -%>
|
|
23
|
-
((I<%-
|
|
29
|
+
((I<%-project.helper.PascalCase(key)%>Operations)operations).<%-method.language.default.name%>Async(<%-method.language.default.syncMethodInvocationArgs%>).GetAwaiter().GetResult();
|
|
24
30
|
<% } -%>
|
|
25
31
|
}
|
|
26
32
|
|
|
@@ -32,26 +38,31 @@
|
|
|
32
38
|
/// <param name='operations'>
|
|
33
39
|
/// The operations group for this extension method.
|
|
34
40
|
/// </param>
|
|
35
|
-
<%
|
|
36
|
-
/// <param name='<%-parameter.language.default.
|
|
41
|
+
<% if(method.parameters && !method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function (parameter) {-%>
|
|
42
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
37
43
|
/// <%=parameter.language.default.description%>
|
|
38
44
|
/// </param>
|
|
39
45
|
<% });}-%>
|
|
46
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
47
|
+
/// <param name='nextPageLink'>
|
|
48
|
+
/// The NextLink from the previous successful call to List operation.
|
|
49
|
+
/// </param>
|
|
50
|
+
<% } -%>
|
|
40
51
|
/// <param name='cancellationToken'>
|
|
41
52
|
/// The cancellation token.
|
|
42
53
|
/// </param>
|
|
43
54
|
<%# ToDo: add support for GetObsoleteAttribute-%>
|
|
44
55
|
<%# ToDo: add support for AccessModifier, assume public for the time being-%>
|
|
45
|
-
public static async System.Threading.Tasks.Task<%- method.language.default.returnType != 'void' ? '<' +
|
|
56
|
+
public static async System.Threading.Tasks.Task<%- method.language.default.returnType != 'void' ? '<' + method.language.default.returnType + '>' : ''%> <%-method.language.default.name%>Async(this I<%-project.helper.PascalCase(key)%>Operations operations<%- method.language.default.asyncMethodParameterDeclaration ? ', ' + method.language.default.asyncMethodParameterDeclaration: '' %>)
|
|
46
57
|
{
|
|
47
58
|
<%# ToDo: need to handle different return type, body, header and the others including no return type-%>
|
|
48
59
|
<% if(method.language.default.returnType != 'void') {-%>
|
|
49
60
|
<%# ToDo: add support for primitive return-%>
|
|
50
|
-
using (var _result = await operations.<%-method.language.default.name%>WithHttpMessagesAsync(
|
|
61
|
+
using (var _result = await operations.<%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodInvocationArgs%>).ConfigureAwait(false))
|
|
51
62
|
{
|
|
52
|
-
return _result.Body
|
|
63
|
+
return <%- method.language.default.responseType.startsWith('Microsoft.Rest.Azure.AzureOperationResponse') ? '_result.Body' : '_result.Headers'%>;
|
|
53
64
|
}
|
|
54
65
|
<% } else { -%>
|
|
55
|
-
(await operations.<%-method.language.default.name%>WithHttpMessagesAsync(
|
|
66
|
+
(await operations.<%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodInvocationArgs%>).ConfigureAwait(false)).Dispose();
|
|
56
67
|
<% }-%>
|
|
57
68
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%- project.commentHeader %>
|
|
2
|
-
|
|
2
|
+
<% var key = methodGroup.$key == 'Operations' ? '' : methodGroup.$key-%>
|
|
3
3
|
namespace <%- project.namespace %>
|
|
4
4
|
{
|
|
5
5
|
<% project.model.usings.forEach(function(using){ -%>
|
|
@@ -7,13 +7,13 @@ namespace <%- project.namespace %>
|
|
|
7
7
|
<% }); -%>
|
|
8
8
|
|
|
9
9
|
/// <summary>
|
|
10
|
-
/// Extension methods for <%-
|
|
10
|
+
/// Extension methods for <%- project.helper.PascalCase(key) %>Operations
|
|
11
11
|
/// </summary>
|
|
12
|
-
public static partial class <%-
|
|
12
|
+
public static partial class <%- project.helper.PascalCase(key) %>OperationsExtensions
|
|
13
13
|
{
|
|
14
14
|
<% methodGroup.operations.forEach(function(method){ -%>
|
|
15
15
|
<%# ToDo: add support for ExcludeFromInterface-%>
|
|
16
|
-
<%- include('extensionMethod', {method: method, group: methodGroup}) %>
|
|
16
|
+
<%- include('extensionMethod', {method: method, group: methodGroup, project: project}) %>
|
|
17
17
|
<% }); -%>
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<% if (method.language.default.description) {-%>
|
|
2
|
+
/// <summary>
|
|
3
|
+
/// <%= method.language.default.description%>
|
|
4
|
+
<%# ToDo: add externaldocsurl -%>
|
|
5
|
+
/// </summary>
|
|
6
|
+
<% };-%>
|
|
7
|
+
<%# ToDo: add remark if both description and summary is provided, question here is in m4, there is no summary provided-%>
|
|
8
|
+
<% if(method.parameters&&!method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function (parameter) {-%>
|
|
9
|
+
<%# ToDo: should use camel name instead of pascal name here -%>
|
|
10
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
11
|
+
/// <%=parameter.language.default.description%>
|
|
12
|
+
/// </param>
|
|
13
|
+
<% });}-%>
|
|
14
|
+
<% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body' && !project.helper.IsConstantParameter(p)).forEach(function(parameter){-%>
|
|
15
|
+
<%if(parameter.extensions && parameter.extensions['x-ms-client-flatten'] ) {-%>
|
|
16
|
+
<%project.helper.GetAllPublicVirtualProperties(parameter.schema.language.default.virtualProperties).filter(p => !project.helper.IsConstantProperty(p)).forEach(function(vp) {-%>
|
|
17
|
+
/// <param name='<%-vp.property.language.default.name%>'>
|
|
18
|
+
/// <%= vp.property.language.default.description%>
|
|
19
|
+
/// </param>
|
|
20
|
+
<%});-%>
|
|
21
|
+
<%} else {-%>
|
|
22
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
23
|
+
/// <%= parameter.language.default.description%>
|
|
24
|
+
/// </param>
|
|
25
|
+
<%}-%>
|
|
26
|
+
<% });-%>
|
|
27
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
28
|
+
/// <param name='nextPageLink'>
|
|
29
|
+
/// The NextLink from the previous successful call to List operation.
|
|
30
|
+
/// </param>
|
|
31
|
+
<% } -%>
|
|
32
|
+
/// <param name='customHeaders'>
|
|
33
|
+
/// Headers that will be added to request.
|
|
34
|
+
/// </param>
|
|
35
|
+
/// <param name='cancellationToken'>
|
|
36
|
+
/// The cancellation token.
|
|
37
|
+
/// </param>
|
|
38
|
+
public async System.Threading.Tasks.Task<<%-method.language.default.responseType%>> <%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodParameterDeclarationWithCustomHeader%>)
|
|
39
|
+
{
|
|
40
|
+
// Send Request
|
|
41
|
+
<%-method.language.default.responseType%> _response = await Begin<%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodInvocationArgsWithCustomerHeaders%>).ConfigureAwait(false);
|
|
42
|
+
return await this.Client.<%-(method.requests[0].protocol.http.method == 'put' || method.requests[0].protocol.http.method == 'patch')?'GetPutOrPatch':(method.requests[0].protocol.http.method == 'post' || method.requests[0].protocol.http.method == 'delete')?'GetPostOrDelete':''%>OperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false);
|
|
43
|
+
}
|
|
@@ -5,12 +5,30 @@
|
|
|
5
5
|
/// </summary>
|
|
6
6
|
<% };-%>
|
|
7
7
|
<%# ToDo: add remark if both description and summary is provided, question here is in m4, there is no summary provided-%>
|
|
8
|
-
<% if(method.parameters) { method.parameters.filter(p => p.implementation != 'Client').forEach(function (parameter) {-%>
|
|
8
|
+
<% if(method.parameters&&!method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function (parameter) {-%>
|
|
9
9
|
<%# ToDo: should use camel name instead of pascal name here -%>
|
|
10
10
|
/// <param name='<%-parameter.language.default.name%>'>
|
|
11
11
|
/// <%=parameter.language.default.description%>
|
|
12
12
|
/// </param>
|
|
13
13
|
<% });}-%>
|
|
14
|
+
<% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body' && !project.helper.IsConstantParameter(p)).forEach(function(parameter){-%>
|
|
15
|
+
<%if(parameter.extensions && parameter.extensions['x-ms-client-flatten'] ) {-%>
|
|
16
|
+
<%project.helper.GetAllPublicVirtualProperties(parameter.schema.language.default.virtualProperties).filter(p => !project.helper.IsConstantProperty(p)).forEach(function(vp) {-%>
|
|
17
|
+
/// <param name='<%-vp.property.language.default.name%>'>
|
|
18
|
+
/// <%= vp.property.language.default.description%>
|
|
19
|
+
/// </param>
|
|
20
|
+
<%});-%>
|
|
21
|
+
<%} else {-%>
|
|
22
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
23
|
+
/// <%= parameter.language.default.description%>
|
|
24
|
+
/// </param>
|
|
25
|
+
<%}-%>
|
|
26
|
+
<% });-%>
|
|
27
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
28
|
+
/// <param name='nextPageLink'>
|
|
29
|
+
/// The NextLink from the previous successful call to List operation.
|
|
30
|
+
/// </param>
|
|
31
|
+
<% } -%>
|
|
14
32
|
/// <param name='customHeaders'>
|
|
15
33
|
/// Headers that will be added to request.
|
|
16
34
|
/// </param>
|
|
@@ -20,7 +38,7 @@
|
|
|
20
38
|
/// <exception cref="Microsoft.Rest.Azure.CloudException">
|
|
21
39
|
/// Thrown when the operation returned an invalid status code
|
|
22
40
|
/// </exception>
|
|
23
|
-
<% if (method.responses
|
|
41
|
+
<% if ((method.responses || []).filter(p => p.schema).length > 0) {-%>
|
|
24
42
|
/// <exception cref="Microsoft.Rest.SerializationException">
|
|
25
43
|
/// Thrown when unable to deserialize the response
|
|
26
44
|
/// </exception>
|
|
@@ -42,5 +60,6 @@
|
|
|
42
60
|
public async System.Threading.Tasks.Task<<%-method.language.default.responseType%>> <%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodParameterDeclarationWithCustomHeader%>)
|
|
43
61
|
{
|
|
44
62
|
<%# ToDo: add support for method.Flavor, currently assume it is RestCall -%>
|
|
63
|
+
|
|
45
64
|
<%- include('methodBodyRestCall', {method: method}) -%>
|
|
46
65
|
}
|
|
@@ -1,16 +1,68 @@
|
|
|
1
|
+
<%- project.helper.HandleConstParameters(method)%>
|
|
2
|
+
<%# handle x-ms-client-request-id -%>
|
|
3
|
+
<% var clientRequestId = 'x-ms-client-request-id';
|
|
4
|
+
var requestId = 'x-ms-request-id';
|
|
5
|
+
(method.parameters||[]).filter(p => p.protocol.http.in == 'header').forEach(function (parameter) {
|
|
6
|
+
if (parameter.extensions && parameter.extensions['x-ms-client-request-id']) {
|
|
7
|
+
clientRequestId = parameter.language.default.serializedName;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
if (method.extensions && method.extensions['x-ms-request-id']) {
|
|
11
|
+
requestId = method.extensions['x-ms-request-id'];
|
|
12
|
+
}
|
|
13
|
+
-%>
|
|
14
|
+
<%# end of handling x-ms-client-request-id -%>
|
|
15
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
16
|
+
if (nextPageLink == null)
|
|
17
|
+
{
|
|
18
|
+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "nextPageLink");
|
|
19
|
+
}
|
|
20
|
+
<% }else{-%>
|
|
21
|
+
<% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body').forEach(function(parameter){-%>
|
|
22
|
+
<%if(!(parameter.extensions && parameter.extensions['x-ms-client-flatten'])) {-%>
|
|
23
|
+
<% if (!project.helper.IsValueType(parameter.schema.type) && parameter.required && !project.helper.IsConstantParameter(parameter)) { -%>
|
|
24
|
+
if (<%-parameter.language.default.name%> == null)
|
|
25
|
+
{
|
|
26
|
+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "<%-parameter.language.default.name%>");
|
|
27
|
+
}
|
|
28
|
+
<% } -%>
|
|
29
|
+
<%if(method.requests[0].protocol.http.method != 'patch') {-%>
|
|
30
|
+
<%-project.helper.ValidateType(parameter.schema, method, parameter.language.default.name, parameter.nullable)%>
|
|
31
|
+
<%}-%>
|
|
32
|
+
<%}-%>
|
|
33
|
+
<% });-%>
|
|
1
34
|
<% if(method.parameters) { method.parameters.filter(p => (p.schema.type != 'constant' && p.language.default.name != '$host') || p.language.default.name == 'ApiVersion').forEach(function (parameter) {-%>
|
|
2
35
|
<%# ToDo: add check IsNullable with required -%>
|
|
3
36
|
<% var prefix = parameter.implementation == 'Client' ? 'this.Client.' : ''-%>
|
|
4
|
-
<% if (parameter.required) {-%>
|
|
37
|
+
<% if ( !(parameter.extensions && parameter.extensions['x-ms-parameter-grouping']) && parameter.required && !project.helper.IsValueType(parameter.schema.type) && !project.helper.IsConstantParameter(parameter)) {-%>
|
|
5
38
|
if (<%-prefix%><%-parameter.language.default.name%> == null)
|
|
6
39
|
{
|
|
7
40
|
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "<%-prefix%><%-parameter.language.default.name%>");
|
|
8
41
|
}
|
|
9
42
|
<% } -%>
|
|
10
|
-
|
|
43
|
+
<%-project.helper.ValidateType(parameter.schema, method, prefix + parameter.language.default.name, parameter.nullable)%>
|
|
11
44
|
<%});}-%>
|
|
12
|
-
|
|
45
|
+
<%(method.parameters || []).filter(p => p.protocol.http.in == 'complex').forEach(function(parameter) {-%>
|
|
46
|
+
<%-project.helper.PopulateGroupParameters(parameter)%>
|
|
47
|
+
<%});-%>
|
|
48
|
+
<%# support for p => p.IsConstant && !p.IsClientProperty -%>
|
|
49
|
+
<%(method.parameters || []).filter(p => p.implementation !== 'Client' && p.schema.type === 'constant' && p.required).forEach(function(parameter) {-%>
|
|
50
|
+
<%-project.helper.GetCsharpType(parameter.schema.valueType)%> <%-parameter.language.default.name%> = <%-parameter.schema.valueType.type === 'string' ? '"' + parameter.schema.value.value + '"' : parameter.schema.value.value%>;
|
|
51
|
+
<%});-%>
|
|
13
52
|
<%# ToDo: add support for BuildInputMappings -%>
|
|
53
|
+
<% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body').forEach(function(parameter){-%>
|
|
54
|
+
<%if(parameter.extensions && parameter.extensions['x-ms-client-flatten']) {-%>
|
|
55
|
+
<%-method.language.default.returnType%> <%-parameter.language.default.name%> = new <%-method.language.default.returnType%>();
|
|
56
|
+
<% var vps = project.helper.GetAllPublicVirtualProperties(parameter.schema.language.default.virtualProperties)-%>
|
|
57
|
+
if(<%-vps.map(vp=>`${vp.property.language.default.name} != null`).join('||')%>)
|
|
58
|
+
{
|
|
59
|
+
<%vps.forEach(function(vp) {-%>
|
|
60
|
+
<%-parameter.language.default.name%>.<%-vp.property.language.csharp.name%> = <%-vp.property.language.default.name%>;
|
|
61
|
+
<%});-%>
|
|
62
|
+
}
|
|
63
|
+
<%}-%>
|
|
64
|
+
<% });-%>
|
|
65
|
+
<%}-%>
|
|
14
66
|
// Tracing
|
|
15
67
|
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
|
|
16
68
|
string _invocationId = null;
|
|
@@ -18,25 +70,54 @@
|
|
|
18
70
|
{
|
|
19
71
|
_invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString();
|
|
20
72
|
System.Collections.Generic.Dictionary<string, object> tracingParameters = new System.Collections.Generic.Dictionary<string, object>();
|
|
73
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
74
|
+
tracingParameters.Add("nextPageLink", nextPageLink);
|
|
75
|
+
<% }else{-%>
|
|
21
76
|
<%# ToDo: add support for Model.LogicalParameters.Where(p => !p.IsClientProperty)-%>
|
|
77
|
+
<%method.parameters.filter(p => p.implementation != 'Client' && p.protocol.http.in != 'complex').forEach(function(p) {-%>
|
|
78
|
+
tracingParameters.Add("<%-p.language.default.name%>", <%-p.language.default.name%>);
|
|
79
|
+
<%});-%>
|
|
80
|
+
<%# ToDo: currently we just add the unexpanded body parameter, and need to be fixed in the future %>
|
|
81
|
+
<% (method.requests[0].parameters || []).filter(p =>p.protocol.http.in == 'body').forEach(function (parameter) {-%>
|
|
82
|
+
tracingParameters.Add("<%-parameter.language.default.name%>", <%-parameter.language.default.name%>);
|
|
83
|
+
<% });-%>
|
|
84
|
+
<% }%>
|
|
22
85
|
tracingParameters.Add("cancellationToken", cancellationToken);
|
|
23
86
|
Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "<%-method.language.default.name%>", tracingParameters);
|
|
24
87
|
}
|
|
25
88
|
// Construct URL
|
|
89
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
90
|
+
string _url = "{nextLink}";
|
|
91
|
+
_url = _url.Replace("{nextLink}", nextPageLink);
|
|
92
|
+
<% }else{%>
|
|
26
93
|
<%# ToDo: may need to support AbsoluteUrl -%>
|
|
27
94
|
var _baseUrl = this.Client.BaseUri.AbsoluteUri;
|
|
28
95
|
<%# ToDo: buildurl, currently only added simple cases, besides we need to handle skip url encoding -%>
|
|
29
96
|
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "<%-method.requests[0].protocol.http.path.substring(1)%>").ToString();
|
|
30
|
-
<%if (method.parameters) { method.parameters.filter(p => p.protocol.http.in == 'path').forEach(function (pathParameter) {
|
|
31
|
-
|
|
97
|
+
<%if (method.parameters) { method.parameters.filter(p => p.protocol.http.in == 'path').forEach(function (pathParameter) {
|
|
98
|
+
var prefix = pathParameter.implementation == 'Client' ? 'this.Client.' : '';
|
|
99
|
+
-%>
|
|
100
|
+
_url = _url.Replace("{<%-pathParameter.language.default.serializedName%>}", <%-project.helper.PathParameterString(pathParameter)%>);
|
|
32
101
|
<% });}-%>
|
|
102
|
+
<% }%>
|
|
33
103
|
System.Collections.Generic.List<string> _queryParameters = new System.Collections.Generic.List<string>();
|
|
34
|
-
<%if (method.parameters) { method.parameters.filter(p => p.protocol.http.in == 'query').forEach(function (queryParameter) { -%>
|
|
104
|
+
<%if (method.parameters && !method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.protocol.http.in == 'query').forEach(function (queryParameter) { -%>
|
|
35
105
|
<% var prefix = queryParameter.implementation == 'Client' ? 'this.Client.' : ''-%>
|
|
106
|
+
<% if (queryParameter.extensions && queryParameter.extensions['x-ms-odata']) {-%>
|
|
107
|
+
if (<%-queryParameter.language.default.name%> != null)
|
|
108
|
+
{
|
|
109
|
+
var _<%-project.helper.CamelCase(queryParameter.schema.language.default.name)%> = <%-queryParameter.language.default.name%>.ToString();
|
|
110
|
+
if (!string.IsNullOrEmpty(_<%-project.helper.CamelCase(queryParameter.schema.language.default.name)%>))
|
|
111
|
+
{
|
|
112
|
+
_queryParameters.Add(_<%-project.helper.CamelCase(queryParameter.schema.language.default.name)%>);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
<% } else {-%>
|
|
36
116
|
if (<%-prefix%><%-queryParameter.language.default.name%> != null)
|
|
37
117
|
{
|
|
38
|
-
_queryParameters.Add(string.Format("<%-queryParameter.language.default.serializedName%>={0}",
|
|
118
|
+
_queryParameters.Add(string.Format("<%-queryParameter.language.default.serializedName%>={0}", <%-project.helper.PathParameterString(queryParameter)%>));
|
|
39
119
|
}
|
|
120
|
+
<% }-%>
|
|
40
121
|
<% });}-%>
|
|
41
122
|
if (_queryParameters.Count > 0)
|
|
42
123
|
{
|
|
@@ -51,7 +132,7 @@
|
|
|
51
132
|
<%# ToDo: Add headers except for following default ones -%>
|
|
52
133
|
if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value)
|
|
53
134
|
{
|
|
54
|
-
_httpRequest.Headers.TryAddWithoutValidation("
|
|
135
|
+
_httpRequest.Headers.TryAddWithoutValidation("<%-clientRequestId%>", System.Guid.NewGuid().ToString());
|
|
55
136
|
}
|
|
56
137
|
if (this.Client.AcceptLanguage != null)
|
|
57
138
|
{
|
|
@@ -61,7 +142,17 @@
|
|
|
61
142
|
}
|
|
62
143
|
_httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage);
|
|
63
144
|
}
|
|
64
|
-
|
|
145
|
+
<% (method.parameters || []).filter(p => p.protocol.http.in == 'header').forEach(function(parameter) {
|
|
146
|
+
var prefix = parameter.implementation == 'Client' ? 'this.Client.' : ''-%>
|
|
147
|
+
if (<%-prefix%><%-parameter.language.default.name%> != null)
|
|
148
|
+
{
|
|
149
|
+
if (_httpRequest.Headers.Contains("<%-parameter.language.default.serializedName%>"))
|
|
150
|
+
{
|
|
151
|
+
_httpRequest.Headers.Remove("<%-parameter.language.default.serializedName%>");
|
|
152
|
+
}
|
|
153
|
+
_httpRequest.Headers.TryAddWithoutValidation("<%-parameter.language.default.serializedName%>", <%-prefix%><%-parameter.language.default.name%>);
|
|
154
|
+
}
|
|
155
|
+
<% });-%>
|
|
65
156
|
|
|
66
157
|
if (customHeaders != null)
|
|
67
158
|
{
|
|
@@ -77,6 +168,21 @@
|
|
|
77
168
|
// Serialize Request
|
|
78
169
|
string _requestContent = null;
|
|
79
170
|
<%# ToDo: add RequestBody, formdata support-%>
|
|
171
|
+
<% (method.requests[0].parameters || []).filter(p =>p.protocol.http.in == 'body').forEach(function (parameter) {-%>
|
|
172
|
+
<%# ToDo: currently only support for an unexpanded nullable body, need other support in the future -%>
|
|
173
|
+
<% if (!project.helper.IsValueType(parameter.schema.type) && !project.helper.IsConstantParameter(parameter)) {-%>
|
|
174
|
+
if(<%-parameter.language.default.name%> != null)
|
|
175
|
+
{
|
|
176
|
+
_requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(<%-parameter.language.default.name%>, <%-project.helper.GetSerializationSettings(parameter.schema, 'this.Client')%>);
|
|
177
|
+
_httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8);
|
|
178
|
+
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
|
|
179
|
+
}
|
|
180
|
+
<% } else { -%>
|
|
181
|
+
_requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(<%-parameter.language.default.name%>, <%-project.helper.GetSerializationSettings(parameter.schema, 'this.Client')%>);
|
|
182
|
+
_httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8);
|
|
183
|
+
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
|
|
184
|
+
<% } -%>
|
|
185
|
+
<% });-%>
|
|
80
186
|
<%# ToDo: Need to confirm in which case Settings.AddCredentials is false -%>
|
|
81
187
|
// Set Credentials
|
|
82
188
|
if (this.Client.Credentials != null)
|
|
@@ -90,8 +196,9 @@
|
|
|
90
196
|
Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
|
|
91
197
|
}
|
|
92
198
|
cancellationToken.ThrowIfCancellationRequested();
|
|
93
|
-
<%# ToDo: Add support for primary type return
|
|
94
|
-
|
|
199
|
+
<%# ToDo: Add support for primary type return -%>
|
|
200
|
+
<% var responseHeadersRead = method.requests[0].protocol.http.method === 'head' ? 'System.Net.Http.HttpCompletionOption.ResponseHeadersRead, ': '' -%>
|
|
201
|
+
_httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, <%-responseHeadersRead%>cancellationToken).ConfigureAwait(false);
|
|
95
202
|
if (_shouldTrace)
|
|
96
203
|
{
|
|
97
204
|
Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
|
|
@@ -103,16 +210,19 @@
|
|
|
103
210
|
|
|
104
211
|
if (<%-method.language.default.failureStatusCodePredicate%>)
|
|
105
212
|
{
|
|
106
|
-
var ex = new Microsoft.Rest.Azure.CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
|
|
213
|
+
var ex = new <%-project.helper.IsCloudErrorException(method) ? 'Microsoft.Rest.Azure.CloudException' : `${method.exceptions[0].schema.language.default.name}Exception`%>(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
|
|
107
214
|
<%# ToDo: not sure whether there is the case that there is no default response(error). If so, we will need to add support for it -%>
|
|
108
215
|
try
|
|
109
216
|
{
|
|
110
217
|
<%# ToDo: Need to add support for primary type -%>
|
|
111
218
|
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
|
|
112
|
-
|
|
219
|
+
<%var errorClass = !project.helper.IsCloudErrorException(method) ? method.exceptions[0].schema.language.default.name : 'CloudError'-%>
|
|
220
|
+
<%-errorClass%> _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<<%-errorClass%>>(_responseContent, this.Client.DeserializationSettings);
|
|
113
221
|
if (_errorBody != null)
|
|
114
222
|
{
|
|
223
|
+
<% if(project.helper.IsCloudErrorException(method)) { -%>
|
|
115
224
|
ex = new Microsoft.Rest.Azure.CloudException(_errorBody.Message);
|
|
225
|
+
<% } -%>
|
|
116
226
|
ex.Body = _errorBody;
|
|
117
227
|
}
|
|
118
228
|
}
|
|
@@ -122,10 +232,12 @@
|
|
|
122
232
|
}
|
|
123
233
|
ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent);
|
|
124
234
|
ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent);
|
|
125
|
-
|
|
235
|
+
<% if (project.helper.IsCloudErrorException(method)) {-%>
|
|
236
|
+
if (_httpResponse.Headers.Contains("<%-(method.extensions && method.extensions[requestId]) ?? requestId%>"))
|
|
126
237
|
{
|
|
127
|
-
ex.RequestId = _httpResponse.Headers.GetValues("
|
|
238
|
+
ex.RequestId = _httpResponse.Headers.GetValues("<%-(method.extensions && method.extensions[requestId]) ?? requestId%>").FirstOrDefault();
|
|
128
239
|
}
|
|
240
|
+
<% } -%>
|
|
129
241
|
if (_shouldTrace)
|
|
130
242
|
{
|
|
131
243
|
Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex);
|
|
@@ -141,12 +253,12 @@
|
|
|
141
253
|
var _result = new <%-method.language.default.responseType%>();
|
|
142
254
|
_result.Request = _httpRequest;
|
|
143
255
|
_result.Response = _httpResponse;
|
|
144
|
-
|
|
145
|
-
if (_httpResponse.Headers.Contains("
|
|
256
|
+
<%- method.language.default.initializeResponseBody %>
|
|
257
|
+
if (_httpResponse.Headers.Contains("<%-requestId%>"))
|
|
146
258
|
{
|
|
147
|
-
_result.RequestId = _httpResponse.Headers.GetValues("
|
|
259
|
+
_result.RequestId = _httpResponse.Headers.GetValues("<%-requestId%>").FirstOrDefault();
|
|
148
260
|
}
|
|
149
|
-
<%method.responses.filter(r => r.schema).forEach(function(resp) {-%>
|
|
261
|
+
<%(method.responses || []).filter(r => r.schema).forEach(function(resp) {-%>
|
|
150
262
|
// Deserialize Response
|
|
151
263
|
if ((int)_statusCode == <%-resp.protocol.http.statusCodes[0]%>)
|
|
152
264
|
{
|
|
@@ -156,7 +268,14 @@
|
|
|
156
268
|
try
|
|
157
269
|
{
|
|
158
270
|
<%# ToDo: we assume the return is object, need to add support for other types including support nullable -%>
|
|
159
|
-
|
|
271
|
+
<% var respSchema = resp.schema;
|
|
272
|
+
if(resp.schema.type === 'choice' || (resp.schema.type === 'sealed-choice' && (respSchema.schema.choiceType.type != 'string' || (resp.schema.extensions && resp.schema.extensions['x-ms-model-as-string'])))){
|
|
273
|
+
respSchema = resp.schema.choiceType;
|
|
274
|
+
}
|
|
275
|
+
var deserializeType = method.language.default.deserializeType ? method.language.default.deserializeType : respSchema.language.csharp.fullname;
|
|
276
|
+
const postfix = (project.helper.IsValueType(respSchema.type) || project.helper.IsEnum(resp.schema)) ? '?' : '';
|
|
277
|
+
-%>
|
|
278
|
+
_result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<<%-deserializeType + postfix%>>(_responseContent, <%-project.helper.GetDeserializationSettings(respSchema, 'this.Client')%>);
|
|
160
279
|
}
|
|
161
280
|
catch (Newtonsoft.Json.JsonException ex)
|
|
162
281
|
{
|
|
@@ -171,6 +290,21 @@
|
|
|
171
290
|
<% });-%>
|
|
172
291
|
<%# ToDo: add support for case Model.ReturnType.Body != null && Model.DefaultResponse.Body != null && !Model.Responses.Any()-%>
|
|
173
292
|
<%# ToDo: add support for case there are return in headers-%>
|
|
293
|
+
<% if (method.language.default.returnTypeHeader.name !== '') { -%>
|
|
294
|
+
try
|
|
295
|
+
{
|
|
296
|
+
_result.Headers = _httpResponse.GetHeadersAsJson().ToObject<<%-method.language.default.returnTypeHeader.name%>>(Newtonsoft.Json.JsonSerializer.Create(this.Client.DeserializationSettings));
|
|
297
|
+
}
|
|
298
|
+
catch (Newtonsoft.Json.JsonException ex)
|
|
299
|
+
{
|
|
300
|
+
_httpRequest.Dispose();
|
|
301
|
+
if (_httpResponse != null)
|
|
302
|
+
{
|
|
303
|
+
_httpResponse.Dispose();
|
|
304
|
+
}
|
|
305
|
+
throw new Microsoft.Rest.SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
|
|
306
|
+
}
|
|
307
|
+
<% } -%>
|
|
174
308
|
if (_shouldTrace)
|
|
175
309
|
{
|
|
176
310
|
Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result);
|