Support additional properties (#358)
This commit is contained in:
Родитель
87e62f9d3d
Коммит
d5ff3b3915
|
@ -39,7 +39,7 @@ $configurationPath = Join-Path $testServerDirectory 'readme.tests.md'
|
|||
$testServerSwaggerPath = Join-Path $repoRoot 'node_modules' '@microsoft.azure' 'autorest.testserver' 'swagger'
|
||||
$testNames = if ($name) { $name } else
|
||||
{
|
||||
#'additionalProperties',
|
||||
'additionalProperties',
|
||||
#'azure-composite-swagger',
|
||||
#'azure-parameter-grouping',
|
||||
#'azure-report',
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using AutoRest.CSharp.V3.Pipeline;
|
||||
using AutoRest.CSharp.V3.Pipeline.Generated;
|
||||
|
||||
namespace AutoRest.CSharp.V3.ClientModels
|
||||
|
@ -63,6 +62,7 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
AllSchemaTypes.Unixtime => typeof(DateTimeOffset),
|
||||
AllSchemaTypes.Uri => typeof(Uri),
|
||||
AllSchemaTypes.Uuid => typeof(string),
|
||||
AllSchemaTypes.Any => typeof(object),
|
||||
_ => null
|
||||
};
|
||||
|
||||
|
|
|
@ -8,12 +8,13 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
{
|
||||
internal class ClientObject : ClientModel, ISchemaTypeProvider
|
||||
{
|
||||
public ClientObject(Schema schema, string name, SchemaTypeReference? inherits, IEnumerable<ClientObjectProperty> properties, IEnumerable<ClientObjectConstant> constants, ClientObjectDiscriminator? discriminator)
|
||||
public ClientObject(Schema schema, string name, SchemaTypeReference? inherits, IEnumerable<ClientObjectProperty> properties, ClientObjectDiscriminator? discriminator, DictionaryTypeReference? implementsDictionary)
|
||||
{
|
||||
Schema = schema;
|
||||
Name = name;
|
||||
Inherits = inherits;
|
||||
Discriminator = discriminator;
|
||||
ImplementsDictionary = implementsDictionary;
|
||||
Properties = new List<ClientObjectProperty>(properties);
|
||||
}
|
||||
|
||||
|
@ -22,5 +23,6 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
public SchemaTypeReference? Inherits { get; }
|
||||
public IList<ClientObjectProperty> Properties { get; }
|
||||
public ClientObjectDiscriminator? Discriminator { get; }
|
||||
public DictionaryTypeReference? ImplementsDictionary { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,11 +25,28 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
|
||||
private static ClientModel BuildClientObject(ObjectSchema objectSchema)
|
||||
{
|
||||
var inheritsFrom = objectSchema.Parents?.Immediate.OfType<ObjectSchema>().SingleOrDefault();
|
||||
var inheritsFromTypeReference = inheritsFrom != null ? ClientModelBuilderHelpers.CreateType(inheritsFrom, false) : null;
|
||||
ClientTypeReference? inheritsFromTypeReference = null;
|
||||
DictionaryTypeReference? dictionaryElementTypeReference = null;
|
||||
|
||||
foreach (ComplexSchema complexSchema in objectSchema.Parents!.Immediate)
|
||||
{
|
||||
switch (complexSchema)
|
||||
{
|
||||
case ObjectSchema parentObjectSchema:
|
||||
inheritsFromTypeReference = ClientModelBuilderHelpers.CreateType(parentObjectSchema, false);
|
||||
break;
|
||||
case DictionarySchema dictionarySchema:
|
||||
var dictionaryElementType = dictionarySchema.ElementType;
|
||||
dictionaryElementTypeReference = new DictionaryTypeReference(
|
||||
new FrameworkTypeReference(typeof(string)),
|
||||
ClientModelBuilderHelpers.CreateType(dictionaryElementType, false),
|
||||
false);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
List<ClientObjectProperty> properties = new List<ClientObjectProperty>();
|
||||
List<ClientObjectConstant> constants = new List<ClientObjectConstant>();
|
||||
|
||||
foreach (Property property in objectSchema.Properties!)
|
||||
{
|
||||
|
@ -41,7 +58,7 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
|
||||
if (schemaDiscriminator == null && objectSchema.DiscriminatorValue != null)
|
||||
{
|
||||
schemaDiscriminator = objectSchema.Parents?.All.OfType<ObjectSchema>().First(p => p.Discriminator != null).Discriminator;
|
||||
schemaDiscriminator = objectSchema.Parents!.All.OfType<ObjectSchema>().First(p => p.Discriminator != null).Discriminator;
|
||||
|
||||
Debug.Assert(schemaDiscriminator != null);
|
||||
|
||||
|
@ -67,8 +84,8 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
objectSchema.CSharpName(),
|
||||
(SchemaTypeReference?) inheritsFromTypeReference,
|
||||
properties.ToArray(),
|
||||
constants.ToArray(),
|
||||
discriminator
|
||||
discriminator,
|
||||
dictionaryElementTypeReference
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,12 +115,7 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
writer.Line($"using var content = new {writer.Type(typeof(Utf8JsonRequestContent))}();");
|
||||
writer.Line($"var writer = content.{nameof(Utf8JsonRequestContent.JsonWriter)};");
|
||||
|
||||
//TODO: Workaround for JSON serialization not supporting the null constants
|
||||
ConstantOrParameter value = body.Value;
|
||||
if (value.IsConstant && value.Constant.Value == null)
|
||||
{
|
||||
value = ClientModelBuilderHelpers.StringConstant("");
|
||||
}
|
||||
|
||||
writer.ToSerializeCall(value.Type, body.Format, _typeFactory, w => WriteConstantOrParameter(w, value));
|
||||
|
||||
|
@ -180,7 +175,11 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
{
|
||||
if (constant.Value == null)
|
||||
{
|
||||
writer.Literal(null);
|
||||
// Cast helps the overload resolution
|
||||
writer.Append("(")
|
||||
.AppendType(_typeFactory.CreateType(constant.Type))
|
||||
.Append(")")
|
||||
.Literal(null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
}
|
||||
|
||||
private string DefinitionLine(string? access, string? modifiers, string kind, string? name, string? implements = null) =>
|
||||
new[] { access ?? _definitionAccessDefault, modifiers, kind, name , implements != null ? $": {implements}" : null }.JoinIgnoreEmpty(" ");
|
||||
new[] { access ?? _definitionAccessDefault, modifiers, kind, name , !string.IsNullOrWhiteSpace(implements)? $": {implements}" : null }.JoinIgnoreEmpty(" ");
|
||||
|
||||
private CodeWriterScope Definition(string? access, string? modifiers, string kind, string? name, string? implements = null)
|
||||
{
|
||||
|
|
|
@ -29,14 +29,14 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
var formatSpecifier = f.ToFormatSpecifier();
|
||||
var valueText = $"{vn}{(nu ? ".Value" : string.Empty)}";
|
||||
var formatText = formatSpecifier != null ? $", \"{formatSpecifier}\"" : string.Empty;
|
||||
//TODO: Hack to call Azure.Core functionality without having the context of the namespaces specified to the file this is being written to.
|
||||
return $"Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, {valueText}{formatText});";
|
||||
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 },
|
||||
|
@ -54,12 +54,12 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
private static Func<string, SerializationFormat, string?>? FormatDeserializer(string typeName) => (n, f) =>
|
||||
{
|
||||
var formatSpecifier = f.ToFormatSpecifier();
|
||||
//TODO: Hack to call Azure.Core functionality without having the context of the namespaces specified to the file this is being written to.
|
||||
return formatSpecifier != null ? $"Azure.Core.TypeFormatters.Get{typeName}({n}, \"{formatSpecifier}\")" : null;
|
||||
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()" },
|
||||
|
@ -126,6 +126,9 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
|
||||
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"));
|
||||
|
||||
if (serializedName != null)
|
||||
{
|
||||
writer.Append("writer.WritePropertyName(");
|
||||
|
@ -135,6 +138,28 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case CollectionTypeReference array:
|
||||
{
|
||||
writer.Line("writer.WriteStartArray();");
|
||||
using (writer.ForEach($"var item in {CodeWriter.Materialize(name)}"))
|
||||
{
|
||||
writer.ToSerializeCall(array.ItemType, format, typeFactory, w => w.Append("item"));
|
||||
}
|
||||
writer.Line("writer.WriteEndArray();");
|
||||
|
||||
return;
|
||||
}
|
||||
case DictionaryTypeReference dictionary:
|
||||
{
|
||||
writer.Line("writer.WriteStartObject();");
|
||||
using (writer.ForEach($"var item in {CodeWriter.Materialize(name)}"))
|
||||
{
|
||||
writer.ToSerializeCall(dictionary.ValueType, format, typeFactory, w => w.Append("item.Value"), w => w.Append("item.Key"));
|
||||
}
|
||||
writer.Line("writer.WriteEndObject();");
|
||||
|
||||
return;
|
||||
}
|
||||
case SchemaTypeReference schemaTypeReference:
|
||||
WriteSerializeSchemaTypeReference(writer, schemaTypeReference, typeFactory, name);
|
||||
return;
|
||||
|
@ -201,19 +226,59 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
writer.Append(TypeDeserializers[frameworkType](CodeWriter.Materialize(name), format) ?? "null");
|
||||
}
|
||||
|
||||
public static void ToDeserializeCall(this CodeWriter writer, ClientTypeReference type, SerializationFormat format, TypeFactory typeFactory, CodeWriterDelegate name)
|
||||
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);
|
||||
writer.Append(".Add(");
|
||||
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);
|
||||
writer.Append(".Add(item.Name, ");
|
||||
writer.ToDeserializeCall(dictionary.ValueType, format, typeFactory, w => w.Append("item.Value"));
|
||||
writer.Line(");");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
writer.Append(destination);
|
||||
writer.Append("=");
|
||||
ToDeserializeCall(writer, type, format, typeFactory, element);
|
||||
writer.SemicolonLine();
|
||||
}
|
||||
|
||||
public static void ToDeserializeCall(this CodeWriter writer, ClientTypeReference type, SerializationFormat format, TypeFactory typeFactory, CodeWriterDelegate element)
|
||||
{
|
||||
CSharpType cSharpType = typeFactory.CreateType(type).WithNullable(false);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SchemaTypeReference schemaTypeReference:
|
||||
WriteDeserializeSchemaTypeReference(writer, cSharpType, schemaTypeReference, typeFactory, name);
|
||||
WriteDeserializeSchemaTypeReference(writer, cSharpType, schemaTypeReference, typeFactory, element);
|
||||
return;
|
||||
case BinaryTypeReference _:
|
||||
WriteDeserializeBinaryTypeReference(writer, name);
|
||||
WriteDeserializeBinaryTypeReference(writer, element);
|
||||
return;
|
||||
default:
|
||||
WriteDeserializeDefault(writer, cSharpType, format, name);
|
||||
WriteDeserializeDefault(writer, cSharpType, format, element);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using AutoRest.CSharp.V3.ClientModels;
|
||||
|
@ -43,13 +45,20 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
var cs = _typeFactory.CreateType(schema);
|
||||
using (writer.Namespace(cs.Namespace))
|
||||
{
|
||||
string? implementsType = null;
|
||||
List<string> implementsTypes = new List<string>();
|
||||
if (schema.Inherits != null)
|
||||
{
|
||||
implementsType = writer.Type(_typeFactory.CreateType(schema.Inherits));
|
||||
implementsTypes.Add(writer.Type(_typeFactory.CreateType(schema.Inherits)));
|
||||
}
|
||||
|
||||
using (writer.Class(null, "partial", schema.CSharpName(), implements: implementsType))
|
||||
if (schema.ImplementsDictionary != null)
|
||||
{
|
||||
var dictionaryType = _typeFactory.CreateInputType(schema.ImplementsDictionary);
|
||||
implementsTypes.Add(writer.Type(dictionaryType));
|
||||
}
|
||||
|
||||
|
||||
using (writer.Class(null, "partial", schema.CSharpName(), implements: string.Join(", ", implementsTypes)))
|
||||
{
|
||||
if (schema.Discriminator != null)
|
||||
{
|
||||
|
@ -69,6 +78,48 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
var initializer = !propertyType.IsNullable && NeedsInitialization(property.Type) ? $" = new {writer.Type(_typeFactory.CreateConcreteType(property.Type))}();" : null;
|
||||
writer.AutoProperty("public", propertyType, property.Name, property.IsReadOnly, initializer);
|
||||
}
|
||||
|
||||
if (schema.ImplementsDictionary != null)
|
||||
{
|
||||
var implementationType = _typeFactory.CreateType(schema.ImplementsDictionary);
|
||||
var fieldType = _typeFactory.CreateConcreteType(schema.ImplementsDictionary);
|
||||
var keyType = _typeFactory.CreateType(schema.ImplementsDictionary.KeyType);
|
||||
var itemType = _typeFactory.CreateType(schema.ImplementsDictionary.ValueType);
|
||||
|
||||
var keyValuePairType = new CSharpType(typeof(KeyValuePair<,>), keyType, itemType);
|
||||
var iEnumeratorKeyValuePairType = new CSharpType(typeof(IEnumerator<>), keyValuePairType);
|
||||
var iCollectionKeyValuePairType = new CSharpType(typeof(ICollection<>), keyValuePairType);
|
||||
var iCollectionKeyType = new CSharpType(typeof(ICollection<>), keyType);
|
||||
var iCollectionItemType = new CSharpType(typeof(ICollection<>), itemType);
|
||||
var iEnumerator = new CSharpType(typeof(IEnumerator));
|
||||
var iEnumerable = new CSharpType(typeof(IEnumerable));
|
||||
|
||||
string additionalProperties = "_additionalProperties";
|
||||
writer.Append("private readonly ").AppendType(implementationType).Space().Append(additionalProperties).Append("= new ").AppendType(fieldType).Append("()").SemicolonLine();
|
||||
|
||||
writer.Append("public ").AppendType(iEnumeratorKeyValuePairType).Append(" GetEnumerator() => _additionalProperties.GetEnumerator();").Line()
|
||||
.AppendType(iEnumerator).Space().AppendType(iEnumerable).Append(".GetEnumerator() => _additionalProperties.GetEnumerator();").Line()
|
||||
.Append("public ").AppendType(iCollectionKeyType).Append(" Keys => _additionalProperties.Keys;").Line()
|
||||
.Append("public ").AppendType(iCollectionItemType).Append(" Values => _additionalProperties.Values;").Line()
|
||||
.Append("public bool TryGetValue(string key, out ").AppendType(itemType).Append(" value) => _additionalProperties.TryGetValue(key, out value);").Line()
|
||||
.Append("public void Add(").AppendType(keyType).Append(" key, ").AppendType(itemType).Append(" value) => _additionalProperties.Add(key, value);").Line()
|
||||
.Append("public bool ContainsKey(").AppendType(keyType).Append(" key) => _additionalProperties.ContainsKey(key);").Line()
|
||||
.Append("public bool Remove(").AppendType(keyType).Append(" key) => _additionalProperties.Remove(key);").Line()
|
||||
.Append("public int Count => _additionalProperties.Count;").Line()
|
||||
.Append("bool ").AppendType(iCollectionKeyValuePairType).Append(".IsReadOnly => _additionalProperties.IsReadOnly;").Line()
|
||||
.Append("void ").AppendType(iCollectionKeyValuePairType).Append(".Add(").AppendType(keyValuePairType).Append(" value) => _additionalProperties.Add(value);").Line()
|
||||
.Append("bool ").AppendType(iCollectionKeyValuePairType).Append(".Remove(").AppendType(keyValuePairType).Append(" value) => _additionalProperties.Remove(value);").Line()
|
||||
.Append("bool ").AppendType(iCollectionKeyValuePairType).Append(".Contains(").AppendType(keyValuePairType).Append(" value) => _additionalProperties.Contains(value);").Line()
|
||||
.Append("void ").AppendType(iCollectionKeyValuePairType).Append(".CopyTo(").AppendType(keyValuePairType).Append("[] destination, int offset) => _additionalProperties.CopyTo(destination, offset);").Line()
|
||||
.Append("void ").AppendType(iCollectionKeyValuePairType).Append(".Clear() => _additionalProperties.Clear();").Line();
|
||||
|
||||
using (writer.Append("public ").AppendType(itemType).Append(" this[").AppendType(keyType).Append(" key]").Scope())
|
||||
{
|
||||
writer
|
||||
.Line("get => _additionalProperties[key];")
|
||||
.Line("set => _additionalProperties[key] = value;");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using AutoRest.CSharp.V3.ClientModels;
|
||||
|
@ -32,35 +33,6 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
}
|
||||
}
|
||||
|
||||
private void WriteProperty(CodeWriter writer, ClientTypeReference type, SerializationFormat format, string name, string serializedName)
|
||||
{
|
||||
if (type is CollectionTypeReference array)
|
||||
{
|
||||
writer.Line($"writer.WriteStartArray(\"{serializedName}\");");
|
||||
using (writer.ForEach($"var item in {name}"))
|
||||
{
|
||||
writer.ToSerializeCall(array.ItemType, format, _typeFactory, w => w.Append("item"));
|
||||
}
|
||||
writer.Line("writer.WriteEndArray();");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (type is DictionaryTypeReference dictionary)
|
||||
{
|
||||
writer.Line($"writer.WriteStartObject(\"{serializedName}\");");
|
||||
using (writer.ForEach($"var item in {name}"))
|
||||
{
|
||||
writer.ToSerializeCall(dictionary.ValueType, format, _typeFactory, w => w.Append("item.Value"), w => w.Append("item.Key"));
|
||||
}
|
||||
writer.Line("writer.WriteEndObject();");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
writer.ToSerializeCall(type, format, _typeFactory, w => w.Append(name), w => w.Literal(serializedName));
|
||||
}
|
||||
|
||||
private void ReadProperty(CodeWriter writer, ClientObjectProperty property)
|
||||
{
|
||||
var type = property.Type;
|
||||
|
@ -69,58 +41,33 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
|
||||
CSharpType propertyType = _typeFactory.CreateType(type);
|
||||
|
||||
void WriteNullCheck()
|
||||
{
|
||||
using (writer.If($"property.Value.ValueKind == {writer.Type(typeof(JsonValueKind))}.Null"))
|
||||
{
|
||||
writer.Append("continue;");
|
||||
}
|
||||
}
|
||||
|
||||
void WriteInitialization()
|
||||
{
|
||||
if (propertyType.IsNullable)
|
||||
if (propertyType.IsNullable && (type is DictionaryTypeReference || type is CollectionTypeReference))
|
||||
{
|
||||
WriteNullCheck(writer);
|
||||
|
||||
writer.Append($"result.{name} = new {writer.Type(_typeFactory.CreateConcreteType(property.Type))}()")
|
||||
.SemicolonLine();
|
||||
}
|
||||
}
|
||||
|
||||
if (type is CollectionTypeReference array)
|
||||
{
|
||||
WriteInitialization();
|
||||
|
||||
using (writer.ForEach("var item in property.Value.EnumerateArray()"))
|
||||
{
|
||||
writer.Append($"result.{name}.Add(");
|
||||
writer.ToDeserializeCall(array.ItemType, format, _typeFactory, w => w.Append("item"));
|
||||
writer.Line(");");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (type is DictionaryTypeReference dictionary)
|
||||
{
|
||||
WriteInitialization();
|
||||
|
||||
using (writer.ForEach("var item in property.Value.EnumerateObject()"))
|
||||
{
|
||||
writer.Append($"result.{name}.Add(item.Name, ");
|
||||
writer.ToDeserializeCall(dictionary.ValueType, format, _typeFactory, w => w.Append("item.Value"));
|
||||
writer.Line(");");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (propertyType.IsNullable)
|
||||
{
|
||||
WriteNullCheck(writer);
|
||||
WriteNullCheck();
|
||||
}
|
||||
writer.Append($"result.{name} = ");
|
||||
writer.ToDeserializeCall(type, format, _typeFactory, w => w.Append("property.Value"));
|
||||
writer.Line(";");
|
||||
|
||||
WriteInitialization();
|
||||
|
||||
writer.ToDeserializeCall(type, format, _typeFactory, w=> w.Append($"result.{name}"), w => w.Append("property.Value"));
|
||||
}
|
||||
|
||||
private static void WriteNullCheck(CodeWriter writer)
|
||||
{
|
||||
using (writer.If($"property.Value.ValueKind == {writer.Type(typeof(JsonValueKind))}.Null"))
|
||||
{
|
||||
writer.Append("continue;");
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: This is currently input schemas only. Does not handle output-style schemas.
|
||||
private void WriteObjectSerialization(CodeWriter writer, ClientObject model)
|
||||
|
@ -131,108 +78,145 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
{
|
||||
using (writer.Class(null, "partial", serializerName))
|
||||
{
|
||||
using (writer.Method("internal static", "void", "Serialize", writer.Pair(cs, "model"), writer.Pair(typeof(Utf8JsonWriter), "writer")))
|
||||
WriteSerialize(writer, model, cs);
|
||||
|
||||
WriteDeserialize(writer, model, cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteDeserialize(CodeWriter writer, ClientObject model, CSharpType cs)
|
||||
{
|
||||
var typeText = writer.Type(cs);
|
||||
using (writer.Method("internal static", typeText, "Deserialize", writer.Pair(typeof(JsonElement), "element")))
|
||||
{
|
||||
if (model.Discriminator?.HasDescendants == true)
|
||||
{
|
||||
using (writer.If($"element.TryGetProperty(\"{model.Discriminator.SerializedName}\", out {writer.Type(typeof(JsonElement))} discriminator)"))
|
||||
{
|
||||
if (model.Discriminator?.HasDirectDescendants == true)
|
||||
writer.Line("switch (discriminator.GetString())");
|
||||
using (writer.Scope())
|
||||
{
|
||||
writer.Line("switch (model)");
|
||||
using (writer.Scope())
|
||||
foreach (var implementation in model.Discriminator.Implementations)
|
||||
{
|
||||
foreach (var implementation in model.Discriminator.Implementations)
|
||||
{
|
||||
if (!implementation.IsDirect)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var type = _typeFactory.CreateType(implementation.Type);
|
||||
var localName = type.Name.ToVariableName();
|
||||
writer.Append("case ").AppendType(type).Space().Append(localName).Append(":").Line();
|
||||
writer.ToSerializeCall(implementation.Type, SerializationFormat.Default, _typeFactory, w => w.Append(localName));
|
||||
writer.Line("return;");
|
||||
}
|
||||
writer
|
||||
.Append("case ")
|
||||
.Literal(implementation.Key)
|
||||
.Append(": return ")
|
||||
.ToDeserializeCall(implementation.Type, SerializationFormat.Default, _typeFactory,
|
||||
w => w.Append("element"));
|
||||
writer.SemicolonLine();
|
||||
}
|
||||
}
|
||||
|
||||
writer.Line("writer.WriteStartObject();");
|
||||
|
||||
var currentType = model;
|
||||
|
||||
while (currentType != null)
|
||||
{
|
||||
foreach (var property in currentType.Properties)
|
||||
{
|
||||
using (property.Type.IsNullable ? writer.If($"model.{ property.Name} != null") : default)
|
||||
{
|
||||
WriteProperty(writer, property.Type, property.Format, "model." + property.Name, property.SerializedName);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentType.Inherits == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
currentType = (ClientObject)_typeFactory.ResolveReference(currentType.Inherits);
|
||||
|
||||
writer.Line();
|
||||
}
|
||||
|
||||
writer.Line("writer.WriteEndObject();");
|
||||
}
|
||||
|
||||
var typeText = writer.Type(cs);
|
||||
using (writer.Method("internal static", typeText, "Deserialize", writer.Pair(typeof(JsonElement), "element")))
|
||||
{
|
||||
if (model.Discriminator?.HasDescendants == true)
|
||||
{
|
||||
using (writer.If($"element.TryGetProperty(\"{model.Discriminator.SerializedName}\", out {writer.Type(typeof(JsonElement))} discriminator)"))
|
||||
{
|
||||
writer.Line("switch (discriminator.GetString())");
|
||||
using (writer.Scope())
|
||||
{
|
||||
foreach (var implementation in model.Discriminator.Implementations)
|
||||
{
|
||||
writer
|
||||
.Append("case ")
|
||||
.Literal(implementation.Key)
|
||||
.Append(": return ")
|
||||
.ToDeserializeCall(implementation.Type, SerializationFormat.Default, _typeFactory, w => w.Append("element"));
|
||||
writer.SemicolonLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writer.Line($"var result = new {typeText}();");
|
||||
using (writer.ForEach("var property in element.EnumerateObject()"))
|
||||
{
|
||||
var currentType = model;
|
||||
|
||||
while (currentType != null)
|
||||
{
|
||||
foreach (var property in currentType.Properties)
|
||||
{
|
||||
using (writer.If($"property.NameEquals(\"{property.SerializedName}\")"))
|
||||
{
|
||||
ReadProperty(writer, property);
|
||||
writer.Line("continue;");
|
||||
}
|
||||
}
|
||||
|
||||
if (currentType.Inherits == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
currentType = (ClientObject)_typeFactory.ResolveReference(currentType.Inherits);
|
||||
|
||||
writer.Line();
|
||||
}
|
||||
}
|
||||
writer.Line("return result;");
|
||||
}
|
||||
}
|
||||
|
||||
writer.Line($"var result = new {typeText}();");
|
||||
using (writer.ForEach("var property in element.EnumerateObject()"))
|
||||
{
|
||||
DictionaryTypeReference? implementsDictionary = null;
|
||||
|
||||
foreach (ClientObject currentType in WalkInheritance(model))
|
||||
{
|
||||
foreach (var property in currentType.Properties)
|
||||
{
|
||||
using (writer.If($"property.NameEquals(\"{property.SerializedName}\")"))
|
||||
{
|
||||
ReadProperty(writer, property);
|
||||
writer.Line("continue;");
|
||||
}
|
||||
}
|
||||
|
||||
implementsDictionary ??= currentType.ImplementsDictionary;
|
||||
}
|
||||
|
||||
if (implementsDictionary != null)
|
||||
{
|
||||
writer.Append("result.Add(property.Name, ");
|
||||
writer.ToDeserializeCall(implementsDictionary.ValueType, SerializationFormat.Default, _typeFactory, w => w.Append("property.Value"));
|
||||
writer.Append(");").Line();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
writer.Line("return result;");
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<ClientObject> WalkInheritance(ClientObject model)
|
||||
{
|
||||
var currentType = model;
|
||||
|
||||
while (currentType != null)
|
||||
{
|
||||
yield return currentType;
|
||||
|
||||
if (currentType.Inherits == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
currentType = (ClientObject)_typeFactory.ResolveReference(currentType.Inherits);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteSerialize(CodeWriter writer, ClientObject model, CSharpType cs)
|
||||
{
|
||||
using (writer.Method("internal static", "void", "Serialize", writer.Pair(cs, "model"), writer.Pair(typeof(Utf8JsonWriter), "writer")))
|
||||
{
|
||||
if (model.Discriminator?.HasDirectDescendants == true)
|
||||
{
|
||||
writer.Line("switch (model)");
|
||||
using (writer.Scope())
|
||||
{
|
||||
foreach (var implementation in model.Discriminator.Implementations)
|
||||
{
|
||||
if (!implementation.IsDirect)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var type = _typeFactory.CreateType(implementation.Type);
|
||||
var localName = type.Name.ToVariableName();
|
||||
writer.Append("case ").AppendType(type).Space().Append(localName).Append(":").Line();
|
||||
writer.ToSerializeCall(implementation.Type, SerializationFormat.Default, _typeFactory,
|
||||
w => w.Append(localName));
|
||||
writer.Line("return;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writer.Line("writer.WriteStartObject();");
|
||||
|
||||
DictionaryTypeReference? implementsDictionary = null;
|
||||
|
||||
foreach (ClientObject currentType in WalkInheritance(model))
|
||||
{
|
||||
foreach (var property in currentType.Properties)
|
||||
{
|
||||
using (property.Type.IsNullable ? writer.If($"model.{property.Name} != null") : default)
|
||||
{
|
||||
writer.ToSerializeCall(
|
||||
property.Type,
|
||||
property.Format,
|
||||
_typeFactory,
|
||||
w => w.Append("model.").Append(property.Name),
|
||||
w => w.Literal(property.SerializedName));
|
||||
}
|
||||
|
||||
implementsDictionary ??= currentType.ImplementsDictionary;
|
||||
}
|
||||
}
|
||||
|
||||
if (implementsDictionary != null)
|
||||
{
|
||||
using (writer.ForEach("var item in model"))
|
||||
{
|
||||
writer.ToSerializeCall(implementsDictionary.ValueType, SerializationFormat.Default, _typeFactory, w => w.Append("item.Value"), w => w.Append("item.Key"));
|
||||
}
|
||||
}
|
||||
|
||||
writer.Line("writer.WriteEndObject();");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,17 @@ namespace AutoRest.CSharp.V3.Pipeline.Generated
|
|||
public ObjectSchema()
|
||||
{
|
||||
Properties = Array.Empty<Property>();
|
||||
Parents = new Relations();
|
||||
Children = new Relations();
|
||||
}
|
||||
}
|
||||
|
||||
internal partial class Relations
|
||||
{
|
||||
public Relations()
|
||||
{
|
||||
Immediate = Array.Empty<ComplexSchema>();
|
||||
All = Array.Empty<ComplexSchema>();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Xml;
|
||||
|
||||
namespace Azure.Core
|
||||
{
|
||||
internal static class JsonElementExtensions
|
||||
{
|
||||
public static object? GetObject(in this JsonElement element)
|
||||
{
|
||||
switch (element.ValueKind)
|
||||
{
|
||||
case JsonValueKind.String:
|
||||
return element.GetString();
|
||||
case JsonValueKind.Number:
|
||||
if (element.TryGetInt32(out var value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return element.GetDouble();
|
||||
case JsonValueKind.True:
|
||||
return true;
|
||||
case JsonValueKind.False:
|
||||
return false;
|
||||
case JsonValueKind.Null:
|
||||
return null;
|
||||
case JsonValueKind.Object:
|
||||
var dictionary = new Dictionary<string, object?>();
|
||||
foreach (JsonProperty jsonProperty in element.EnumerateObject())
|
||||
{
|
||||
dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject());
|
||||
}
|
||||
return dictionary;
|
||||
case JsonValueKind.Array:
|
||||
var list = new List<object?>();
|
||||
foreach (JsonElement item in element.EnumerateArray())
|
||||
{
|
||||
list.Add(item.GetObject());
|
||||
}
|
||||
return list.ToArray();
|
||||
default:
|
||||
throw new NotSupportedException("Not supported value kind " + element.ValueKind);
|
||||
}
|
||||
}
|
||||
|
||||
public static DateTimeOffset GetDateTimeOffset(in this JsonElement element, string format) => format switch
|
||||
{
|
||||
"D" => element.GetDateTimeOffset(),
|
||||
"S" => element.GetDateTimeOffset(),
|
||||
"R" => DateTimeOffset.Parse(element.GetString()),
|
||||
"U" => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()),
|
||||
_ => throw new ArgumentException("Format is not supported", nameof(format))
|
||||
};
|
||||
|
||||
public static TimeSpan GetTimeSpan(in this JsonElement element, string format) => format switch
|
||||
{
|
||||
"P" => XmlConvert.ToTimeSpan(element.GetString()),
|
||||
_ => throw new ArgumentException("Format is not supported", nameof(format))
|
||||
};
|
||||
}
|
||||
}
|
|
@ -29,21 +29,6 @@ namespace Azure.Core
|
|||
_ => throw new ArgumentException("Format is not supported", nameof(format))
|
||||
};
|
||||
|
||||
public static DateTimeOffset GetDateTimeOffset(JsonElement element, string format) => format switch
|
||||
{
|
||||
"D" => element.GetDateTimeOffset(),
|
||||
"S" => element.GetDateTimeOffset(),
|
||||
"R" => DateTimeOffset.Parse(element.GetString()),
|
||||
"U" => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()),
|
||||
_ => throw new ArgumentException("Format is not supported", nameof(format))
|
||||
};
|
||||
|
||||
public static TimeSpan GetTimeSpan(JsonElement element, string format) => format switch
|
||||
{
|
||||
"P" => XmlConvert.ToTimeSpan(element.GetString()),
|
||||
_ => throw new ArgumentException("Format is not supported", nameof(format))
|
||||
};
|
||||
|
||||
public static string ToBase64UrlString(byte[] value)
|
||||
{
|
||||
var numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Azure.Core
|
||||
|
@ -13,5 +14,56 @@ namespace Azure.Core
|
|||
|
||||
public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) =>
|
||||
writer.WriteStringValue(TypeFormatters.ToString(value, format));
|
||||
|
||||
public static void WriteObjectValue(this Utf8JsonWriter writer, object value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case null:
|
||||
writer.WriteNullValue();
|
||||
break;
|
||||
case int i:
|
||||
writer.WriteNumberValue(i);
|
||||
break;
|
||||
case decimal d:
|
||||
writer.WriteNumberValue(d);
|
||||
break;
|
||||
case double d:
|
||||
writer.WriteNumberValue(d);
|
||||
break;
|
||||
case float f:
|
||||
writer.WriteNumberValue(f);
|
||||
break;
|
||||
case string s:
|
||||
writer.WriteStringValue(s);
|
||||
break;
|
||||
case bool b:
|
||||
writer.WriteBooleanValue(b);
|
||||
break;
|
||||
case DateTimeOffset dateTimeOffset:
|
||||
writer.WriteStringValue(dateTimeOffset,"S");
|
||||
break;
|
||||
case IEnumerable<KeyValuePair<string, object>> enumerable:
|
||||
writer.WriteStartObject();
|
||||
foreach (KeyValuePair<string, object> pair in enumerable)
|
||||
{
|
||||
writer.WritePropertyName(pair.Key);
|
||||
writer.WriteObjectValue(pair.Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
break;
|
||||
case IEnumerable<object> objectEnumerable:
|
||||
writer.WriteStartArray();
|
||||
foreach (object item in objectEnumerable)
|
||||
{
|
||||
writer.WriteObjectValue(item);
|
||||
}
|
||||
writer.WriteEndArray();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotSupportedException("Not supported type " + value.GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,174 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using additionalProperties;
|
||||
using additionalProperties.Models.V100;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
{
|
||||
public class AdditionalPropertiesTest : TestServerTestBase
|
||||
{
|
||||
public AdditionalPropertiesTest(TestServerVersion version) : base(version, "additionalProperties") { }
|
||||
|
||||
[Test]
|
||||
[IgnoreOnTestServer(TestServerVersion.V2, "No match")]
|
||||
public Task AdditionalPropertiesInProperties() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var response = await PetsOperations.CreateAPInPropertiesAsync(ClientDiagnostics, pipeline, new PetAPInProperties()
|
||||
{
|
||||
Id = 4,
|
||||
Name = "Bunny",
|
||||
AdditionalProperties = new Dictionary<string, float>()
|
||||
{
|
||||
{ "height", 5.61f },
|
||||
{ "weight", 599f },
|
||||
{ "footsize", 11.5f }
|
||||
}
|
||||
}, host);
|
||||
|
||||
var value = response.Value;
|
||||
Assert.AreEqual(4, value.Id);
|
||||
Assert.AreEqual("Bunny", value.Name);
|
||||
Assert.AreEqual(5.61f, value.AdditionalProperties["height"]);
|
||||
Assert.AreEqual(599f, value.AdditionalProperties["weight"]);
|
||||
Assert.AreEqual(11.5f, value.AdditionalProperties["footsize"]);
|
||||
});
|
||||
|
||||
[Test]
|
||||
[IgnoreOnTestServer(TestServerVersion.V2, "No match")]
|
||||
public Task AdditionalPropertiesInPropertiesWithAPTypeString() => Test(async (host, pipeline) =>
|
||||
{
|
||||
PetAPInPropertiesWithAPString parameter = new PetAPInPropertiesWithAPString()
|
||||
{
|
||||
Id = 5,
|
||||
Name = "Funny",
|
||||
OdataLocation = "westus",
|
||||
AdditionalProperties = new Dictionary<string, float>()
|
||||
{
|
||||
{ "height", 5.61f },
|
||||
{ "weight", 599f },
|
||||
{ "footsize", 11.5f }
|
||||
},
|
||||
};
|
||||
|
||||
parameter["color"] = "red";
|
||||
parameter["city"] = "Seattle";
|
||||
parameter["food"] = "tikka masala";
|
||||
|
||||
var response = await PetsOperations.CreateAPInPropertiesWithAPStringAsync(ClientDiagnostics, pipeline, parameter, host);
|
||||
|
||||
var value = response.Value;
|
||||
Assert.AreEqual(5, value.Id);
|
||||
Assert.AreEqual("Funny", value.Name);
|
||||
Assert.AreEqual("westus", value.OdataLocation);
|
||||
Assert.AreEqual(5.61f, value.AdditionalProperties["height"]);
|
||||
Assert.AreEqual(599f, value.AdditionalProperties["weight"]);
|
||||
Assert.AreEqual(11.5f, value.AdditionalProperties["footsize"]);
|
||||
|
||||
Assert.AreEqual("red", value["color"]);
|
||||
Assert.AreEqual("Seattle", value["city"]);
|
||||
Assert.AreEqual("tikka masala", value["food"]);
|
||||
});
|
||||
|
||||
[Test]
|
||||
[IgnoreOnTestServer(TestServerVersion.V2, "No match")]
|
||||
public Task AdditionalPropertiesSubclass() => Test(async (host, pipeline) =>
|
||||
{
|
||||
CatAPTrue catApTrue = new CatAPTrue()
|
||||
{
|
||||
Id = 1,
|
||||
Name = "Lisa",
|
||||
Friendly = true,
|
||||
};
|
||||
|
||||
catApTrue["birthdate"] = DateTimeOffset.Parse("2017-12-13T02:29:51Z");
|
||||
catApTrue["complexProperty"] = new Dictionary<string, object>()
|
||||
{
|
||||
{"color", "Red"}
|
||||
};
|
||||
|
||||
var response = await PetsOperations.CreateCatAPTrueAsync(ClientDiagnostics, pipeline, catApTrue, host);
|
||||
|
||||
var value = response.Value;
|
||||
Assert.AreEqual(1, value.Id);
|
||||
Assert.AreEqual("Lisa", value.Name);
|
||||
Assert.AreEqual(true, value.Status);
|
||||
Assert.AreEqual(true, value.Friendly);
|
||||
Assert.AreEqual("2017-12-13T02:29:51Z", value["birthdate"]);
|
||||
Assert.AreEqual("Red", ((Dictionary<string, object>)value["complexProperty"])["color"]);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task AdditionalPropertiesTrue() => Test(async (host, pipeline) =>
|
||||
{
|
||||
PetAPTrue catApTrue = new PetAPTrue()
|
||||
{
|
||||
Id = 1,
|
||||
Name = "Puppy",
|
||||
};
|
||||
|
||||
catApTrue["birthdate"] = DateTimeOffset.Parse("2017-12-13T02:29:51Z");
|
||||
catApTrue["complexProperty"] = new Dictionary<string, object>()
|
||||
{
|
||||
{"color", "Red"}
|
||||
};
|
||||
|
||||
var response = await PetsOperations.CreateAPTrueAsync(ClientDiagnostics, pipeline, catApTrue, host);
|
||||
|
||||
var value = response.Value;
|
||||
Assert.AreEqual(1, value.Id);
|
||||
Assert.AreEqual("Puppy", value.Name);
|
||||
Assert.AreEqual(true, value.Status);
|
||||
Assert.AreEqual("2017-12-13T02:29:51Z", value["birthdate"]);
|
||||
Assert.AreEqual("Red", ((Dictionary<string, object>)value["complexProperty"])["color"]);
|
||||
});
|
||||
|
||||
[Test]
|
||||
[Ignore("https://github.com/Azure/autorest.csharp/issues/360")]
|
||||
public Task AdditionalPropertiesTypeObject() => Test(async (host, pipeline) =>
|
||||
{
|
||||
PetAPObject petApObject = new PetAPObject()
|
||||
{
|
||||
Id = 1,
|
||||
Name = "Puppy",
|
||||
};
|
||||
|
||||
petApObject["birthdate"] = DateTimeOffset.Parse("2017-12-13T02:29:51Z");
|
||||
petApObject["complexProperty"] = new Dictionary<string, object>()
|
||||
{
|
||||
{"color", "Red"}
|
||||
};
|
||||
|
||||
await PetsOperations.CreateAPObjectAsync(ClientDiagnostics, pipeline, petApObject, host);
|
||||
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task AdditionalPropertiesTypeString() => Test(async (host, pipeline) =>
|
||||
{
|
||||
PetAPString petApObject = new PetAPString()
|
||||
{
|
||||
Id = 3,
|
||||
Name = "Tommy"
|
||||
};
|
||||
|
||||
petApObject["weight"] = "10 kg";
|
||||
petApObject["color"] = "red";
|
||||
petApObject["city"] = "Bombay";
|
||||
|
||||
var response = await PetsOperations.CreateAPStringAsync(ClientDiagnostics, pipeline, petApObject, host);
|
||||
var value = response.Value;
|
||||
Assert.AreEqual(3, value.Id);
|
||||
Assert.AreEqual("Tommy", value.Name);
|
||||
Assert.AreEqual(true, value.Status);
|
||||
Assert.AreEqual("red", value["color"]);
|
||||
Assert.AreEqual("10 kg", value["weight"]);
|
||||
Assert.AreEqual("Bombay", value["city"]);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -548,7 +548,6 @@ namespace AutoRest.TestServer.Tests
|
|||
});
|
||||
|
||||
[Test]
|
||||
// TODO: Passes but without additional properties https://github.com/Azure/autorest.csharp/issues/348
|
||||
public Task GetComplexPolymorphismComplicated() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var result = await PolymorphismOperations.GetComplicatedAsync(ClientDiagnostics, pipeline, host);
|
||||
|
@ -585,97 +584,62 @@ namespace AutoRest.TestServer.Tests
|
|||
Assert.AreEqual(5, goblin.Jawsize);
|
||||
Assert.AreEqual("pinkish-gray", goblin.Color.ToString());
|
||||
|
||||
/*
|
||||
var rawSalmon = {
|
||||
'fishtype': 'smart_salmon',
|
||||
'location': 'alaska',
|
||||
'iswild': true,
|
||||
'species': 'king',
|
||||
'additionalProperty1': 1,
|
||||
'additionalProperty2': false,
|
||||
'additionalProperty3': "hello",
|
||||
'additionalProperty4': { a: 1, b: 2 },
|
||||
'additionalProperty5': [1, 3],
|
||||
'length': 1.0,
|
||||
'siblings': [
|
||||
{
|
||||
'fishtype': 'shark',
|
||||
'age': 6,
|
||||
'birthday': '2012-01-05T01:00:00Z',
|
||||
'length': 20.0,
|
||||
'species': 'predator',
|
||||
},
|
||||
{
|
||||
'fishtype': 'sawshark',
|
||||
'age': 105,
|
||||
'birthday': '1900-01-05T01:00:00Z',
|
||||
'length': 10.0,
|
||||
'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'),
|
||||
'species': 'dangerous',
|
||||
},
|
||||
{
|
||||
'fishtype': 'goblin',
|
||||
'age': 1,
|
||||
'birthday': '2015-08-08T00:00:00Z',
|
||||
'length': 30.0,
|
||||
'species': 'scary',
|
||||
'jawsize': 5,
|
||||
'color':'pinkish-gray'
|
||||
}
|
||||
]
|
||||
};
|
||||
*/
|
||||
Assert.AreEqual(1, value["additionalProperty1"]);
|
||||
Assert.AreEqual(false, value["additionalProperty2"]);
|
||||
Assert.AreEqual("hello", value["additionalProperty3"]);
|
||||
Assert.AreEqual(new Dictionary<string, object>()
|
||||
{
|
||||
{"a", 1},
|
||||
{"b", 2 }
|
||||
}, value["additionalProperty4"]);
|
||||
|
||||
Assert.AreEqual(new object[] { 1, 3 }, value["additionalProperty5"]);
|
||||
});
|
||||
|
||||
[Test]
|
||||
[Ignore("https://github.com/Azure/autorest.csharp/issues/348")]
|
||||
[IgnoreOnTestServer(TestServerVersion.V2, "No match")]
|
||||
public Task PutComplexPolymorphismComplicated() => TestStatus(async (host, pipeline) =>
|
||||
{
|
||||
/*
|
||||
var rawSalmon = {
|
||||
'fishtype': 'smart_salmon',
|
||||
'location': 'alaska',
|
||||
'iswild': true,
|
||||
'species': 'king',
|
||||
'additionalProperty1': 1,
|
||||
'additionalProperty2': false,
|
||||
'additionalProperty3': "hello",
|
||||
'additionalProperty4': { a: 1, b: 2 },
|
||||
'additionalProperty5': [1, 3],
|
||||
'length': 1.0,
|
||||
'siblings': [
|
||||
{
|
||||
'fishtype': 'shark',
|
||||
'age': 6,
|
||||
'birthday': '2012-01-05T01:00:00Z',
|
||||
'length': 20.0,
|
||||
'species': 'predator',
|
||||
},
|
||||
{
|
||||
'fishtype': 'sawshark',
|
||||
'age': 105,
|
||||
'birthday': '1900-01-05T01:00:00Z',
|
||||
'length': 10.0,
|
||||
'picture': new Buffer([255, 255, 255, 255, 254]).toString('base64'),
|
||||
'species': 'dangerous',
|
||||
},
|
||||
{
|
||||
'fishtype': 'goblin',
|
||||
'age': 1,
|
||||
'birthday': '2015-08-08T00:00:00Z',
|
||||
'length': 30.0,
|
||||
'species': 'scary',
|
||||
'jawsize': 5,
|
||||
'color':'pinkish-gray'
|
||||
}
|
||||
]
|
||||
};
|
||||
*/
|
||||
var value = new Salmon
|
||||
var value = new SmartSalmon()
|
||||
{
|
||||
//Fishtype = "smart_salmon",
|
||||
Location = "alaska"
|
||||
Location = "alaska",
|
||||
Iswild = true,
|
||||
Species = "king",
|
||||
Length = 1,
|
||||
Siblings = new[]
|
||||
{
|
||||
new Shark
|
||||
{
|
||||
Age = 6,
|
||||
Birthday = DateTimeOffset.Parse("2012-01-05T01:00:00Z"),
|
||||
Length = 20,
|
||||
Species = "predator"
|
||||
},
|
||||
new Sawshark()
|
||||
{
|
||||
Age = 105,
|
||||
Birthday = DateTimeOffset.Parse("1900-01-05T01:00:00Z"),
|
||||
Picture = new byte[] {255, 255, 255, 255, 254},
|
||||
Length = 10,
|
||||
Species = "dangerous"
|
||||
},
|
||||
new Goblinshark()
|
||||
{
|
||||
Age = 1,
|
||||
Birthday = DateTimeOffset.Parse("2015-08-08T00:00:00Z"),
|
||||
Length = 30,
|
||||
Species = "scary",
|
||||
Jawsize = 5,
|
||||
Color = "pinkish-gray"
|
||||
}
|
||||
}
|
||||
};
|
||||
value["additionalProperty1"] = 1;
|
||||
value["additionalProperty2"] = false;
|
||||
value["additionalProperty3"] = "hello";
|
||||
value["additionalProperty4"] = new Dictionary<string, object>() {{"a", 1}, {"b", 2}};
|
||||
value["additionalProperty5"] = new object[] {1, 3};
|
||||
|
||||
return await PolymorphismOperations.PutComplicatedAsync(ClientDiagnostics, pipeline, value, host);
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class CatAPTrueSerializer
|
||||
{
|
||||
internal static void Serialize(CatAPTrue model, Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (model.Friendly != null)
|
||||
{
|
||||
writer.WritePropertyName("friendly");
|
||||
writer.WriteBooleanValue(model.Friendly.Value);
|
||||
}
|
||||
writer.WritePropertyName("id");
|
||||
writer.WriteNumberValue(model.Id);
|
||||
if (model.Name != null)
|
||||
{
|
||||
writer.WritePropertyName("name");
|
||||
writer.WriteStringValue(model.Name);
|
||||
}
|
||||
if (model.Status != null)
|
||||
{
|
||||
writer.WritePropertyName("status");
|
||||
writer.WriteBooleanValue(model.Status.Value);
|
||||
}
|
||||
foreach (var item in model)
|
||||
{
|
||||
writer.WritePropertyName(item.Key);
|
||||
writer.WriteObjectValue(item.Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static CatAPTrue Deserialize(JsonElement element)
|
||||
{
|
||||
var result = new CatAPTrue();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("friendly"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Friendly = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("id"))
|
||||
{
|
||||
result.Id = property.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("name"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Name = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("status"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Status = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
result.Add(property.Name, property.Value.GetObject());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class CatAPTrue : PetAPTrue
|
||||
{
|
||||
public bool? Friendly { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class ErrorSerializer
|
||||
{
|
||||
internal static void Serialize(Error model, Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (model.Status != null)
|
||||
{
|
||||
writer.WritePropertyName("status");
|
||||
writer.WriteNumberValue(model.Status.Value);
|
||||
}
|
||||
if (model.Message != null)
|
||||
{
|
||||
writer.WritePropertyName("message");
|
||||
writer.WriteStringValue(model.Message);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static Error Deserialize(JsonElement element)
|
||||
{
|
||||
var result = new Error();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("status"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Status = property.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("message"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Message = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class Error
|
||||
{
|
||||
public int? Status { get; set; }
|
||||
public string? Message { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class PetAPInPropertiesSerializer
|
||||
{
|
||||
internal static void Serialize(PetAPInProperties model, Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("id");
|
||||
writer.WriteNumberValue(model.Id);
|
||||
if (model.Name != null)
|
||||
{
|
||||
writer.WritePropertyName("name");
|
||||
writer.WriteStringValue(model.Name);
|
||||
}
|
||||
if (model.Status != null)
|
||||
{
|
||||
writer.WritePropertyName("status");
|
||||
writer.WriteBooleanValue(model.Status.Value);
|
||||
}
|
||||
if (model.AdditionalProperties != null)
|
||||
{
|
||||
writer.WritePropertyName("additionalProperties");
|
||||
writer.WriteStartObject();
|
||||
foreach (var item in model.AdditionalProperties)
|
||||
{
|
||||
writer.WritePropertyName(item.Key);
|
||||
writer.WriteNumberValue(item.Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static PetAPInProperties Deserialize(JsonElement element)
|
||||
{
|
||||
var result = new PetAPInProperties();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("id"))
|
||||
{
|
||||
result.Id = property.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("name"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Name = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("status"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Status = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("additionalProperties"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.AdditionalProperties = new Dictionary<string, float>();
|
||||
foreach (var item in property.Value.EnumerateObject())
|
||||
{
|
||||
result.AdditionalProperties.Add(item.Name, item.Value.GetSingle());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class PetAPInProperties
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool? Status { get; internal set; }
|
||||
public IDictionary<string, float>? AdditionalProperties { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class PetAPInPropertiesWithAPStringSerializer
|
||||
{
|
||||
internal static void Serialize(PetAPInPropertiesWithAPString model, Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("id");
|
||||
writer.WriteNumberValue(model.Id);
|
||||
if (model.Name != null)
|
||||
{
|
||||
writer.WritePropertyName("name");
|
||||
writer.WriteStringValue(model.Name);
|
||||
}
|
||||
if (model.Status != null)
|
||||
{
|
||||
writer.WritePropertyName("status");
|
||||
writer.WriteBooleanValue(model.Status.Value);
|
||||
}
|
||||
writer.WritePropertyName("@odata.location");
|
||||
writer.WriteStringValue(model.OdataLocation);
|
||||
if (model.AdditionalProperties != null)
|
||||
{
|
||||
writer.WritePropertyName("additionalProperties");
|
||||
writer.WriteStartObject();
|
||||
foreach (var item in model.AdditionalProperties)
|
||||
{
|
||||
writer.WritePropertyName(item.Key);
|
||||
writer.WriteNumberValue(item.Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
foreach (var item in model)
|
||||
{
|
||||
writer.WritePropertyName(item.Key);
|
||||
writer.WriteStringValue(item.Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static PetAPInPropertiesWithAPString Deserialize(JsonElement element)
|
||||
{
|
||||
var result = new PetAPInPropertiesWithAPString();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("id"))
|
||||
{
|
||||
result.Id = property.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("name"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Name = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("status"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Status = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("@odata.location"))
|
||||
{
|
||||
result.OdataLocation = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("additionalProperties"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.AdditionalProperties = new Dictionary<string, float>();
|
||||
foreach (var item in property.Value.EnumerateObject())
|
||||
{
|
||||
result.AdditionalProperties.Add(item.Name, item.Value.GetSingle());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
result.Add(property.Name, property.Value.GetString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class PetAPInPropertiesWithAPString : IDictionary<string, string>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool? Status { get; internal set; }
|
||||
public string OdataLocation { get; set; }
|
||||
public IDictionary<string, float>? AdditionalProperties { get; set; }
|
||||
private readonly IDictionary<string, string> _additionalProperties = new Dictionary<string, string>();
|
||||
public IEnumerator<KeyValuePair<string, string>> GetEnumerator() => _additionalProperties.GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => _additionalProperties.GetEnumerator();
|
||||
public ICollection<string> Keys => _additionalProperties.Keys;
|
||||
public ICollection<string> Values => _additionalProperties.Values;
|
||||
public bool TryGetValue(string key, out string value) => _additionalProperties.TryGetValue(key, out value);
|
||||
public void Add(string key, string value) => _additionalProperties.Add(key, value);
|
||||
public bool ContainsKey(string key) => _additionalProperties.ContainsKey(key);
|
||||
public bool Remove(string key) => _additionalProperties.Remove(key);
|
||||
public int Count => _additionalProperties.Count;
|
||||
bool ICollection<KeyValuePair<string, string>>.IsReadOnly => _additionalProperties.IsReadOnly;
|
||||
void ICollection<KeyValuePair<string, string>>.Add(KeyValuePair<string, string> value) => _additionalProperties.Add(value);
|
||||
bool ICollection<KeyValuePair<string, string>>.Remove(KeyValuePair<string, string> value) => _additionalProperties.Remove(value);
|
||||
bool ICollection<KeyValuePair<string, string>>.Contains(KeyValuePair<string, string> value) => _additionalProperties.Contains(value);
|
||||
void ICollection<KeyValuePair<string, string>>.CopyTo(KeyValuePair<string, string>[] destination, int offset) => _additionalProperties.CopyTo(destination, offset);
|
||||
void ICollection<KeyValuePair<string, string>>.Clear() => _additionalProperties.Clear();
|
||||
public string this[string key]
|
||||
{
|
||||
get => _additionalProperties[key];
|
||||
set => _additionalProperties[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class PetAPObjectSerializer
|
||||
{
|
||||
internal static void Serialize(PetAPObject model, Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("id");
|
||||
writer.WriteNumberValue(model.Id);
|
||||
if (model.Name != null)
|
||||
{
|
||||
writer.WritePropertyName("name");
|
||||
writer.WriteStringValue(model.Name);
|
||||
}
|
||||
if (model.Status != null)
|
||||
{
|
||||
writer.WritePropertyName("status");
|
||||
writer.WriteBooleanValue(model.Status.Value);
|
||||
}
|
||||
foreach (var item in model)
|
||||
{
|
||||
writer.WritePropertyName(item.Key);
|
||||
writer.WriteObjectValue(item.Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static PetAPObject Deserialize(JsonElement element)
|
||||
{
|
||||
var result = new PetAPObject();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("id"))
|
||||
{
|
||||
result.Id = property.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("name"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Name = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("status"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Status = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
result.Add(property.Name, property.Value.GetObject());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class PetAPObject : IDictionary<string, object>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool? Status { get; internal set; }
|
||||
private readonly IDictionary<string, object> _additionalProperties = new Dictionary<string, object>();
|
||||
public IEnumerator<KeyValuePair<string, object>> GetEnumerator() => _additionalProperties.GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => _additionalProperties.GetEnumerator();
|
||||
public ICollection<string> Keys => _additionalProperties.Keys;
|
||||
public ICollection<object> Values => _additionalProperties.Values;
|
||||
public bool TryGetValue(string key, out object value) => _additionalProperties.TryGetValue(key, out value);
|
||||
public void Add(string key, object value) => _additionalProperties.Add(key, value);
|
||||
public bool ContainsKey(string key) => _additionalProperties.ContainsKey(key);
|
||||
public bool Remove(string key) => _additionalProperties.Remove(key);
|
||||
public int Count => _additionalProperties.Count;
|
||||
bool ICollection<KeyValuePair<string, object>>.IsReadOnly => _additionalProperties.IsReadOnly;
|
||||
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> value) => _additionalProperties.Add(value);
|
||||
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> value) => _additionalProperties.Remove(value);
|
||||
bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> value) => _additionalProperties.Contains(value);
|
||||
void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] destination, int offset) => _additionalProperties.CopyTo(destination, offset);
|
||||
void ICollection<KeyValuePair<string, object>>.Clear() => _additionalProperties.Clear();
|
||||
public object this[string key]
|
||||
{
|
||||
get => _additionalProperties[key];
|
||||
set => _additionalProperties[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class PetAPStringSerializer
|
||||
{
|
||||
internal static void Serialize(PetAPString model, Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("id");
|
||||
writer.WriteNumberValue(model.Id);
|
||||
if (model.Name != null)
|
||||
{
|
||||
writer.WritePropertyName("name");
|
||||
writer.WriteStringValue(model.Name);
|
||||
}
|
||||
if (model.Status != null)
|
||||
{
|
||||
writer.WritePropertyName("status");
|
||||
writer.WriteBooleanValue(model.Status.Value);
|
||||
}
|
||||
foreach (var item in model)
|
||||
{
|
||||
writer.WritePropertyName(item.Key);
|
||||
writer.WriteStringValue(item.Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static PetAPString Deserialize(JsonElement element)
|
||||
{
|
||||
var result = new PetAPString();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("id"))
|
||||
{
|
||||
result.Id = property.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("name"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Name = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("status"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Status = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
result.Add(property.Name, property.Value.GetString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class PetAPString : IDictionary<string, string>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool? Status { get; internal set; }
|
||||
private readonly IDictionary<string, string> _additionalProperties = new Dictionary<string, string>();
|
||||
public IEnumerator<KeyValuePair<string, string>> GetEnumerator() => _additionalProperties.GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => _additionalProperties.GetEnumerator();
|
||||
public ICollection<string> Keys => _additionalProperties.Keys;
|
||||
public ICollection<string> Values => _additionalProperties.Values;
|
||||
public bool TryGetValue(string key, out string value) => _additionalProperties.TryGetValue(key, out value);
|
||||
public void Add(string key, string value) => _additionalProperties.Add(key, value);
|
||||
public bool ContainsKey(string key) => _additionalProperties.ContainsKey(key);
|
||||
public bool Remove(string key) => _additionalProperties.Remove(key);
|
||||
public int Count => _additionalProperties.Count;
|
||||
bool ICollection<KeyValuePair<string, string>>.IsReadOnly => _additionalProperties.IsReadOnly;
|
||||
void ICollection<KeyValuePair<string, string>>.Add(KeyValuePair<string, string> value) => _additionalProperties.Add(value);
|
||||
bool ICollection<KeyValuePair<string, string>>.Remove(KeyValuePair<string, string> value) => _additionalProperties.Remove(value);
|
||||
bool ICollection<KeyValuePair<string, string>>.Contains(KeyValuePair<string, string> value) => _additionalProperties.Contains(value);
|
||||
void ICollection<KeyValuePair<string, string>>.CopyTo(KeyValuePair<string, string>[] destination, int offset) => _additionalProperties.CopyTo(destination, offset);
|
||||
void ICollection<KeyValuePair<string, string>>.Clear() => _additionalProperties.Clear();
|
||||
public string this[string key]
|
||||
{
|
||||
get => _additionalProperties[key];
|
||||
set => _additionalProperties[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class PetAPTrueSerializer
|
||||
{
|
||||
internal static void Serialize(PetAPTrue model, Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("id");
|
||||
writer.WriteNumberValue(model.Id);
|
||||
if (model.Name != null)
|
||||
{
|
||||
writer.WritePropertyName("name");
|
||||
writer.WriteStringValue(model.Name);
|
||||
}
|
||||
if (model.Status != null)
|
||||
{
|
||||
writer.WritePropertyName("status");
|
||||
writer.WriteBooleanValue(model.Status.Value);
|
||||
}
|
||||
foreach (var item in model)
|
||||
{
|
||||
writer.WritePropertyName(item.Key);
|
||||
writer.WriteObjectValue(item.Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static PetAPTrue Deserialize(JsonElement element)
|
||||
{
|
||||
var result = new PetAPTrue();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("id"))
|
||||
{
|
||||
result.Id = property.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("name"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Name = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("status"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Status = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
result.Add(property.Name, property.Value.GetObject());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace additionalProperties.Models.V100
|
||||
{
|
||||
public partial class PetAPTrue : IDictionary<string, object>
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public bool? Status { get; internal set; }
|
||||
private readonly IDictionary<string, object> _additionalProperties = new Dictionary<string, object>();
|
||||
public IEnumerator<KeyValuePair<string, object>> GetEnumerator() => _additionalProperties.GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => _additionalProperties.GetEnumerator();
|
||||
public ICollection<string> Keys => _additionalProperties.Keys;
|
||||
public ICollection<object> Values => _additionalProperties.Values;
|
||||
public bool TryGetValue(string key, out object value) => _additionalProperties.TryGetValue(key, out value);
|
||||
public void Add(string key, object value) => _additionalProperties.Add(key, value);
|
||||
public bool ContainsKey(string key) => _additionalProperties.ContainsKey(key);
|
||||
public bool Remove(string key) => _additionalProperties.Remove(key);
|
||||
public int Count => _additionalProperties.Count;
|
||||
bool ICollection<KeyValuePair<string, object>>.IsReadOnly => _additionalProperties.IsReadOnly;
|
||||
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> value) => _additionalProperties.Add(value);
|
||||
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> value) => _additionalProperties.Remove(value);
|
||||
bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> value) => _additionalProperties.Contains(value);
|
||||
void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] destination, int offset) => _additionalProperties.CopyTo(destination, offset);
|
||||
void ICollection<KeyValuePair<string, object>>.Clear() => _additionalProperties.Clear();
|
||||
public object this[string key]
|
||||
{
|
||||
get => _additionalProperties[key];
|
||||
set => _additionalProperties[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,276 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using additionalProperties.Models.V100;
|
||||
using Azure;
|
||||
using Azure.Core;
|
||||
using Azure.Core.Pipeline;
|
||||
|
||||
namespace additionalProperties
|
||||
{
|
||||
internal static class PetsOperations
|
||||
{
|
||||
public static async ValueTask<Response<PetAPTrue>> CreateAPTrueAsync(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, PetAPTrue createParameters, string host = "http://localhost:3000", CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (host == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(host));
|
||||
}
|
||||
if (createParameters == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(createParameters));
|
||||
}
|
||||
|
||||
using var scope = clientDiagnostics.CreateScope("additionalProperties.CreateAPTrue");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
var request = pipeline.CreateRequest();
|
||||
request.Method = RequestMethod.Put;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/additionalProperties/true", false);
|
||||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
PetAPTrueSerializer.Serialize(createParameters, writer);
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = PetAPTrueSerializer.Deserialize(document.RootElement);
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public static async ValueTask<Response<CatAPTrue>> CreateCatAPTrueAsync(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, CatAPTrue createParameters, string host = "http://localhost:3000", CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (host == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(host));
|
||||
}
|
||||
if (createParameters == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(createParameters));
|
||||
}
|
||||
|
||||
using var scope = clientDiagnostics.CreateScope("additionalProperties.CreateCatAPTrue");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
var request = pipeline.CreateRequest();
|
||||
request.Method = RequestMethod.Put;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/additionalProperties/true-subclass", false);
|
||||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
CatAPTrueSerializer.Serialize(createParameters, writer);
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = CatAPTrueSerializer.Deserialize(document.RootElement);
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public static async ValueTask<Response<PetAPObject>> CreateAPObjectAsync(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, PetAPObject createParameters, string host = "http://localhost:3000", CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (host == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(host));
|
||||
}
|
||||
if (createParameters == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(createParameters));
|
||||
}
|
||||
|
||||
using var scope = clientDiagnostics.CreateScope("additionalProperties.CreateAPObject");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
var request = pipeline.CreateRequest();
|
||||
request.Method = RequestMethod.Put;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/additionalProperties/type/object", false);
|
||||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
PetAPObjectSerializer.Serialize(createParameters, writer);
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = PetAPObjectSerializer.Deserialize(document.RootElement);
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public static async ValueTask<Response<PetAPString>> CreateAPStringAsync(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, PetAPString createParameters, string host = "http://localhost:3000", CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (host == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(host));
|
||||
}
|
||||
if (createParameters == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(createParameters));
|
||||
}
|
||||
|
||||
using var scope = clientDiagnostics.CreateScope("additionalProperties.CreateAPString");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
var request = pipeline.CreateRequest();
|
||||
request.Method = RequestMethod.Put;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/additionalProperties/type/string", false);
|
||||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
PetAPStringSerializer.Serialize(createParameters, writer);
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = PetAPStringSerializer.Deserialize(document.RootElement);
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public static async ValueTask<Response<PetAPInProperties>> CreateAPInPropertiesAsync(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, PetAPInProperties createParameters, string host = "http://localhost:3000", CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (host == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(host));
|
||||
}
|
||||
if (createParameters == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(createParameters));
|
||||
}
|
||||
|
||||
using var scope = clientDiagnostics.CreateScope("additionalProperties.CreateAPInProperties");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
var request = pipeline.CreateRequest();
|
||||
request.Method = RequestMethod.Put;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
request.Uri.AppendPath("/additionalProperties/in/properties", false);
|
||||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
PetAPInPropertiesSerializer.Serialize(createParameters, writer);
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = PetAPInPropertiesSerializer.Deserialize(document.RootElement);
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public static async ValueTask<Response<PetAPInPropertiesWithAPString>> CreateAPInPropertiesWithAPStringAsync(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, PetAPInPropertiesWithAPString createParameters, string host = "http://localhost:3000", CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (host == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(host));
|
||||
}
|
||||
if (createParameters == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(createParameters));
|
||||
}
|
||||
|
||||
using var scope = clientDiagnostics.CreateScope("additionalProperties.CreateAPInPropertiesWithAPString");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
var request = pipeline.CreateRequest();
|
||||
request.Method = RequestMethod.Put;
|
||||
request.Uri.Reset(new Uri($"{host}"));
|
||||
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;
|
||||
PetAPInPropertiesWithAPStringSerializer.Serialize(createParameters, writer);
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = PetAPInPropertiesWithAPStringSerializer.Deserialize(document.RootElement);
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
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.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_boolean.Models.V100
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -13,7 +14,8 @@ namespace body_complex.Models.V20160229
|
|||
writer.WriteStartObject();
|
||||
if (model.Array != null)
|
||||
{
|
||||
writer.WriteStartArray("array");
|
||||
writer.WritePropertyName("array");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.Array)
|
||||
{
|
||||
writer.WriteStringValue(item);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -18,14 +19,14 @@ namespace body_complex.Models.V20160229
|
|||
}
|
||||
if (model.Hates != null)
|
||||
{
|
||||
writer.WriteStartArray("hates");
|
||||
writer.WritePropertyName("hates");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.Hates)
|
||||
{
|
||||
DogSerializer.Serialize(item, writer);
|
||||
}
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
|
||||
if (model.Id != null)
|
||||
{
|
||||
writer.WritePropertyName("id");
|
||||
|
@ -65,7 +66,6 @@ namespace body_complex.Models.V20160229
|
|||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("id"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -11,15 +12,13 @@ namespace body_complex.Models.V20160229
|
|||
internal static void Serialize(Cookiecuttershark model, Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
if (model.Age != null)
|
||||
{
|
||||
writer.WritePropertyName("age");
|
||||
writer.WriteNumberValue(model.Age.Value);
|
||||
}
|
||||
writer.WritePropertyName("birthday");
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, model.Birthday, "S");
|
||||
|
||||
writer.WriteStringValue(model.Birthday, "S");
|
||||
writer.WritePropertyName("fishtype");
|
||||
writer.WriteStringValue(model.Fishtype);
|
||||
if (model.Species != null)
|
||||
|
@ -31,7 +30,8 @@ namespace body_complex.Models.V20160229
|
|||
writer.WriteNumberValue(model.Length);
|
||||
if (model.Siblings != null)
|
||||
{
|
||||
writer.WriteStartArray("siblings");
|
||||
writer.WritePropertyName("siblings");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.Siblings)
|
||||
{
|
||||
FishSerializer.Serialize(item, writer);
|
||||
|
@ -45,7 +45,6 @@ namespace body_complex.Models.V20160229
|
|||
var result = new Cookiecuttershark();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
|
||||
if (property.NameEquals("age"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
|
@ -57,10 +56,9 @@ namespace body_complex.Models.V20160229
|
|||
}
|
||||
if (property.NameEquals("birthday"))
|
||||
{
|
||||
result.Birthday = Azure.Core.TypeFormatters.GetDateTimeOffset(property.Value, "S");
|
||||
result.Birthday = property.Value.GetDateTimeOffset("S");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("fishtype"))
|
||||
{
|
||||
result.Fishtype = property.Value.GetString();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -13,12 +14,12 @@ namespace body_complex.Models.V20160229
|
|||
if (model.Field != null)
|
||||
{
|
||||
writer.WritePropertyName("field");
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, model.Field.Value, "D");
|
||||
writer.WriteStringValue(model.Field.Value, "D");
|
||||
}
|
||||
if (model.Leap != null)
|
||||
{
|
||||
writer.WritePropertyName("leap");
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, model.Leap.Value, "D");
|
||||
writer.WriteStringValue(model.Leap.Value, "D");
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ namespace body_complex.Models.V20160229
|
|||
{
|
||||
continue;
|
||||
}
|
||||
result.Field = Azure.Core.TypeFormatters.GetDateTimeOffset(property.Value, "D");
|
||||
result.Field = property.Value.GetDateTimeOffset("D");
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("leap"))
|
||||
|
@ -42,7 +43,7 @@ namespace body_complex.Models.V20160229
|
|||
{
|
||||
continue;
|
||||
}
|
||||
result.Leap = Azure.Core.TypeFormatters.GetDateTimeOffset(property.Value, "D");
|
||||
result.Leap = property.Value.GetDateTimeOffset("D");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -13,12 +14,12 @@ namespace body_complex.Models.V20160229
|
|||
if (model.Field != null)
|
||||
{
|
||||
writer.WritePropertyName("field");
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, model.Field.Value, "S");
|
||||
writer.WriteStringValue(model.Field.Value, "S");
|
||||
}
|
||||
if (model.Now != null)
|
||||
{
|
||||
writer.WritePropertyName("now");
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, model.Now.Value, "S");
|
||||
writer.WriteStringValue(model.Now.Value, "S");
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ namespace body_complex.Models.V20160229
|
|||
{
|
||||
continue;
|
||||
}
|
||||
result.Field = Azure.Core.TypeFormatters.GetDateTimeOffset(property.Value, "S");
|
||||
result.Field = property.Value.GetDateTimeOffset("S");
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("now"))
|
||||
|
@ -42,7 +43,7 @@ namespace body_complex.Models.V20160229
|
|||
{
|
||||
continue;
|
||||
}
|
||||
result.Now = Azure.Core.TypeFormatters.GetDateTimeOffset(property.Value, "S");
|
||||
result.Now = property.Value.GetDateTimeOffset("S");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -13,12 +14,12 @@ namespace body_complex.Models.V20160229
|
|||
if (model.Field != null)
|
||||
{
|
||||
writer.WritePropertyName("field");
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, model.Field.Value, "R");
|
||||
writer.WriteStringValue(model.Field.Value, "R");
|
||||
}
|
||||
if (model.Now != null)
|
||||
{
|
||||
writer.WritePropertyName("now");
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, model.Now.Value, "R");
|
||||
writer.WriteStringValue(model.Now.Value, "R");
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ namespace body_complex.Models.V20160229
|
|||
{
|
||||
continue;
|
||||
}
|
||||
result.Field = Azure.Core.TypeFormatters.GetDateTimeOffset(property.Value, "R");
|
||||
result.Field = property.Value.GetDateTimeOffset("R");
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("now"))
|
||||
|
@ -42,7 +43,7 @@ namespace body_complex.Models.V20160229
|
|||
{
|
||||
continue;
|
||||
}
|
||||
result.Now = Azure.Core.TypeFormatters.GetDateTimeOffset(property.Value, "R");
|
||||
result.Now = property.Value.GetDateTimeOffset("R");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -13,7 +14,8 @@ namespace body_complex.Models.V20160229
|
|||
writer.WriteStartObject();
|
||||
if (model.DefaultProgram != null)
|
||||
{
|
||||
writer.WriteStartObject("defaultProgram");
|
||||
writer.WritePropertyName("defaultProgram");
|
||||
writer.WriteStartObject();
|
||||
foreach (var item in model.DefaultProgram)
|
||||
{
|
||||
writer.WritePropertyName(item.Key);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -15,7 +16,6 @@ namespace body_complex.Models.V20160229
|
|||
writer.WritePropertyName("food");
|
||||
writer.WriteStringValue(model.Food);
|
||||
}
|
||||
|
||||
if (model.Id != null)
|
||||
{
|
||||
writer.WritePropertyName("id");
|
||||
|
@ -42,7 +42,6 @@ namespace body_complex.Models.V20160229
|
|||
result.Food = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("id"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -18,7 +19,8 @@ namespace body_complex.Models.V20160229
|
|||
}
|
||||
if (model.Salmons != null)
|
||||
{
|
||||
writer.WriteStartArray("salmons");
|
||||
writer.WritePropertyName("salmons");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.Salmons)
|
||||
{
|
||||
DotSalmonSerializer.Serialize(item, writer);
|
||||
|
@ -32,7 +34,8 @@ namespace body_complex.Models.V20160229
|
|||
}
|
||||
if (model.Fishes != null)
|
||||
{
|
||||
writer.WriteStartArray("fishes");
|
||||
writer.WritePropertyName("fishes");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.Fishes)
|
||||
{
|
||||
DotFishSerializer.Serialize(item, writer);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -20,7 +21,6 @@ namespace body_complex.Models.V20160229
|
|||
writer.WritePropertyName("iswild");
|
||||
writer.WriteBooleanValue(model.Iswild.Value);
|
||||
}
|
||||
|
||||
writer.WritePropertyName("fish.type");
|
||||
writer.WriteStringValue(model.FishType);
|
||||
if (model.Species != null)
|
||||
|
@ -53,7 +53,6 @@ namespace body_complex.Models.V20160229
|
|||
result.Iswild = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("fish.type"))
|
||||
{
|
||||
result.FishType = property.Value.GetString();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -13,7 +14,7 @@ namespace body_complex.Models.V20160229
|
|||
if (model.Field != null)
|
||||
{
|
||||
writer.WritePropertyName("field");
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, model.Field.Value, "P");
|
||||
writer.WriteStringValue(model.Field.Value, "P");
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
@ -28,7 +29,7 @@ namespace body_complex.Models.V20160229
|
|||
{
|
||||
continue;
|
||||
}
|
||||
result.Field = Azure.Core.TypeFormatters.GetTimeSpan(property.Value, "P");
|
||||
result.Field = property.Value.GetTimeSpan("P");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -31,7 +32,8 @@ namespace body_complex.Models.V20160229
|
|||
writer.WriteNumberValue(model.Length);
|
||||
if (model.Siblings != null)
|
||||
{
|
||||
writer.WriteStartArray("siblings");
|
||||
writer.WritePropertyName("siblings");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.Siblings)
|
||||
{
|
||||
FishSerializer.Serialize(item, writer);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -21,15 +22,13 @@ namespace body_complex.Models.V20160229
|
|||
writer.WritePropertyName("color");
|
||||
writer.WriteStringValue(model.Color.ToString());
|
||||
}
|
||||
|
||||
if (model.Age != null)
|
||||
{
|
||||
writer.WritePropertyName("age");
|
||||
writer.WriteNumberValue(model.Age.Value);
|
||||
}
|
||||
writer.WritePropertyName("birthday");
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, model.Birthday, "S");
|
||||
|
||||
writer.WriteStringValue(model.Birthday, "S");
|
||||
writer.WritePropertyName("fishtype");
|
||||
writer.WriteStringValue(model.Fishtype);
|
||||
if (model.Species != null)
|
||||
|
@ -41,7 +40,8 @@ namespace body_complex.Models.V20160229
|
|||
writer.WriteNumberValue(model.Length);
|
||||
if (model.Siblings != null)
|
||||
{
|
||||
writer.WriteStartArray("siblings");
|
||||
writer.WritePropertyName("siblings");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.Siblings)
|
||||
{
|
||||
FishSerializer.Serialize(item, writer);
|
||||
|
@ -73,7 +73,6 @@ namespace body_complex.Models.V20160229
|
|||
result.Color = new GoblinSharkColor(property.Value.GetString());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("age"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
|
@ -85,10 +84,9 @@ namespace body_complex.Models.V20160229
|
|||
}
|
||||
if (property.NameEquals("birthday"))
|
||||
{
|
||||
result.Birthday = Azure.Core.TypeFormatters.GetDateTimeOffset(property.Value, "S");
|
||||
result.Birthday = property.Value.GetDateTimeOffset("S");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("fishtype"))
|
||||
{
|
||||
result.Fishtype = property.Value.GetString();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -15,7 +16,6 @@ namespace body_complex.Models.V20160229
|
|||
writer.WritePropertyName("propD1");
|
||||
writer.WriteStringValue(model.PropD1);
|
||||
}
|
||||
|
||||
writer.WritePropertyName("kind");
|
||||
writer.WriteStringValue(model.Kind);
|
||||
if (model.PropB1 != null)
|
||||
|
@ -44,7 +44,6 @@ namespace body_complex.Models.V20160229
|
|||
result.PropD1 = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("kind"))
|
||||
{
|
||||
result.Kind = property.Value.GetString();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -27,7 +28,6 @@ namespace body_complex.Models.V20160229
|
|||
writer.WritePropertyName("iswild");
|
||||
writer.WriteBooleanValue(model.Iswild.Value);
|
||||
}
|
||||
|
||||
writer.WritePropertyName("fishtype");
|
||||
writer.WriteStringValue(model.Fishtype);
|
||||
if (model.Species != null)
|
||||
|
@ -39,7 +39,8 @@ namespace body_complex.Models.V20160229
|
|||
writer.WriteNumberValue(model.Length);
|
||||
if (model.Siblings != null)
|
||||
{
|
||||
writer.WriteStartArray("siblings");
|
||||
writer.WritePropertyName("siblings");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.Siblings)
|
||||
{
|
||||
FishSerializer.Serialize(item, writer);
|
||||
|
@ -78,7 +79,6 @@ namespace body_complex.Models.V20160229
|
|||
result.Iswild = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("fishtype"))
|
||||
{
|
||||
result.Fishtype = property.Value.GetString();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -16,15 +17,13 @@ namespace body_complex.Models.V20160229
|
|||
writer.WritePropertyName("picture");
|
||||
writer.WriteBase64StringValue(model.Picture);
|
||||
}
|
||||
|
||||
if (model.Age != null)
|
||||
{
|
||||
writer.WritePropertyName("age");
|
||||
writer.WriteNumberValue(model.Age.Value);
|
||||
}
|
||||
writer.WritePropertyName("birthday");
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, model.Birthday, "S");
|
||||
|
||||
writer.WriteStringValue(model.Birthday, "S");
|
||||
writer.WritePropertyName("fishtype");
|
||||
writer.WriteStringValue(model.Fishtype);
|
||||
if (model.Species != null)
|
||||
|
@ -36,7 +35,8 @@ namespace body_complex.Models.V20160229
|
|||
writer.WriteNumberValue(model.Length);
|
||||
if (model.Siblings != null)
|
||||
{
|
||||
writer.WriteStartArray("siblings");
|
||||
writer.WritePropertyName("siblings");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.Siblings)
|
||||
{
|
||||
FishSerializer.Serialize(item, writer);
|
||||
|
@ -59,7 +59,6 @@ namespace body_complex.Models.V20160229
|
|||
result.Picture = property.Value.GetBytesFromBase64();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("age"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
|
@ -71,10 +70,9 @@ namespace body_complex.Models.V20160229
|
|||
}
|
||||
if (property.NameEquals("birthday"))
|
||||
{
|
||||
result.Birthday = Azure.Core.TypeFormatters.GetDateTimeOffset(property.Value, "S");
|
||||
result.Birthday = property.Value.GetDateTimeOffset("S");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("fishtype"))
|
||||
{
|
||||
result.Fishtype = property.Value.GetString();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -29,8 +30,7 @@ namespace body_complex.Models.V20160229
|
|||
writer.WriteNumberValue(model.Age.Value);
|
||||
}
|
||||
writer.WritePropertyName("birthday");
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, model.Birthday, "S");
|
||||
|
||||
writer.WriteStringValue(model.Birthday, "S");
|
||||
writer.WritePropertyName("fishtype");
|
||||
writer.WriteStringValue(model.Fishtype);
|
||||
if (model.Species != null)
|
||||
|
@ -42,7 +42,8 @@ namespace body_complex.Models.V20160229
|
|||
writer.WriteNumberValue(model.Length);
|
||||
if (model.Siblings != null)
|
||||
{
|
||||
writer.WriteStartArray("siblings");
|
||||
writer.WritePropertyName("siblings");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.Siblings)
|
||||
{
|
||||
FishSerializer.Serialize(item, writer);
|
||||
|
@ -76,10 +77,9 @@ namespace body_complex.Models.V20160229
|
|||
}
|
||||
if (property.NameEquals("birthday"))
|
||||
{
|
||||
result.Birthday = Azure.Core.TypeFormatters.GetDateTimeOffset(property.Value, "S");
|
||||
result.Birthday = property.Value.GetDateTimeOffset("S");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("fishtype"))
|
||||
{
|
||||
result.Fishtype = property.Value.GetString();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -16,7 +17,6 @@ namespace body_complex.Models.V20160229
|
|||
writer.WritePropertyName("breed");
|
||||
writer.WriteStringValue(model.Breed);
|
||||
}
|
||||
|
||||
if (model.Color != null)
|
||||
{
|
||||
writer.WritePropertyName("color");
|
||||
|
@ -24,14 +24,14 @@ namespace body_complex.Models.V20160229
|
|||
}
|
||||
if (model.Hates != null)
|
||||
{
|
||||
writer.WriteStartArray("hates");
|
||||
writer.WritePropertyName("hates");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.Hates)
|
||||
{
|
||||
DogSerializer.Serialize(item, writer);
|
||||
}
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
|
||||
if (model.Id != null)
|
||||
{
|
||||
writer.WritePropertyName("id");
|
||||
|
@ -58,7 +58,6 @@ namespace body_complex.Models.V20160229
|
|||
result.Breed = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("color"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
|
@ -81,7 +80,6 @@ namespace body_complex.Models.V20160229
|
|||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("id"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
@ -16,7 +17,6 @@ namespace body_complex.Models.V20160229
|
|||
writer.WritePropertyName("college_degree");
|
||||
writer.WriteStringValue(model.CollegeDegree);
|
||||
}
|
||||
|
||||
if (model.Location != null)
|
||||
{
|
||||
writer.WritePropertyName("location");
|
||||
|
@ -27,7 +27,6 @@ namespace body_complex.Models.V20160229
|
|||
writer.WritePropertyName("iswild");
|
||||
writer.WriteBooleanValue(model.Iswild.Value);
|
||||
}
|
||||
|
||||
writer.WritePropertyName("fishtype");
|
||||
writer.WriteStringValue(model.Fishtype);
|
||||
if (model.Species != null)
|
||||
|
@ -39,13 +38,19 @@ namespace body_complex.Models.V20160229
|
|||
writer.WriteNumberValue(model.Length);
|
||||
if (model.Siblings != null)
|
||||
{
|
||||
writer.WriteStartArray("siblings");
|
||||
writer.WritePropertyName("siblings");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.Siblings)
|
||||
{
|
||||
FishSerializer.Serialize(item, writer);
|
||||
}
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
foreach (var item in model)
|
||||
{
|
||||
writer.WritePropertyName(item.Key);
|
||||
writer.WriteObjectValue(item.Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static SmartSalmon Deserialize(JsonElement element)
|
||||
|
@ -62,7 +67,6 @@ namespace body_complex.Models.V20160229
|
|||
result.CollegeDegree = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("location"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
|
@ -81,7 +85,6 @@ namespace body_complex.Models.V20160229
|
|||
result.Iswild = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (property.NameEquals("fishtype"))
|
||||
{
|
||||
result.Fishtype = property.Value.GetString();
|
||||
|
@ -114,6 +117,7 @@ namespace body_complex.Models.V20160229
|
|||
}
|
||||
continue;
|
||||
}
|
||||
result.Add(property.Name, property.Value.GetObject());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,38 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
public partial class SmartSalmon : Salmon
|
||||
public partial class SmartSalmon : Salmon, IDictionary<string, object>
|
||||
{
|
||||
public SmartSalmon()
|
||||
{
|
||||
Fishtype = "smart_salmon";
|
||||
}
|
||||
public string? CollegeDegree { get; set; }
|
||||
private readonly IDictionary<string, object> _additionalProperties = new Dictionary<string, object>();
|
||||
public IEnumerator<KeyValuePair<string, object>> GetEnumerator() => _additionalProperties.GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => _additionalProperties.GetEnumerator();
|
||||
public ICollection<string> Keys => _additionalProperties.Keys;
|
||||
public ICollection<object> Values => _additionalProperties.Values;
|
||||
public bool TryGetValue(string key, out object value) => _additionalProperties.TryGetValue(key, out value);
|
||||
public void Add(string key, object value) => _additionalProperties.Add(key, value);
|
||||
public bool ContainsKey(string key) => _additionalProperties.ContainsKey(key);
|
||||
public bool Remove(string key) => _additionalProperties.Remove(key);
|
||||
public int Count => _additionalProperties.Count;
|
||||
bool ICollection<KeyValuePair<string, object>>.IsReadOnly => _additionalProperties.IsReadOnly;
|
||||
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> value) => _additionalProperties.Add(value);
|
||||
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> value) => _additionalProperties.Remove(value);
|
||||
bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> value) => _additionalProperties.Contains(value);
|
||||
void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] destination, int offset) => _additionalProperties.CopyTo(destination, offset);
|
||||
void ICollection<KeyValuePair<string, object>>.Clear() => _additionalProperties.Clear();
|
||||
public object this[string key]
|
||||
{
|
||||
get => _additionalProperties[key];
|
||||
set => _additionalProperties[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_complex.Models.V20160229
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_date.Models.V100
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace body_date
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "D");
|
||||
var value = document.RootElement.GetDateTimeOffset("D");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -68,7 +68,7 @@ namespace body_date
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "D");
|
||||
var value = document.RootElement.GetDateTimeOffset("D");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -102,7 +102,7 @@ namespace body_date
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "D");
|
||||
var value = document.RootElement.GetDateTimeOffset("D");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -136,7 +136,7 @@ namespace body_date
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "D");
|
||||
var value = document.RootElement.GetDateTimeOffset("D");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -167,7 +167,7 @@ namespace body_date
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, dateBody, "D");
|
||||
writer.WriteStringValue(dateBody, "D");
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
@ -205,7 +205,7 @@ namespace body_date
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "D");
|
||||
var value = document.RootElement.GetDateTimeOffset("D");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -236,7 +236,7 @@ namespace body_date
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, dateBody, "D");
|
||||
writer.WriteStringValue(dateBody, "D");
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
@ -274,7 +274,7 @@ namespace body_date
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "D");
|
||||
var value = document.RootElement.GetDateTimeOffset("D");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_datetime_rfc1123.Models.V100
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace body_datetime_rfc1123
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "R");
|
||||
var value = document.RootElement.GetDateTimeOffset("R");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -68,7 +68,7 @@ namespace body_datetime_rfc1123
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "R");
|
||||
var value = document.RootElement.GetDateTimeOffset("R");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -102,7 +102,7 @@ namespace body_datetime_rfc1123
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "R");
|
||||
var value = document.RootElement.GetDateTimeOffset("R");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -136,7 +136,7 @@ namespace body_datetime_rfc1123
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "R");
|
||||
var value = document.RootElement.GetDateTimeOffset("R");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -167,7 +167,7 @@ namespace body_datetime_rfc1123
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, datetimeBody, "R");
|
||||
writer.WriteStringValue(datetimeBody, "R");
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
@ -205,7 +205,7 @@ namespace body_datetime_rfc1123
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "R");
|
||||
var value = document.RootElement.GetDateTimeOffset("R");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -239,7 +239,7 @@ namespace body_datetime_rfc1123
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "R");
|
||||
var value = document.RootElement.GetDateTimeOffset("R");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -270,7 +270,7 @@ namespace body_datetime_rfc1123
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, datetimeBody, "R");
|
||||
writer.WriteStringValue(datetimeBody, "R");
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
@ -308,7 +308,7 @@ namespace body_datetime_rfc1123
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "R");
|
||||
var value = document.RootElement.GetDateTimeOffset("R");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_datetime.Models.V100
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -68,7 +68,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -102,7 +102,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -136,7 +136,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -167,7 +167,7 @@ namespace body_datetime
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, datetimeBody, "S");
|
||||
writer.WriteStringValue(datetimeBody, "S");
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
@ -205,7 +205,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -239,7 +239,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -270,7 +270,7 @@ namespace body_datetime
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, datetimeBody, "S");
|
||||
writer.WriteStringValue(datetimeBody, "S");
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
@ -308,7 +308,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -342,7 +342,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -373,7 +373,7 @@ namespace body_datetime
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, datetimeBody, "S");
|
||||
writer.WriteStringValue(datetimeBody, "S");
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
@ -411,7 +411,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -445,7 +445,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -476,7 +476,7 @@ namespace body_datetime
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, datetimeBody, "S");
|
||||
writer.WriteStringValue(datetimeBody, "S");
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
@ -514,7 +514,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -545,7 +545,7 @@ namespace body_datetime
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, datetimeBody, "S");
|
||||
writer.WriteStringValue(datetimeBody, "S");
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
@ -583,7 +583,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -614,7 +614,7 @@ namespace body_datetime
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, datetimeBody, "S");
|
||||
writer.WriteStringValue(datetimeBody, "S");
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
@ -652,7 +652,7 @@ namespace body_datetime
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "S");
|
||||
var value = document.RootElement.GetDateTimeOffset("S");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_duration.Models.V100
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace body_duration
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetTimeSpan(document.RootElement, "P");
|
||||
var value = document.RootElement.GetTimeSpan("P");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -65,7 +65,7 @@ namespace body_duration
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, durationBody, "P");
|
||||
writer.WriteStringValue(durationBody, "P");
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
@ -103,7 +103,7 @@ namespace body_duration
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetTimeSpan(document.RootElement, "P");
|
||||
var value = document.RootElement.GetTimeSpan("P");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -137,7 +137,7 @@ namespace body_duration
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetTimeSpan(document.RootElement, "P");
|
||||
var value = document.RootElement.GetTimeSpan("P");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_integer.Models.V100
|
||||
{
|
||||
|
|
|
@ -378,7 +378,7 @@ namespace body_integer
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "U");
|
||||
var value = document.RootElement.GetDateTimeOffset("U");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -409,7 +409,7 @@ namespace body_integer
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
Azure.Core.Utf8JsonWriterExtensions.WriteStringValue(writer, intBody, "U");
|
||||
writer.WriteStringValue(intBody, "U");
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
@ -447,7 +447,7 @@ namespace body_integer
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "U");
|
||||
var value = document.RootElement.GetDateTimeOffset("U");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
@ -481,7 +481,7 @@ namespace body_integer
|
|||
case 200:
|
||||
{
|
||||
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
var value = Azure.Core.TypeFormatters.GetDateTimeOffset(document.RootElement, "U");
|
||||
var value = document.RootElement.GetDateTimeOffset("U");
|
||||
return Response.FromValue(value, response);
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_number.Models.V100
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_string.Models.V100
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace body_string.Models.V100
|
||||
{
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace body_string
|
|||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
var writer = content.JsonWriter;
|
||||
writer.WriteStringValue("");
|
||||
writer.WriteStringValue((string?)null);
|
||||
request.Content = content;
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
switch (response.Status)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace custom_baseUrl_more_options.Models.V100
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace custom_baseUrl.Models.V100
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace extensible_enums_swagger.Models.V20160707
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace header.Models.V100
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace url_multi_collectionFormat.Models.V100
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace url.Models.V100
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace validation.Models.V100
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace validation.Models.V100
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace validation.Models.V100
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace validation.Models.V100
|
||||
{
|
||||
|
@ -13,7 +14,8 @@ namespace validation.Models.V100
|
|||
writer.WriteStartObject();
|
||||
if (model.DisplayNames != null)
|
||||
{
|
||||
writer.WriteStartArray("display_names");
|
||||
writer.WritePropertyName("display_names");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in model.DisplayNames)
|
||||
{
|
||||
writer.WriteStringValue(item);
|
||||
|
|
Двоичные данные
test/scripts/TestList.txt
Двоичные данные
test/scripts/TestList.txt
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче