Generated required-optional. Added required-optional tests. Fixed issue with array headers.
This commit is contained in:
Родитель
d0bbe8db35
Коммит
78dd590486
|
@ -45,7 +45,7 @@ $testNames =
|
|||
'model-flattening',
|
||||
'non-string-enum',
|
||||
'paging',
|
||||
#'required-optional',
|
||||
'required-optional',
|
||||
'url',
|
||||
'validation',
|
||||
'xml-service',
|
||||
|
|
|
@ -352,12 +352,30 @@ namespace AutoRest.CSharp.V3.Generation.Writers
|
|||
writer.Line($", {segment.Escape:L});");
|
||||
}
|
||||
|
||||
private string? GetSerializationStyleDelimiter(RequestSerializationStyle style) => style switch
|
||||
{
|
||||
RequestSerializationStyle.PipeDelimited => "|",
|
||||
RequestSerializationStyle.TabDelimited => "\t",
|
||||
RequestSerializationStyle.SpaceDelimited => " ",
|
||||
RequestSerializationStyle.CommaDelimited => ",",
|
||||
_ => null
|
||||
};
|
||||
|
||||
private void WriteHeader(CodeWriter writer, CodeWriterDeclaration request, RequestHeader header)
|
||||
{
|
||||
string? delimiter = GetSerializationStyleDelimiter(header.SerializationStyle);
|
||||
string method = delimiter != null
|
||||
? nameof(RequestHeaderExtensions.AddDelimited)
|
||||
: nameof(RequestHeaderExtensions.Add);
|
||||
|
||||
using (WriteValueNullCheck(writer, header.Value))
|
||||
{
|
||||
writer.Append($"{request}.Headers.Add({header.Name:L}, ");
|
||||
writer.Append($"{request}.Headers.{method}({header.Name:L}, ");
|
||||
WriteConstantOrParameter(writer, header.Value, enumAsString: true);
|
||||
if (delimiter != null)
|
||||
{
|
||||
writer.Append($", {delimiter:L}");
|
||||
}
|
||||
WriteSerializationFormat(writer, header.Format);
|
||||
writer.Line($");");
|
||||
}
|
||||
|
@ -412,30 +430,10 @@ namespace AutoRest.CSharp.V3.Generation.Writers
|
|||
|
||||
private void WriteQueryParameter(CodeWriter writer, CodeWriterDeclaration uri, QueryParameter queryParameter)
|
||||
{
|
||||
string method;
|
||||
string? delimiter = null;
|
||||
switch (queryParameter.SerializationStyle)
|
||||
{
|
||||
case QuerySerializationStyle.PipeDelimited:
|
||||
method = nameof(RequestUriBuilderExtensions.AppendQueryDelimited);
|
||||
delimiter = "|";
|
||||
break;
|
||||
case QuerySerializationStyle.TabDelimited:
|
||||
method = nameof(RequestUriBuilderExtensions.AppendQueryDelimited);
|
||||
delimiter = "\t";
|
||||
break;
|
||||
case QuerySerializationStyle.SpaceDelimited:
|
||||
method = nameof(RequestUriBuilderExtensions.AppendQueryDelimited);
|
||||
delimiter = " ";
|
||||
break;
|
||||
case QuerySerializationStyle.CommaDelimited:
|
||||
method = nameof(RequestUriBuilderExtensions.AppendQueryDelimited);
|
||||
delimiter = ",";
|
||||
break;
|
||||
default:
|
||||
method = nameof(RequestUriBuilderExtensions.AppendQuery);
|
||||
break;
|
||||
}
|
||||
string? delimiter = GetSerializationStyleDelimiter(queryParameter.SerializationStyle);
|
||||
string method = delimiter != null
|
||||
? nameof(RequestUriBuilderExtensions.AppendQueryDelimited)
|
||||
: nameof(RequestUriBuilderExtensions.AppendQuery);
|
||||
|
||||
ReferenceOrConstant value = queryParameter.Value;
|
||||
using (WriteValueNullCheck(writer, value))
|
||||
|
|
|
@ -253,7 +253,7 @@ namespace AutoRest.CSharp.V3.Output.Builders
|
|||
switch (httpParameter.In)
|
||||
{
|
||||
case ParameterLocation.Header:
|
||||
headers.Add(new RequestHeader(serializedName, constantOrReference, serializationFormat));
|
||||
headers.Add(new RequestHeader(serializedName, constantOrReference, GetSerializationStyle(httpParameter, valueSchema), serializationFormat));
|
||||
break;
|
||||
case ParameterLocation.Query:
|
||||
query.Add(new QueryParameter(serializedName, constantOrReference, GetSerializationStyle(httpParameter, valueSchema), !skipEncoding, serializationFormat));
|
||||
|
@ -558,21 +558,22 @@ namespace AutoRest.CSharp.V3.Output.Builders
|
|||
);
|
||||
}
|
||||
|
||||
private static QuerySerializationStyle GetSerializationStyle(HttpParameter httpParameter, Schema valueSchema)
|
||||
private static RequestSerializationStyle GetSerializationStyle(HttpParameter httpParameter, Schema valueSchema)
|
||||
{
|
||||
Debug.Assert(httpParameter.In == ParameterLocation.Query);
|
||||
Debug.Assert(httpParameter.In == ParameterLocation.Query || httpParameter.In == ParameterLocation.Header);
|
||||
|
||||
switch (httpParameter.Style)
|
||||
{
|
||||
case null:
|
||||
case SerializationStyle.Form:
|
||||
return valueSchema is ArraySchema ? QuerySerializationStyle.CommaDelimited : QuerySerializationStyle.Simple;
|
||||
case SerializationStyle.Simple:
|
||||
return valueSchema is ArraySchema ? RequestSerializationStyle.CommaDelimited : RequestSerializationStyle.Simple;
|
||||
case SerializationStyle.PipeDelimited:
|
||||
return QuerySerializationStyle.PipeDelimited;
|
||||
return RequestSerializationStyle.PipeDelimited;
|
||||
case SerializationStyle.SpaceDelimited:
|
||||
return QuerySerializationStyle.SpaceDelimited;
|
||||
return RequestSerializationStyle.SpaceDelimited;
|
||||
case SerializationStyle.TabDelimited:
|
||||
return QuerySerializationStyle.TabDelimited;
|
||||
return RequestSerializationStyle.TabDelimited;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace AutoRest.CSharp.V3.Output.Models.Requests
|
|||
{
|
||||
internal class QueryParameter
|
||||
{
|
||||
public QueryParameter(string name, ReferenceOrConstant value, QuerySerializationStyle serializationStyle, bool escape, SerializationFormat serializationFormat)
|
||||
public QueryParameter(string name, ReferenceOrConstant value, RequestSerializationStyle serializationStyle, bool escape, SerializationFormat serializationFormat)
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
|
@ -18,7 +18,7 @@ namespace AutoRest.CSharp.V3.Output.Models.Requests
|
|||
|
||||
public string Name { get; }
|
||||
public ReferenceOrConstant Value { get; }
|
||||
public QuerySerializationStyle SerializationStyle { get; }
|
||||
public RequestSerializationStyle SerializationStyle { get; }
|
||||
public SerializationFormat SerializationFormat { get; }
|
||||
public bool Escape { get; }
|
||||
}
|
||||
|
|
|
@ -9,12 +9,14 @@ namespace AutoRest.CSharp.V3.Output.Models.Requests
|
|||
{
|
||||
public string Name { get; }
|
||||
public ReferenceOrConstant Value { get; }
|
||||
public RequestSerializationStyle SerializationStyle { get; }
|
||||
public SerializationFormat Format { get; }
|
||||
|
||||
public RequestHeader(string name, ReferenceOrConstant value, SerializationFormat format = SerializationFormat.Default)
|
||||
public RequestHeader(string name, ReferenceOrConstant value, RequestSerializationStyle serializationStyle, SerializationFormat format = SerializationFormat.Default)
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
SerializationStyle = serializationStyle;
|
||||
Format = format;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace AutoRest.CSharp.V3.Output.Models.Requests
|
||||
{
|
||||
internal enum QuerySerializationStyle
|
||||
internal enum RequestSerializationStyle
|
||||
{
|
||||
Simple,
|
||||
PipeDelimited,
|
|
@ -144,6 +144,10 @@
|
|||
"commandName": "Project",
|
||||
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\paging\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\paging --namespace=paging --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
|
||||
},
|
||||
"required-optional": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\test\\TestServerProjects\\required-optional\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\test\\TestServerProjects\\required-optional --namespace=required_optional --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
|
||||
},
|
||||
"SignalR": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "--standalone --input-codemodel=$(SolutionDir)\\samples\\SignalR\\SignalR\\CodeModel.yaml --plugin=csharpgen --output-folder=$(SolutionDir)\\samples\\SignalR\\SignalR --namespace=SignalR --shared-source-folder=$(SolutionDir)\\src\\assets --save-code-model=true"
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Azure.Core
|
||||
|
@ -49,5 +50,10 @@ namespace Azure.Core
|
|||
{
|
||||
headers.Add(name, Convert.ToBase64String(value));
|
||||
}
|
||||
|
||||
public static void AddDelimited<T>(this RequestHeaders headers, string name, IEnumerable<T> value, string delimiter)
|
||||
{
|
||||
headers.Add(name, string.Join(delimiter, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using NUnit.Framework;
|
||||
using required_optional;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
{
|
||||
public class RequiredOptionalTest : TestServerTestBase
|
||||
{
|
||||
public RequiredOptionalTest(TestServerVersion version) : base(version, "reqopt") { }
|
||||
|
||||
[Test]
|
||||
public Task OptionalArrayHeader() => TestStatus(async (host, pipeline) => await new ExplicitClient(ClientDiagnostics, pipeline, host).RestClient.PostOptionalArrayHeaderAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalArrayParameter() => TestStatus(async (host, pipeline) => await new ExplicitClient(ClientDiagnostics, pipeline, host).RestClient.PostOptionalArrayParameterAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalArrayProperty() => TestStatus(async (host, pipeline) => await new ExplicitClient(ClientDiagnostics, pipeline, host).RestClient.PostOptionalArrayPropertyAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalClassParameter() => TestStatus(async (host, pipeline) => await new ExplicitClient(ClientDiagnostics, pipeline, host).RestClient.PostOptionalClassParameterAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalClassProperty() => TestStatus(async (host, pipeline) => await new ExplicitClient(ClientDiagnostics, pipeline, host).RestClient.PostOptionalClassPropertyAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalGlobalQuery() => TestStatus(async (host, pipeline) => await new ImplicitClient(ClientDiagnostics, pipeline, string.Empty, string.Empty, host).RestClient.GetOptionalGlobalQueryAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalImplicitBody() => TestStatus(async (host, pipeline) => await new ImplicitClient(ClientDiagnostics, pipeline, string.Empty, string.Empty, host).RestClient.PutOptionalBodyAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalImplicitHeader() => TestStatus(async (host, pipeline) => await new ImplicitClient(ClientDiagnostics, pipeline, string.Empty, string.Empty, host).RestClient.PutOptionalHeaderAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalImplicitQuery() => TestStatus(async (host, pipeline) => await new ImplicitClient(ClientDiagnostics, pipeline, string.Empty, string.Empty, host).RestClient.PutOptionalQueryAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalIntegerHeader() => TestStatus(async (host, pipeline) => await new ExplicitClient(ClientDiagnostics, pipeline, host).RestClient.PostOptionalIntegerHeaderAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalIntegerParameter() => TestStatus(async (host, pipeline) => await new ExplicitClient(ClientDiagnostics, pipeline, host).RestClient.PostOptionalIntegerParameterAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalIntegerProperty() => TestStatus(async (host, pipeline) => await new ExplicitClient(ClientDiagnostics, pipeline, host).RestClient.PostOptionalIntegerPropertyAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalStringHeader() => TestStatus(async (host, pipeline) => await new ExplicitClient(ClientDiagnostics, pipeline, host).RestClient.PostOptionalStringHeaderAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalStringParameter() => TestStatus(async (host, pipeline) => await new ExplicitClient(ClientDiagnostics, pipeline, host).RestClient.PostOptionalStringParameterAsync());
|
||||
|
||||
[Test]
|
||||
public Task OptionalStringProperty() => TestStatus(async (host, pipeline) => await new ExplicitClient(ClientDiagnostics, pipeline, host).RestClient.PostOptionalStringPropertyAsync());
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
31
test/TestServerProjects/required-optional/Generated/Models/ArrayOptionalWrapper.Serialization.cs
сгенерированный
Normal file
31
test/TestServerProjects/required-optional/Generated/Models/ArrayOptionalWrapper.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
public partial class ArrayOptionalWrapper : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (Value != null)
|
||||
{
|
||||
writer.WritePropertyName("value");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in Value)
|
||||
{
|
||||
writer.WriteStringValue(item);
|
||||
}
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
29
test/TestServerProjects/required-optional/Generated/Models/ArrayOptionalWrapper.cs
сгенерированный
Normal file
29
test/TestServerProjects/required-optional/Generated/Models/ArrayOptionalWrapper.cs
сгенерированный
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
/// <summary> The ArrayOptionalWrapper. </summary>
|
||||
public partial class ArrayOptionalWrapper
|
||||
{
|
||||
/// <summary> Initializes a new instance of ArrayOptionalWrapper. </summary>
|
||||
public ArrayOptionalWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of ArrayOptionalWrapper. </summary>
|
||||
/// <param name="value"> . </param>
|
||||
internal ArrayOptionalWrapper(IList<string> value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public IList<string> Value { get; set; }
|
||||
}
|
||||
}
|
28
test/TestServerProjects/required-optional/Generated/Models/ArrayWrapper.Serialization.cs
сгенерированный
Normal file
28
test/TestServerProjects/required-optional/Generated/Models/ArrayWrapper.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
public partial class ArrayWrapper : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("value");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in Value)
|
||||
{
|
||||
writer.WriteStringValue(item);
|
||||
}
|
||||
writer.WriteEndArray();
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
38
test/TestServerProjects/required-optional/Generated/Models/ArrayWrapper.cs
сгенерированный
Normal file
38
test/TestServerProjects/required-optional/Generated/Models/ArrayWrapper.cs
сгенерированный
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
/// <summary> The ArrayWrapper. </summary>
|
||||
public partial class ArrayWrapper
|
||||
{
|
||||
/// <summary> Initializes a new instance of ArrayWrapper. </summary>
|
||||
/// <param name="value"> . </param>
|
||||
public ArrayWrapper(IEnumerable<string> value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
Value = value.ToArray();
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of ArrayWrapper. </summary>
|
||||
/// <param name="value"> . </param>
|
||||
internal ArrayWrapper(IList<string> value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public IList<string> Value { get; }
|
||||
}
|
||||
}
|
26
test/TestServerProjects/required-optional/Generated/Models/ClassOptionalWrapper.Serialization.cs
сгенерированный
Normal file
26
test/TestServerProjects/required-optional/Generated/Models/ClassOptionalWrapper.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
public partial class ClassOptionalWrapper : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (Value != null)
|
||||
{
|
||||
writer.WritePropertyName("value");
|
||||
writer.WriteObjectValue(Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
27
test/TestServerProjects/required-optional/Generated/Models/ClassOptionalWrapper.cs
сгенерированный
Normal file
27
test/TestServerProjects/required-optional/Generated/Models/ClassOptionalWrapper.cs
сгенерированный
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
/// <summary> The ClassOptionalWrapper. </summary>
|
||||
public partial class ClassOptionalWrapper
|
||||
{
|
||||
/// <summary> Initializes a new instance of ClassOptionalWrapper. </summary>
|
||||
public ClassOptionalWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of ClassOptionalWrapper. </summary>
|
||||
/// <param name="value"> . </param>
|
||||
internal ClassOptionalWrapper(Product value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public Product Value { get; set; }
|
||||
}
|
||||
}
|
23
test/TestServerProjects/required-optional/Generated/Models/ClassWrapper.Serialization.cs
сгенерированный
Normal file
23
test/TestServerProjects/required-optional/Generated/Models/ClassWrapper.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
public partial class ClassWrapper : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("value");
|
||||
writer.WriteObjectValue(Value);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
29
test/TestServerProjects/required-optional/Generated/Models/ClassWrapper.cs
сгенерированный
Normal file
29
test/TestServerProjects/required-optional/Generated/Models/ClassWrapper.cs
сгенерированный
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
/// <summary> The ClassWrapper. </summary>
|
||||
public partial class ClassWrapper
|
||||
{
|
||||
/// <summary> Initializes a new instance of ClassWrapper. </summary>
|
||||
/// <param name="value"> . </param>
|
||||
public ClassWrapper(Product value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public Product Value { get; }
|
||||
}
|
||||
}
|
43
test/TestServerProjects/required-optional/Generated/Models/Error.Serialization.cs
сгенерированный
Normal file
43
test/TestServerProjects/required-optional/Generated/Models/Error.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
public partial class Error
|
||||
{
|
||||
internal static Error DeserializeError(JsonElement element)
|
||||
{
|
||||
int? status = default;
|
||||
string message = default;
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("status"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
status = property.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("message"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
message = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return new Error(status, message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
/// <summary> The Error. </summary>
|
||||
public partial class Error
|
||||
{
|
||||
/// <summary> Initializes a new instance of Error. </summary>
|
||||
internal Error()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of Error. </summary>
|
||||
/// <param name="status"> . </param>
|
||||
/// <param name="message"> . </param>
|
||||
internal Error(int? status, string message)
|
||||
{
|
||||
Status = status;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public int? Status { get; }
|
||||
public string Message { get; }
|
||||
}
|
||||
}
|
26
test/TestServerProjects/required-optional/Generated/Models/IntOptionalWrapper.Serialization.cs
сгенерированный
Normal file
26
test/TestServerProjects/required-optional/Generated/Models/IntOptionalWrapper.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
public partial class IntOptionalWrapper : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (Value != null)
|
||||
{
|
||||
writer.WritePropertyName("value");
|
||||
writer.WriteNumberValue(Value.Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
27
test/TestServerProjects/required-optional/Generated/Models/IntOptionalWrapper.cs
сгенерированный
Normal file
27
test/TestServerProjects/required-optional/Generated/Models/IntOptionalWrapper.cs
сгенерированный
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
/// <summary> The IntOptionalWrapper. </summary>
|
||||
public partial class IntOptionalWrapper
|
||||
{
|
||||
/// <summary> Initializes a new instance of IntOptionalWrapper. </summary>
|
||||
public IntOptionalWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of IntOptionalWrapper. </summary>
|
||||
/// <param name="value"> . </param>
|
||||
internal IntOptionalWrapper(int? value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public int? Value { get; set; }
|
||||
}
|
||||
}
|
23
test/TestServerProjects/required-optional/Generated/Models/IntWrapper.Serialization.cs
сгенерированный
Normal file
23
test/TestServerProjects/required-optional/Generated/Models/IntWrapper.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
public partial class IntWrapper : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("value");
|
||||
writer.WriteNumberValue(Value);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
22
test/TestServerProjects/required-optional/Generated/Models/IntWrapper.cs
сгенерированный
Normal file
22
test/TestServerProjects/required-optional/Generated/Models/IntWrapper.cs
сгенерированный
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
/// <summary> The IntWrapper. </summary>
|
||||
public partial class IntWrapper
|
||||
{
|
||||
/// <summary> Initializes a new instance of IntWrapper. </summary>
|
||||
/// <param name="value"> . </param>
|
||||
public IntWrapper(int value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public int Value { get; }
|
||||
}
|
||||
}
|
28
test/TestServerProjects/required-optional/Generated/Models/Product.Serialization.cs
сгенерированный
Normal file
28
test/TestServerProjects/required-optional/Generated/Models/Product.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
public partial class Product : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("id");
|
||||
writer.WriteNumberValue(Id);
|
||||
if (Name != null)
|
||||
{
|
||||
writer.WritePropertyName("name");
|
||||
writer.WriteStringValue(Name);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
32
test/TestServerProjects/required-optional/Generated/Models/Product.cs
сгенерированный
Normal file
32
test/TestServerProjects/required-optional/Generated/Models/Product.cs
сгенерированный
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
/// <summary> The Product. </summary>
|
||||
public partial class Product
|
||||
{
|
||||
/// <summary> Initializes a new instance of Product. </summary>
|
||||
/// <param name="id"> . </param>
|
||||
public Product(int id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of Product. </summary>
|
||||
/// <param name="id"> . </param>
|
||||
/// <param name="name"> . </param>
|
||||
internal Product(int id, string name)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public int Id { get; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
26
test/TestServerProjects/required-optional/Generated/Models/StringOptionalWrapper.Serialization.cs
сгенерированный
Normal file
26
test/TestServerProjects/required-optional/Generated/Models/StringOptionalWrapper.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
public partial class StringOptionalWrapper : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (Value != null)
|
||||
{
|
||||
writer.WritePropertyName("value");
|
||||
writer.WriteStringValue(Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
27
test/TestServerProjects/required-optional/Generated/Models/StringOptionalWrapper.cs
сгенерированный
Normal file
27
test/TestServerProjects/required-optional/Generated/Models/StringOptionalWrapper.cs
сгенерированный
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
/// <summary> The StringOptionalWrapper. </summary>
|
||||
public partial class StringOptionalWrapper
|
||||
{
|
||||
/// <summary> Initializes a new instance of StringOptionalWrapper. </summary>
|
||||
public StringOptionalWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of StringOptionalWrapper. </summary>
|
||||
/// <param name="value"> . </param>
|
||||
internal StringOptionalWrapper(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
23
test/TestServerProjects/required-optional/Generated/Models/StringWrapper.Serialization.cs
сгенерированный
Normal file
23
test/TestServerProjects/required-optional/Generated/Models/StringWrapper.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
public partial class StringWrapper : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("value");
|
||||
writer.WriteStringValue(Value);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
29
test/TestServerProjects/required-optional/Generated/Models/StringWrapper.cs
сгенерированный
Normal file
29
test/TestServerProjects/required-optional/Generated/Models/StringWrapper.cs
сгенерированный
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
|
||||
namespace required_optional.Models
|
||||
{
|
||||
/// <summary> The StringWrapper. </summary>
|
||||
public partial class StringWrapper
|
||||
{
|
||||
/// <summary> Initializes a new instance of StringWrapper. </summary>
|
||||
/// <param name="value"> . </param>
|
||||
public StringWrapper(string value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public string Value { get; }
|
||||
}
|
||||
}
|
386
test/TestServerProjects/required-optional/Generated/Operations/ExplicitClient.cs
сгенерированный
Normal file
386
test/TestServerProjects/required-optional/Generated/Operations/ExplicitClient.cs
сгенерированный
Normal file
|
@ -0,0 +1,386 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Azure;
|
||||
using Azure.Core.Pipeline;
|
||||
using required_optional.Models;
|
||||
|
||||
namespace required_optional
|
||||
{
|
||||
public partial class ExplicitClient
|
||||
{
|
||||
private readonly ClientDiagnostics clientDiagnostics;
|
||||
private readonly HttpPipeline pipeline;
|
||||
internal ExplicitRestClient RestClient { get; }
|
||||
/// <summary> Initializes a new instance of ExplicitClient for mocking. </summary>
|
||||
protected ExplicitClient()
|
||||
{
|
||||
}
|
||||
/// <summary> Initializes a new instance of ExplicitClient. </summary>
|
||||
internal ExplicitClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string host = "http://localhost:3000")
|
||||
{
|
||||
RestClient = new ExplicitRestClient(clientDiagnostics, pipeline, host);
|
||||
this.clientDiagnostics = clientDiagnostics;
|
||||
this.pipeline = pipeline;
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required integer. Please put null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The Integer to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostRequiredIntegerParameterAsync(int bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostRequiredIntegerParameterAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required integer. Please put null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The Integer to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostRequiredIntegerParameter(int bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostRequiredIntegerParameter(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional integer. Please put null. </summary>
|
||||
/// <param name="bodyParameter"> The Integer to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostOptionalIntegerParameterAsync(int? bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostOptionalIntegerParameterAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional integer. Please put null. </summary>
|
||||
/// <param name="bodyParameter"> The Integer to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostOptionalIntegerParameter(int? bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostOptionalIntegerParameter(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required integer. Please put a valid int-wrapper with 'value' = null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The IntWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostRequiredIntegerPropertyAsync(IntWrapper bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostRequiredIntegerPropertyAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required integer. Please put a valid int-wrapper with 'value' = null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The IntWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostRequiredIntegerProperty(IntWrapper bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostRequiredIntegerProperty(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional integer. Please put a valid int-wrapper with 'value' = null. </summary>
|
||||
/// <param name="bodyParameter"> The IntOptionalWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostOptionalIntegerPropertyAsync(IntOptionalWrapper bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostOptionalIntegerPropertyAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional integer. Please put a valid int-wrapper with 'value' = null. </summary>
|
||||
/// <param name="bodyParameter"> The IntOptionalWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostOptionalIntegerProperty(IntOptionalWrapper bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostOptionalIntegerProperty(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required integer. Please put a header 'headerParameter' => null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="headerParameter"> The Integer to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostRequiredIntegerHeaderAsync(int headerParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostRequiredIntegerHeaderAsync(headerParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required integer. Please put a header 'headerParameter' => null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="headerParameter"> The Integer to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostRequiredIntegerHeader(int headerParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostRequiredIntegerHeader(headerParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional integer. Please put a header 'headerParameter' => null. </summary>
|
||||
/// <param name="headerParameter"> The Integer to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostOptionalIntegerHeaderAsync(int? headerParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostOptionalIntegerHeaderAsync(headerParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional integer. Please put a header 'headerParameter' => null. </summary>
|
||||
/// <param name="headerParameter"> The Integer to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostOptionalIntegerHeader(int? headerParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostOptionalIntegerHeader(headerParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required string. Please put null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostRequiredStringParameterAsync(string bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostRequiredStringParameterAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required string. Please put null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostRequiredStringParameter(string bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostRequiredStringParameter(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional string. Please put null. </summary>
|
||||
/// <param name="bodyParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostOptionalStringParameterAsync(string bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostOptionalStringParameterAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional string. Please put null. </summary>
|
||||
/// <param name="bodyParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostOptionalStringParameter(string bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostOptionalStringParameter(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required string. Please put a valid string-wrapper with 'value' = null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The StringWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostRequiredStringPropertyAsync(StringWrapper bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostRequiredStringPropertyAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required string. Please put a valid string-wrapper with 'value' = null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The StringWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostRequiredStringProperty(StringWrapper bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostRequiredStringProperty(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional integer. Please put a valid string-wrapper with 'value' = null. </summary>
|
||||
/// <param name="bodyParameter"> The StringOptionalWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostOptionalStringPropertyAsync(StringOptionalWrapper bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostOptionalStringPropertyAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional integer. Please put a valid string-wrapper with 'value' = null. </summary>
|
||||
/// <param name="bodyParameter"> The StringOptionalWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostOptionalStringProperty(StringOptionalWrapper bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostOptionalStringProperty(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required string. Please put a header 'headerParameter' => null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="headerParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostRequiredStringHeaderAsync(string headerParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostRequiredStringHeaderAsync(headerParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required string. Please put a header 'headerParameter' => null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="headerParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostRequiredStringHeader(string headerParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostRequiredStringHeader(headerParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional string. Please put a header 'headerParameter' => null. </summary>
|
||||
/// <param name="bodyParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostOptionalStringHeaderAsync(string bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostOptionalStringHeaderAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional string. Please put a header 'headerParameter' => null. </summary>
|
||||
/// <param name="bodyParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostOptionalStringHeader(string bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostOptionalStringHeader(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required complex object. Please put null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The Product to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostRequiredClassParameterAsync(Product bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostRequiredClassParameterAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required complex object. Please put null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The Product to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostRequiredClassParameter(Product bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostRequiredClassParameter(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional complex object. Please put null. </summary>
|
||||
/// <param name="bodyParameter"> The Product to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostOptionalClassParameterAsync(Product bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostOptionalClassParameterAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional complex object. Please put null. </summary>
|
||||
/// <param name="bodyParameter"> The Product to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostOptionalClassParameter(Product bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostOptionalClassParameter(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required complex object. Please put a valid class-wrapper with 'value' = null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The ClassWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostRequiredClassPropertyAsync(ClassWrapper bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostRequiredClassPropertyAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required complex object. Please put a valid class-wrapper with 'value' = null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The ClassWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostRequiredClassProperty(ClassWrapper bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostRequiredClassProperty(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional complex object. Please put a valid class-wrapper with 'value' = null. </summary>
|
||||
/// <param name="bodyParameter"> The ClassOptionalWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostOptionalClassPropertyAsync(ClassOptionalWrapper bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostOptionalClassPropertyAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional complex object. Please put a valid class-wrapper with 'value' = null. </summary>
|
||||
/// <param name="bodyParameter"> The ClassOptionalWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostOptionalClassProperty(ClassOptionalWrapper bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostOptionalClassProperty(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required array. Please put null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The ArrayOfPostContentSchemaItem to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostRequiredArrayParameterAsync(IEnumerable<string> bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostRequiredArrayParameterAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required array. Please put null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The ArrayOfPostContentSchemaItem to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostRequiredArrayParameter(IEnumerable<string> bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostRequiredArrayParameter(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional array. Please put null. </summary>
|
||||
/// <param name="bodyParameter"> The ArrayOfString to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostOptionalArrayParameterAsync(IEnumerable<string> bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostOptionalArrayParameterAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional array. Please put null. </summary>
|
||||
/// <param name="bodyParameter"> The ArrayOfString to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostOptionalArrayParameter(IEnumerable<string> bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostOptionalArrayParameter(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required array. Please put a valid array-wrapper with 'value' = null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The ArrayWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostRequiredArrayPropertyAsync(ArrayWrapper bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostRequiredArrayPropertyAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required array. Please put a valid array-wrapper with 'value' = null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="bodyParameter"> The ArrayWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostRequiredArrayProperty(ArrayWrapper bodyParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostRequiredArrayProperty(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional array. Please put a valid array-wrapper with 'value' = null. </summary>
|
||||
/// <param name="bodyParameter"> The ArrayOptionalWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostOptionalArrayPropertyAsync(ArrayOptionalWrapper bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostOptionalArrayPropertyAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional array. Please put a valid array-wrapper with 'value' = null. </summary>
|
||||
/// <param name="bodyParameter"> The ArrayOptionalWrapper to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostOptionalArrayProperty(ArrayOptionalWrapper bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostOptionalArrayProperty(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required array. Please put a header 'headerParameter' => null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="headerParameter"> The ArrayOfPost0ItemsItem to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostRequiredArrayHeaderAsync(IEnumerable<string> headerParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostRequiredArrayHeaderAsync(headerParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly required array. Please put a header 'headerParameter' => null and the client library should throw before the request is sent. </summary>
|
||||
/// <param name="headerParameter"> The ArrayOfPost0ItemsItem to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostRequiredArrayHeader(IEnumerable<string> headerParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostRequiredArrayHeader(headerParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional integer. Please put a header 'headerParameter' => null. </summary>
|
||||
/// <param name="headerParameter"> The ArrayOfString to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PostOptionalArrayHeaderAsync(IEnumerable<string> headerParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PostOptionalArrayHeaderAsync(headerParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test explicitly optional integer. Please put a header 'headerParameter' => null. </summary>
|
||||
/// <param name="headerParameter"> The ArrayOfString to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PostOptionalArrayHeader(IEnumerable<string> headerParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PostOptionalArrayHeader(headerParameter, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
1649
test/TestServerProjects/required-optional/Generated/Operations/ExplicitRestClient.cs
сгенерированный
Normal file
1649
test/TestServerProjects/required-optional/Generated/Operations/ExplicitRestClient.cs
сгенерированный
Normal file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
138
test/TestServerProjects/required-optional/Generated/Operations/ImplicitClient.cs
сгенерированный
Normal file
138
test/TestServerProjects/required-optional/Generated/Operations/ImplicitClient.cs
сгенерированный
Normal file
|
@ -0,0 +1,138 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Azure;
|
||||
using Azure.Core.Pipeline;
|
||||
|
||||
namespace required_optional
|
||||
{
|
||||
public partial class ImplicitClient
|
||||
{
|
||||
private readonly ClientDiagnostics clientDiagnostics;
|
||||
private readonly HttpPipeline pipeline;
|
||||
internal ImplicitRestClient RestClient { get; }
|
||||
/// <summary> Initializes a new instance of ImplicitClient for mocking. </summary>
|
||||
protected ImplicitClient()
|
||||
{
|
||||
}
|
||||
/// <summary> Initializes a new instance of ImplicitClient. </summary>
|
||||
internal ImplicitClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string requiredGlobalPath, string requiredGlobalQuery, string host = "http://localhost:3000", int? optionalGlobalQuery = null)
|
||||
{
|
||||
RestClient = new ImplicitRestClient(clientDiagnostics, pipeline, requiredGlobalPath, requiredGlobalQuery, host, optionalGlobalQuery);
|
||||
this.clientDiagnostics = clientDiagnostics;
|
||||
this.pipeline = pipeline;
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly required path parameter. </summary>
|
||||
/// <param name="pathParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> GetRequiredPathAsync(string pathParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.GetRequiredPathAsync(pathParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly required path parameter. </summary>
|
||||
/// <param name="pathParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response GetRequiredPath(string pathParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.GetRequiredPath(pathParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional query parameter. </summary>
|
||||
/// <param name="queryParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PutOptionalQueryAsync(string queryParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PutOptionalQueryAsync(queryParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional query parameter. </summary>
|
||||
/// <param name="queryParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PutOptionalQuery(string queryParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PutOptionalQuery(queryParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional header parameter. </summary>
|
||||
/// <param name="queryParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PutOptionalHeaderAsync(string queryParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PutOptionalHeaderAsync(queryParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional header parameter. </summary>
|
||||
/// <param name="queryParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PutOptionalHeader(string queryParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PutOptionalHeader(queryParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional body parameter. </summary>
|
||||
/// <param name="bodyParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> PutOptionalBodyAsync(string bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PutOptionalBodyAsync(bodyParameter, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional body parameter. </summary>
|
||||
/// <param name="bodyParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response PutOptionalBody(string bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PutOptionalBody(bodyParameter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly required path parameter. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> GetRequiredGlobalPathAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.GetRequiredGlobalPathAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly required path parameter. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response GetRequiredGlobalPath(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.GetRequiredGlobalPath(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly required query parameter. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> GetRequiredGlobalQueryAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.GetRequiredGlobalQueryAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly required query parameter. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response GetRequiredGlobalQuery(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.GetRequiredGlobalQuery(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional query parameter. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response> GetOptionalGlobalQueryAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.GetOptionalGlobalQueryAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional query parameter. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response GetOptionalGlobalQuery(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.GetOptionalGlobalQuery(cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
524
test/TestServerProjects/required-optional/Generated/Operations/ImplicitRestClient.cs
сгенерированный
Normal file
524
test/TestServerProjects/required-optional/Generated/Operations/ImplicitRestClient.cs
сгенерированный
Normal file
|
@ -0,0 +1,524 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Azure;
|
||||
using Azure.Core;
|
||||
using Azure.Core.Pipeline;
|
||||
|
||||
namespace required_optional
|
||||
{
|
||||
internal partial class ImplicitRestClient
|
||||
{
|
||||
private string requiredGlobalPath;
|
||||
private string requiredGlobalQuery;
|
||||
private string host;
|
||||
private int? optionalGlobalQuery;
|
||||
private ClientDiagnostics clientDiagnostics;
|
||||
private HttpPipeline pipeline;
|
||||
|
||||
/// <summary> Initializes a new instance of ImplicitRestClient. </summary>
|
||||
public ImplicitRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string requiredGlobalPath, string requiredGlobalQuery, string host = "http://localhost:3000", int? optionalGlobalQuery = null)
|
||||
{
|
||||
if (requiredGlobalPath == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(requiredGlobalPath));
|
||||
}
|
||||
if (requiredGlobalQuery == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(requiredGlobalQuery));
|
||||
}
|
||||
if (host == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(host));
|
||||
}
|
||||
|
||||
this.requiredGlobalPath = requiredGlobalPath;
|
||||
this.requiredGlobalQuery = requiredGlobalQuery;
|
||||
this.host = host;
|
||||
this.optionalGlobalQuery = optionalGlobalQuery;
|
||||
this.clientDiagnostics = clientDiagnostics;
|
||||
this.pipeline = pipeline;
|
||||
}
|
||||
|
||||
internal HttpMessage CreateGetRequiredPathRequest(string pathParameter)
|
||||
{
|
||||
var message = pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Get;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/reqopt/implicit/required/path/", false);
|
||||
uri.AppendPath(pathParameter, true);
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly required path parameter. </summary>
|
||||
/// <param name="pathParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response> GetRequiredPathAsync(string pathParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (pathParameter == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(pathParameter));
|
||||
}
|
||||
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.GetRequiredPath");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetRequiredPathRequest(pathParameter);
|
||||
await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly required path parameter. </summary>
|
||||
/// <param name="pathParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response GetRequiredPath(string pathParameter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (pathParameter == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(pathParameter));
|
||||
}
|
||||
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.GetRequiredPath");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetRequiredPathRequest(pathParameter);
|
||||
pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreatePutOptionalQueryRequest(string queryParameter)
|
||||
{
|
||||
var message = pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Put;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/reqopt/implicit/optional/query", false);
|
||||
if (queryParameter != null)
|
||||
{
|
||||
uri.AppendQuery("queryParameter", queryParameter, true);
|
||||
}
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional query parameter. </summary>
|
||||
/// <param name="queryParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response> PutOptionalQueryAsync(string queryParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.PutOptionalQuery");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutOptionalQueryRequest(queryParameter);
|
||||
await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional query parameter. </summary>
|
||||
/// <param name="queryParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response PutOptionalQuery(string queryParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.PutOptionalQuery");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutOptionalQueryRequest(queryParameter);
|
||||
pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreatePutOptionalHeaderRequest(string queryParameter)
|
||||
{
|
||||
var message = pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Put;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/reqopt/implicit/optional/header", false);
|
||||
request.Uri = uri;
|
||||
if (queryParameter != null)
|
||||
{
|
||||
request.Headers.Add("queryParameter", queryParameter);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional header parameter. </summary>
|
||||
/// <param name="queryParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response> PutOptionalHeaderAsync(string queryParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.PutOptionalHeader");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutOptionalHeaderRequest(queryParameter);
|
||||
await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional header parameter. </summary>
|
||||
/// <param name="queryParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response PutOptionalHeader(string queryParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.PutOptionalHeader");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutOptionalHeaderRequest(queryParameter);
|
||||
pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreatePutOptionalBodyRequest(string bodyParameter)
|
||||
{
|
||||
var message = pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Put;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/reqopt/implicit/optional/body", false);
|
||||
request.Uri = uri;
|
||||
request.Headers.Add("Content-Type", "application/json");
|
||||
if (bodyParameter != null)
|
||||
{
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
content.JsonWriter.WriteStringValue(bodyParameter);
|
||||
request.Content = content;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional body parameter. </summary>
|
||||
/// <param name="bodyParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response> PutOptionalBodyAsync(string bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.PutOptionalBody");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutOptionalBodyRequest(bodyParameter);
|
||||
await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional body parameter. </summary>
|
||||
/// <param name="bodyParameter"> The String to use. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response PutOptionalBody(string bodyParameter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.PutOptionalBody");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutOptionalBodyRequest(bodyParameter);
|
||||
pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreateGetRequiredGlobalPathRequest()
|
||||
{
|
||||
var message = pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Get;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/reqopt/global/required/path/", false);
|
||||
uri.AppendPath(requiredGlobalPath, true);
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly required path parameter. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response> GetRequiredGlobalPathAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.GetRequiredGlobalPath");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetRequiredGlobalPathRequest();
|
||||
await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly required path parameter. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response GetRequiredGlobalPath(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.GetRequiredGlobalPath");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetRequiredGlobalPathRequest();
|
||||
pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreateGetRequiredGlobalQueryRequest()
|
||||
{
|
||||
var message = pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Get;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/reqopt/global/required/query", false);
|
||||
uri.AppendQuery("required-global-query", requiredGlobalQuery, true);
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly required query parameter. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response> GetRequiredGlobalQueryAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.GetRequiredGlobalQuery");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetRequiredGlobalQueryRequest();
|
||||
await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly required query parameter. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response GetRequiredGlobalQuery(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.GetRequiredGlobalQuery");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetRequiredGlobalQueryRequest();
|
||||
pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreateGetOptionalGlobalQueryRequest()
|
||||
{
|
||||
var message = pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Get;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/reqopt/global/optional/query", false);
|
||||
if (optionalGlobalQuery != null)
|
||||
{
|
||||
uri.AppendQuery("optional-global-query", optionalGlobalQuery.Value, true);
|
||||
}
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional query parameter. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response> GetOptionalGlobalQueryAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.GetOptionalGlobalQuery");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetOptionalGlobalQueryRequest();
|
||||
await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw await clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Test implicitly optional query parameter. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response GetOptionalGlobalQuery(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("ImplicitClient.GetOptionalGlobalQuery");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetOptionalGlobalQueryRequest();
|
||||
pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
return message.Response;
|
||||
default:
|
||||
throw clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Nullable>annotations</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Azure.Core" Version="1.1.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Загрузка…
Ссылка в новой задаче