Cleanup JSON serialization even more (#364)

This commit is contained in:
Pavel Krymets 2019-12-18 15:51:47 -08:00 коммит произвёл GitHub
Родитель 214d235fdb
Коммит 577f6beef0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
27 изменённых файлов: 260 добавлений и 339 удалений

Просмотреть файл

@ -113,11 +113,15 @@ namespace AutoRest.CSharp.V3.CodeGen
if (operation.Request.Body is RequestBody body)
{
writer.Line($"using var content = new {writer.Type(typeof(Utf8JsonRequestContent))}();");
writer.Line($"var writer = content.{nameof(Utf8JsonRequestContent.JsonWriter)};");
ConstantOrParameter value = body.Value;
writer.ToSerializeCall(value.Type, body.Format, _typeFactory, w => WriteConstantOrParameter(w, value));
writer.ToSerializeCall(
value.Type,
body.Format,
_typeFactory,
w => WriteConstantOrParameter(w, value),
writerName: w => w.Append($"content.{nameof(Utf8JsonRequestContent.JsonWriter)}"));
writer.Line($"request.Content = content;");
}
@ -144,13 +148,8 @@ namespace AutoRest.CSharp.V3.CodeGen
}
else
{
writer.AppendRaw(constantOrParameter.Parameter.Name);
var type = _typeFactory.CreateType(constantOrParameter.Type);
if (type.IsNullable && type.IsValueType)
{
writer.Append($".Value");
}
writer.AppendRaw(constantOrParameter.Parameter.Name)
.AppendNullableValue(_typeFactory.CreateType(constantOrParameter.Type));
}
}

Просмотреть файл

@ -320,13 +320,6 @@ namespace AutoRest.CSharp.V3.CodeGen
public override string? ToString() => _builder.ToString();
public static string Materialize(CodeWriterDelegate writer)
{
var codeWriter = new CodeWriter();
writer(codeWriter);
return codeWriter._builder.ToString();
}
internal readonly struct CodeWriterScope : IDisposable
{
private readonly CodeWriter _writer;

Просмотреть файл

@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.CodeGen
{
internal static class CodeWriterExtensions
{
public static CodeWriter AppendNullableValue(this CodeWriter writer, CSharpType type)
{
if (type.IsNullable && type.IsValueType)
{
writer.Append($".Value");
}
return writer;
}
}
}

Просмотреть файл

@ -2,239 +2,150 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using AutoRest.CSharp.V3.ClientModels;
namespace AutoRest.CSharp.V3.CodeGen
{
internal static class JsonSerializerExtensions
{
private static readonly Func<string, bool, SerializationFormat, string?> NumberSerializer =
(vn, nu, f) => $"writer.WriteNumberValue({vn}{(nu ? ".Value" : string.Empty)});";
private static Func<string, bool, SerializationFormat, string?> StringSerializer(bool includeToString = false) =>
(vn, nu, f) => $"writer.WriteStringValue({vn}{(includeToString ? ".ToString()" : string.Empty)});";
public static string? ToFormatSpecifier(this SerializationFormat format) => format switch
public static void ToSerializeCall(this CodeWriter writer, ClientTypeReference type, SerializationFormat format, TypeFactory typeFactory, CodeWriterDelegate name, CodeWriterDelegate? serializedName = null, CodeWriterDelegate? writerName = null)
{
SerializationFormat.DateTime_RFC1123 => "R",
SerializationFormat.DateTime_ISO8601 => "S",
SerializationFormat.Date_ISO8601 => "D",
SerializationFormat.DateTime_Unix => "U",
SerializationFormat.Duration_ISO8601 => "P",
_ => null
};
private static readonly Func<string, bool, SerializationFormat, string?> FormatSerializer = (vn, nu, f) =>
{
var formatSpecifier = f.ToFormatSpecifier();
var valueText = $"{vn}{(nu ? ".Value" : string.Empty)}";
var formatText = formatSpecifier != null ? $", \"{formatSpecifier}\"" : string.Empty;
return $"writer.WriteStringValue({valueText}{formatText});";
};
//TODO: Do this by AllSchemaTypes so things like Date versus DateTime can be serialized properly.
private static readonly Dictionary<Type, Func<string, bool, SerializationFormat, string?>> TypeSerializers = new Dictionary<Type, Func<string, bool, SerializationFormat, string?>>
{
{ typeof(bool), (vn, nu, f) => $"writer.WriteBooleanValue({vn}{(nu ? ".Value" : string.Empty)});" },
{ typeof(object), (vn, nu, f) => $"writer.WriteObjectValue({vn});" },
{ typeof(char), StringSerializer() },
{ typeof(short), NumberSerializer },
{ typeof(int), NumberSerializer },
{ typeof(long), NumberSerializer },
{ typeof(float), NumberSerializer },
{ typeof(double), NumberSerializer },
{ typeof(decimal), NumberSerializer },
{ typeof(string), StringSerializer() },
{ typeof(byte[]), (vn, nu, f) => null },
{ typeof(DateTimeOffset), FormatSerializer },
{ typeof(TimeSpan), FormatSerializer },
{ typeof(Uri), StringSerializer(true) }
};
private static Func<string, SerializationFormat, string?>? FormatDeserializer(string typeName) => (n, f) =>
{
var formatSpecifier = f.ToFormatSpecifier();
return formatSpecifier != null ? $"{n}.Get{typeName}(\"{formatSpecifier}\")" : null;
};
private static readonly Dictionary<Type, Func<string, SerializationFormat, string?>> TypeDeserializers = new Dictionary<Type, Func<string, SerializationFormat, string?>>
{
{ typeof(object), (n, f) => $"{n}.GetObject()" },
{ typeof(bool), (n, f) => $"{n}.GetBoolean()" },
{ typeof(char), (n, f) => $"{n}.GetString()" },
{ typeof(short), (n, f) => $"{n}.GetInt16()" },
{ typeof(int), (n, f) => $"{n}.GetInt32()" },
{ typeof(long), (n, f) => $"{n}.GetInt64()" },
{ typeof(float), (n, f) => $"{n}.GetSingle()" },
{ typeof(double), (n, f) => $"{n}.GetDouble()" },
{ typeof(decimal), (n, f) => $"{n}.GetDecimal()" },
{ typeof(string), (n, f) => $"{n}.GetString()" },
{ typeof(DateTimeOffset), FormatDeserializer(nameof(DateTimeOffset)) ?? ((n, f) => $"{n}.GetDateTimeOffset()") },
{ typeof(TimeSpan), FormatDeserializer(nameof(TimeSpan)) ?? ((n, f) => $"TimeSpan.Parse({n}.GetString())") },
{ typeof(Uri), (n, f) => null } //TODO: Figure out how to get the Uri type here, so we can do 'new Uri(GetString())'
};
private static void WriteSerializeClientObject(CodeWriter writer, CodeWriterDelegate name)
{
writer.Line($"writer.WriteObjectValue({name});");
}
private static void WriteSerializeClientEnum(CodeWriter writer, CodeWriterDelegate name, bool isNullable, bool isStringBased)
{
writer.Append($"writer.WriteStringValue({name}");
if (!isStringBased && isNullable)
{
writer.Append($".Value");
}
writer.AppendRaw(isStringBased ? ".ToString()" : ".ToSerialString()");
writer.Line($");");
}
private static void WriteSerializeSchemaTypeReference(CodeWriter writer, SchemaTypeReference type, TypeFactory typeFactory, CodeWriterDelegate name)
{
switch (typeFactory.ResolveReference(type))
{
case ClientObject _:
WriteSerializeClientObject(writer, name);
return;
case ClientEnum clientEnum:
WriteSerializeClientEnum(writer, name, type.IsNullable, clientEnum.IsStringBased);
return;
default:
writer.Line($"// Serialization of this type is not supported");
return;
}
}
private static void WriteSerializeBinaryTypeReference(CodeWriter writer, CodeWriterDelegate name)
{
writer.Line($"writer.WriteBase64StringValue({name});");
}
private static void WriteSerializeDefault(CodeWriter writer, ClientTypeReference type, SerializationFormat format, TypeFactory typeFactory, CodeWriterDelegate name)
{
var frameworkType = typeFactory.CreateType(type)?.FrameworkType ?? typeof(void);
writer.LineRaw(TypeSerializers[frameworkType](CodeWriter.Materialize(name), type.IsNullable, format) ?? "writer.WriteNullValue();");
}
public static void ToSerializeCall(this CodeWriter writer, ClientTypeReference type, SerializationFormat format, TypeFactory typeFactory, CodeWriterDelegate name, CodeWriterDelegate? serializedName = null)
{
// TODO: remove when serialization uses the full writer
writer.UseNamespace(new CSharpNamespace("Azure.Core"));
writerName ??= w => w.AppendRaw("writer");
if (serializedName != null)
{
writer.Line($"writer.WritePropertyName({serializedName});");
writer.Line($"{writerName}.WritePropertyName({serializedName});");
}
CSharpType implementationType = typeFactory.CreateType(type);
switch (type)
{
case CollectionTypeReference array:
{
writer.Line($"writer.WriteStartArray();");
using (writer.ForEach($"var item in {CodeWriter.Materialize(name)}"))
writer.Line($"{writerName}.WriteStartArray();");
writer.Line($"foreach (var item in {name})");
using (writer.Scope())
{
writer.ToSerializeCall(array.ItemType, format, typeFactory, w => w.Append($"item"));
}
writer.Line($"writer.WriteEndArray();");
writer.Line($"{writerName}.WriteEndArray();");
return;
}
case DictionaryTypeReference dictionary:
{
writer.Line($"writer.WriteStartObject();");
using (writer.ForEach($"var item in {CodeWriter.Materialize(name)}"))
writer.Line($"{writerName}.WriteStartObject();");
writer.Line($"foreach (var item in {name})");
using (writer.Scope())
{
writer.ToSerializeCall(dictionary.ValueType, format, typeFactory, w => w.Append($"item.Value"), w => w.Append($"item.Key"));
writer.ToSerializeCall(
dictionary.ValueType,
format,
typeFactory,
w => w.Append($"item.Value"),
w => w.Append($"item.Key"));
}
writer.Line($"writer.WriteEndObject();");
writer.Line($"{writerName}.WriteEndObject();");
return;
}
case SchemaTypeReference schemaTypeReference:
WriteSerializeSchemaTypeReference(writer, schemaTypeReference, typeFactory, name);
switch (typeFactory.ResolveReference(schemaTypeReference))
{
case ClientObject _:
writer.Line($"{writerName}.WriteObjectValue({name});");
return;
case ClientEnum clientEnum:
writer.Append($"{writerName}.WriteStringValue({name}")
.AppendNullableValue(implementationType)
.AppendRaw(clientEnum.IsStringBased ? ".ToString()" : ".ToSerialString()")
.Line($");");
return;
}
return;
case BinaryTypeReference _:
WriteSerializeBinaryTypeReference(writer, name);
writer.Line($"{writerName}.WriteBase64StringValue({name});");
return;
default:
WriteSerializeDefault(writer, type, format, typeFactory, name);
case FrameworkTypeReference frameworkTypeReference:
var frameworkType = frameworkTypeReference.Type;
bool writeFormat = false;
writer.Append($"{writerName}.");
if (frameworkType == typeof(decimal) ||
frameworkType == typeof(double) ||
frameworkType == typeof(float) ||
frameworkType == typeof(long) ||
frameworkType == typeof(int) ||
frameworkType == typeof(short))
{
writer.AppendRaw("WriteNumberValue");
}
else if (frameworkType == typeof(object))
{
writer.AppendRaw("WriteObjectValue");
}
else if (frameworkType == typeof(string) ||
frameworkType == typeof(char))
{
writer.AppendRaw("WriteStringValue");
}
else if (frameworkType == typeof(bool))
{
writer.AppendRaw("WriteBooleanValue");
}
else if (frameworkType == typeof(DateTimeOffset) ||
frameworkType == typeof(DateTime) ||
frameworkType == typeof(TimeSpan))
{
writer.AppendRaw("WriteStringValue");
writeFormat = true;
}
writer.Append($"({name}")
.AppendNullableValue(implementationType);
if (writeFormat && format.ToFormatSpecifier() is string formatString)
{
writer.Append($", {formatString:L}");
}
writer.LineRaw(");");
return;
}
}
private static void WriteDeserializeClientObject(CodeWriter writer, CSharpType cSharpType, CodeWriterDelegate name)
{
writer.Append($"{cSharpType}.Deserialize{cSharpType.Name}({name})");
}
private static void WriteDeserializeClientEnum(CodeWriter writer, CSharpType cSharpType, CodeWriterDelegate name, bool isStringBased)
{
if (isStringBased)
{
writer.Append($"new {cSharpType}({name}.GetString())");
return;
}
writer.Append($"{name}.GetString().To{cSharpType}()");
}
private static void WriteDeserializeSchemaTypeReference(CodeWriter writer, CSharpType cSharpType, SchemaTypeReference type, TypeFactory typeFactory, CodeWriterDelegate name)
{
switch (typeFactory.ResolveReference(type))
{
case ClientObject _:
WriteDeserializeClientObject(writer, cSharpType, name);
return;
case ClientEnum clientEnum:
WriteDeserializeClientEnum(writer, cSharpType, name, clientEnum.IsStringBased);
return;
default:
writer.Append($"/* Deserialization of this type is not supported */");
return;
}
}
private static void WriteDeserializeBinaryTypeReference(CodeWriter writer, CodeWriterDelegate name)
{
writer.Append($"{name}.GetBytesFromBase64()");
}
private static void WriteDeserializeDefault(CodeWriter writer, CSharpType cSharpType, SerializationFormat format, CodeWriterDelegate name)
{
var frameworkType = cSharpType?.FrameworkType ?? typeof(void);
writer.AppendRaw(TypeDeserializers[frameworkType](CodeWriter.Materialize(name), format) ?? "null");
}
public static void ToDeserializeCall(this CodeWriter writer, ClientTypeReference type, SerializationFormat format, TypeFactory typeFactory, CodeWriterDelegate destination, CodeWriterDelegate element)
{
// TODO: remove when serialization uses the full writer
writer.UseNamespace(new CSharpNamespace("Azure.Core"));
switch (type)
{
case CollectionTypeReference array:
{
using (writer.ForEach("var item in property.Value.EnumerateArray()"))
{
writer.Append($"{destination}.Add(");
writer.ToDeserializeCall(array.ItemType, format, typeFactory, w => w.Append($"item"));
writer.ToDeserializeCall(
array.ItemType,
format,
typeFactory,
w => w.Append($"item"));
writer.Line($");");
}
return;
}
case DictionaryTypeReference dictionary:
{
using (writer.ForEach("var item in property.Value.EnumerateObject()"))
{
writer.Append($"{destination}.Add(item.Name, ");
writer.ToDeserializeCall(dictionary.ValueType, format, typeFactory, w => w.Append($"item.Value"));
writer.ToDeserializeCall(
dictionary.ValueType,
format,
typeFactory,
w => w.Append($"item.Value"));
writer.Line($");");
}
return;
}
}
writer.Append($"{destination} = ");
@ -249,15 +160,83 @@ namespace AutoRest.CSharp.V3.CodeGen
switch (type)
{
case SchemaTypeReference schemaTypeReference:
WriteDeserializeSchemaTypeReference(writer, cSharpType, schemaTypeReference, typeFactory, element);
switch (typeFactory.ResolveReference(schemaTypeReference))
{
case ClientObject _:
writer.Append($"{cSharpType}.Deserialize{cSharpType.Name}({element})");
break;
case ClientEnum clientEnum when clientEnum.IsStringBased:
writer.Append($"new {cSharpType}({element}.GetString())");
break;
case ClientEnum clientEnum when !clientEnum.IsStringBased:
writer.Append($"{element}.GetString().To{cSharpType}()");
break;
}
return;
case BinaryTypeReference _:
WriteDeserializeBinaryTypeReference(writer, element);
writer.Append($"{element}.GetBytesFromBase64()");
return;
default:
WriteDeserializeDefault(writer, cSharpType, format, element);
case FrameworkTypeReference frameworkTypeReference:
bool includeFormat = false;
var frameworkType = frameworkTypeReference.Type;
writer.Append($"{element}.");
if (frameworkType == typeof(object))
writer.AppendRaw("GetObject");
if (frameworkType == typeof(bool))
writer.AppendRaw("GetBoolean");
if (frameworkType == typeof(char))
writer.AppendRaw("GetString");
if (frameworkType == typeof(short))
writer.AppendRaw("GetInt16");
if (frameworkType == typeof(int))
writer.AppendRaw("GetInt32");
if (frameworkType == typeof(long))
writer.AppendRaw("GetInt64");
if (frameworkType == typeof(float))
writer.AppendRaw("GetSingle");
if (frameworkType == typeof(double))
writer.AppendRaw("GetDouble");
if (frameworkType == typeof(decimal))
writer.AppendRaw("GetDecimal");
if (frameworkType == typeof(string))
writer.AppendRaw("GetString");
if (frameworkType == typeof(DateTimeOffset))
{
writer.AppendRaw("GetDateTimeOffset");
includeFormat = true;
}
if (frameworkType == typeof(TimeSpan))
{
writer.AppendRaw("GetTimeSpan");
includeFormat = true;
}
writer.AppendRaw("(");
if (includeFormat && format.ToFormatSpecifier() is string formatString)
{
writer.Literal(formatString);
}
writer.AppendRaw(")");
return;
}
}
public static string? ToFormatSpecifier(this SerializationFormat format) => format switch
{
SerializationFormat.DateTime_RFC1123 => "R",
SerializationFormat.DateTime_ISO8601 => "S",
SerializationFormat.Date_ISO8601 => "D",
SerializationFormat.DateTime_Unix => "U",
SerializationFormat.Duration_ISO8601 => "P",
_ => null
};
}
}

Просмотреть файл

@ -35,8 +35,7 @@ namespace additionalProperties
request.Uri.AppendPath("/additionalProperties/true", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(createParameters);
content.JsonWriter.WriteObjectValue(createParameters);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -78,8 +77,7 @@ namespace additionalProperties
request.Uri.AppendPath("/additionalProperties/true-subclass", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(createParameters);
content.JsonWriter.WriteObjectValue(createParameters);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -121,8 +119,7 @@ namespace additionalProperties
request.Uri.AppendPath("/additionalProperties/type/object", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(createParameters);
content.JsonWriter.WriteObjectValue(createParameters);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -164,8 +161,7 @@ namespace additionalProperties
request.Uri.AppendPath("/additionalProperties/type/string", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(createParameters);
content.JsonWriter.WriteObjectValue(createParameters);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -207,8 +203,7 @@ namespace additionalProperties
request.Uri.AppendPath("/additionalProperties/in/properties", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(createParameters);
content.JsonWriter.WriteObjectValue(createParameters);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -250,8 +245,7 @@ namespace additionalProperties
request.Uri.AppendPath("/additionalProperties/in/properties/with/additionalProperties/string", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(createParameters);
content.JsonWriter.WriteObjectValue(createParameters);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -64,8 +64,7 @@ namespace body_boolean
request.Uri.AppendPath("/bool/true", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteBooleanValue(true);
content.JsonWriter.WriteBooleanValue(true);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -133,8 +132,7 @@ namespace body_boolean
request.Uri.AppendPath("/bool/false", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteBooleanValue(false);
content.JsonWriter.WriteBooleanValue(false);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -24,7 +24,7 @@ namespace body_complex.Models.V20160229
if (Color != null)
{
writer.WritePropertyName("color");
writer.WriteStringValue(Color.ToString());
writer.WriteStringValue(Color.Value.ToString());
}
writer.WriteEndObject();
}

Просмотреть файл

@ -20,7 +20,7 @@ namespace body_complex.Models.V20160229
if (Color != null)
{
writer.WritePropertyName("color");
writer.WriteStringValue(Color.ToString());
writer.WriteStringValue(Color.Value.ToString());
}
if (Age != null)
{

Просмотреть файл

@ -69,8 +69,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/array/valid", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -142,8 +141,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/array/empty", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -70,8 +70,7 @@ namespace body_complex
request.Headers.Add("Content-Type", "application/json");
request.Uri.AppendQuery("api-version", "2016-02-29", true);
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -69,8 +69,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/dictionary/typed/valid", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -142,8 +141,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/dictionary/typed/empty", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -69,8 +69,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/inheritance/valid", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -69,8 +69,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/polymorphicrecursive/valid", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -69,8 +69,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/polymorphism/valid", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -244,8 +243,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/polymorphism/complicated", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -283,8 +281,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/polymorphism/missingdiscriminator", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -326,8 +323,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/polymorphism/missingrequired/invalid", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -69,8 +69,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/primitive/integer", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -142,8 +141,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/primitive/long", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -215,8 +213,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/primitive/float", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -288,8 +285,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/primitive/double", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -361,8 +357,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/primitive/bool", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -434,8 +429,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/primitive/string", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -507,8 +501,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/primitive/date", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -580,8 +573,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/primitive/datetime", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -653,8 +645,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/primitive/datetimerfc1123", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -726,8 +717,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/primitive/duration", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -799,8 +789,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/primitive/byte", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -69,8 +69,7 @@ namespace body_complex
request.Uri.AppendPath("/complex/readonlyproperty/valid", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(complexBody);
content.JsonWriter.WriteObjectValue(complexBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -166,8 +166,7 @@ namespace body_date
request.Uri.AppendPath("/date/max", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(dateBody, "D");
content.JsonWriter.WriteStringValue(dateBody, "D");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -235,8 +234,7 @@ namespace body_date
request.Uri.AppendPath("/date/min", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(dateBody, "D");
content.JsonWriter.WriteStringValue(dateBody, "D");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -166,8 +166,7 @@ namespace body_datetime_rfc1123
request.Uri.AppendPath("/datetimerfc1123/max", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(datetimeBody, "R");
content.JsonWriter.WriteStringValue(datetimeBody, "R");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -269,8 +268,7 @@ namespace body_datetime_rfc1123
request.Uri.AppendPath("/datetimerfc1123/min", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(datetimeBody, "R");
content.JsonWriter.WriteStringValue(datetimeBody, "R");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -166,8 +166,7 @@ namespace body_datetime
request.Uri.AppendPath("/datetime/max/utc", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(datetimeBody, "S");
content.JsonWriter.WriteStringValue(datetimeBody, "S");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -269,8 +268,7 @@ namespace body_datetime
request.Uri.AppendPath("/datetime/max/localpositiveoffset", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(datetimeBody, "S");
content.JsonWriter.WriteStringValue(datetimeBody, "S");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -372,8 +370,7 @@ namespace body_datetime
request.Uri.AppendPath("/datetime/max/localnegativeoffset", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(datetimeBody, "S");
content.JsonWriter.WriteStringValue(datetimeBody, "S");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -475,8 +472,7 @@ namespace body_datetime
request.Uri.AppendPath("/datetime/min/utc", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(datetimeBody, "S");
content.JsonWriter.WriteStringValue(datetimeBody, "S");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -544,8 +540,7 @@ namespace body_datetime
request.Uri.AppendPath("/datetime/min/localpositiveoffset", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(datetimeBody, "S");
content.JsonWriter.WriteStringValue(datetimeBody, "S");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -613,8 +608,7 @@ namespace body_datetime
request.Uri.AppendPath("/datetime/min/localnegativeoffset", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(datetimeBody, "S");
content.JsonWriter.WriteStringValue(datetimeBody, "S");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -64,8 +64,7 @@ namespace body_duration
request.Uri.AppendPath("/duration/positiveduration", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(durationBody, "P");
content.JsonWriter.WriteStringValue(durationBody, "P");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -234,8 +234,7 @@ namespace body_integer
request.Uri.AppendPath("/int/max/32", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(intBody);
content.JsonWriter.WriteNumberValue(intBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -269,8 +268,7 @@ namespace body_integer
request.Uri.AppendPath("/int/max/64", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(intBody);
content.JsonWriter.WriteNumberValue(intBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -304,8 +302,7 @@ namespace body_integer
request.Uri.AppendPath("/int/min/32", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(intBody);
content.JsonWriter.WriteNumberValue(intBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -339,8 +336,7 @@ namespace body_integer
request.Uri.AppendPath("/int/min/64", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(intBody);
content.JsonWriter.WriteNumberValue(intBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -408,8 +404,7 @@ namespace body_integer
request.Uri.AppendPath("/int/unixtime", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(intBody, "U");
content.JsonWriter.WriteStringValue(intBody, "U");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -166,8 +166,7 @@ namespace body_number
request.Uri.AppendPath("/number/big/float/3.402823e+20", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(numberBody);
content.JsonWriter.WriteNumberValue(numberBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -235,8 +234,7 @@ namespace body_number
request.Uri.AppendPath("/number/big/double/2.5976931e+101", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(numberBody);
content.JsonWriter.WriteNumberValue(numberBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -304,8 +302,7 @@ namespace body_number
request.Uri.AppendPath("/number/big/double/99999999.99", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(99999999.99);
content.JsonWriter.WriteNumberValue(99999999.99);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -373,8 +370,7 @@ namespace body_number
request.Uri.AppendPath("/number/big/double/-99999999.99", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(-99999999.99);
content.JsonWriter.WriteNumberValue(-99999999.99);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -442,8 +438,7 @@ namespace body_number
request.Uri.AppendPath("/number/big/decimal/2.5976931e+101", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(numberBody);
content.JsonWriter.WriteNumberValue(numberBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -511,8 +506,7 @@ namespace body_number
request.Uri.AppendPath("/number/big/decimal/99999999.99", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(99999999.99M);
content.JsonWriter.WriteNumberValue(99999999.99M);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -580,8 +574,7 @@ namespace body_number
request.Uri.AppendPath("/number/big/decimal/-99999999.99", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(-99999999.99M);
content.JsonWriter.WriteNumberValue(-99999999.99M);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -649,8 +642,7 @@ namespace body_number
request.Uri.AppendPath("/number/small/float/3.402823e-20", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(numberBody);
content.JsonWriter.WriteNumberValue(numberBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -718,8 +710,7 @@ namespace body_number
request.Uri.AppendPath("/number/small/double/2.5976931e-101", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(numberBody);
content.JsonWriter.WriteNumberValue(numberBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -787,8 +778,7 @@ namespace body_number
request.Uri.AppendPath("/number/small/decimal/2.5976931e-101", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteNumberValue(numberBody);
content.JsonWriter.WriteNumberValue(numberBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -65,8 +65,7 @@ namespace body_string
request.Uri.AppendPath("/string/enum/notExpandable", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(stringBody.ToSerialString());
content.JsonWriter.WriteStringValue(stringBody.ToSerialString());
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -134,8 +133,7 @@ namespace body_string
request.Uri.AppendPath("/string/enum/Referenced", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(enumStringBody.ToSerialString());
content.JsonWriter.WriteStringValue(enumStringBody.ToSerialString());
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -207,8 +205,7 @@ namespace body_string
request.Uri.AppendPath("/string/enum/ReferencedConstant", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(enumStringBody);
content.JsonWriter.WriteObjectValue(enumStringBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -64,8 +64,7 @@ namespace body_string
request.Uri.AppendPath("/string/null", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue((string?)null);
content.JsonWriter.WriteStringValue((string?)null);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -133,8 +132,7 @@ namespace body_string
request.Uri.AppendPath("/string/empty", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue("");
content.JsonWriter.WriteStringValue("");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -202,8 +200,7 @@ namespace body_string
request.Uri.AppendPath("/string/mbcs", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue("啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€");
content.JsonWriter.WriteStringValue("啊齄丂狛狜隣郎隣兀﨩ˊ〞〡¦℡㈱‐ー﹡﹢﹫、〓ⅰⅹ⒈€㈠㈩ⅠⅫ! ̄ぁんァヶΑ︴АЯаяāɡㄅㄩ─╋︵﹄︻︱︳︴ⅰⅹɑɡ〇〾⿻⺁䜣€");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -271,8 +268,7 @@ namespace body_string
request.Uri.AppendPath("/string/whitespace", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteStringValue(" Now is the time for all good men to come to the aid of their country ");
content.JsonWriter.WriteStringValue(" Now is the time for all good men to come to the aid of their country ");
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -412,8 +408,7 @@ namespace body_string
request.Uri.AppendPath("/string/base64UrlEncoding", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteBase64StringValue(stringBody);
content.JsonWriter.WriteBase64StringValue(stringBody);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -19,7 +19,7 @@ namespace extensible_enums_swagger.Models.V20160707
if (DaysOfWeek != null)
{
writer.WritePropertyName("DaysOfWeek");
writer.WriteStringValue(DaysOfWeek.ToString());
writer.WriteStringValue(DaysOfWeek.Value.ToString());
}
writer.WritePropertyName("IntEnum");
writer.WriteStringValue(IntEnum.ToString());

Просмотреть файл

@ -70,8 +70,7 @@ namespace extensible_enums_swagger
request.Uri.AppendPath("/extensibleenums/pet/addPet", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(petParam);
content.JsonWriter.WriteObjectValue(petParam);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)

Просмотреть файл

@ -93,8 +93,7 @@ namespace validation
request.Headers.Add("Content-Type", "application/json");
request.Uri.AppendQuery("apiVersion", "1.0.0", true);
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(body);
content.JsonWriter.WriteObjectValue(body);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)
@ -166,8 +165,7 @@ namespace validation
request.Uri.AppendPath("/value", false);
request.Headers.Add("Content-Type", "application/json");
using var content = new Utf8JsonRequestContent();
var writer = content.JsonWriter;
writer.WriteObjectValue(body);
content.JsonWriter.WriteObjectValue(body);
request.Content = content;
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
switch (response.Status)