diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/SampleTypeSpecContext.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/SampleTypeSpecContext.cs index acbd82d2f33..9e380357e68 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/SampleTypeSpecContext.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/SampleTypeSpecContext.cs @@ -30,6 +30,9 @@ namespace SampleTypeSpec [ModelReaderWriterBuildable(typeof(Thing))] [ModelReaderWriterBuildable(typeof(UnknownAnimal))] [ModelReaderWriterBuildable(typeof(UnknownPet))] + [ModelReaderWriterBuildable(typeof(XmlAdvancedModel))] + [ModelReaderWriterBuildable(typeof(XmlItem))] + [ModelReaderWriterBuildable(typeof(XmlNestedModel))] public partial class SampleTypeSpecContext : ModelReaderWriterContext { } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlAdvancedModel.Serialization.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlAdvancedModel.Serialization.cs new file mode 100644 index 00000000000..21a8c34ce20 --- /dev/null +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlAdvancedModel.Serialization.cs @@ -0,0 +1,483 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace SampleTypeSpec +{ + /// An advanced XML model for testing various property types and XML features. + public partial class XmlAdvancedModel : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal XmlAdvancedModel() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(XmlAdvancedModel)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("age"u8); + writer.WriteNumberValue(Age); + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled); + writer.WritePropertyName("score"u8); + writer.WriteNumberValue(Score); + if (Optional.IsDefined(OptionalString)) + { + writer.WritePropertyName("optionalString"u8); + writer.WriteStringValue(OptionalString); + } + if (Optional.IsDefined(OptionalInt)) + { + writer.WritePropertyName("optionalInt"u8); + writer.WriteNumberValue(OptionalInt.Value); + } + if (Optional.IsDefined(NullableString)) + { + writer.WritePropertyName("nullableString"u8); + writer.WriteStringValue(NullableString); + } + else + { + writer.WriteNull("nullableString"u8); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("version"u8); + writer.WriteNumberValue(Version); + writer.WritePropertyName("isActive"u8); + writer.WriteBooleanValue(IsActive); + writer.WritePropertyName("RenamedProperty"u8); + writer.WriteStringValue(OriginalName); + writer.WritePropertyName("xml-id"u8); + writer.WriteStringValue(XmlIdentifier); + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + writer.WritePropertyName("unwrappedStrings"u8); + writer.WriteStartArray(); + foreach (string item in UnwrappedStrings) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("unwrappedCounts"u8); + writer.WriteStartArray(); + foreach (int item in UnwrappedCounts) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("unwrappedItems"u8); + writer.WriteStartArray(); + foreach (XmlItem item in UnwrappedItems) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("wrappedColors"u8); + writer.WriteStartArray(); + foreach (string item in WrappedColors) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("ItemCollection"u8); + writer.WriteStartArray(); + foreach (XmlItem item in Items) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("nestedModel"u8); + writer.WriteObjectValue(NestedModel, options); + if (Optional.IsDefined(OptionalNestedModel)) + { + writer.WritePropertyName("optionalNestedModel"u8); + writer.WriteObjectValue(OptionalNestedModel, options); + } + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + writer.WritePropertyName("createdAt"u8); + writer.WriteStringValue(CreatedAt, "O"); + writer.WritePropertyName("duration"u8); + writer.WriteStringValue(Duration, "P"); + writer.WritePropertyName("data"u8); + writer.WriteBase64StringValue(Data.ToArray(), "D"); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + XmlAdvancedModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual XmlAdvancedModel JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(XmlAdvancedModel)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeXmlAdvancedModel(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static XmlAdvancedModel DeserializeXmlAdvancedModel(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + int age = default; + bool enabled = default; + float score = default; + string optionalString = default; + int? optionalInt = default; + string nullableString = default; + string id = default; + int version = default; + bool isActive = default; + string originalName = default; + string xmlIdentifier = default; + string content = default; + IList unwrappedStrings = default; + IList unwrappedCounts = default; + IList unwrappedItems = default; + IList wrappedColors = default; + IList items = default; + XmlNestedModel nestedModel = default; + XmlNestedModel optionalNestedModel = default; + IDictionary metadata = default; + DateTimeOffset createdAt = default; + TimeSpan duration = default; + BinaryData data = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("age"u8)) + { + age = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("enabled"u8)) + { + enabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("score"u8)) + { + score = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("optionalString"u8)) + { + optionalString = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("optionalInt"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + optionalInt = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("nullableString"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + nullableString = null; + continue; + } + nullableString = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("isActive"u8)) + { + isActive = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("RenamedProperty"u8)) + { + originalName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("xml-id"u8)) + { + xmlIdentifier = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("unwrappedStrings"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + unwrappedStrings = array; + continue; + } + if (prop.NameEquals("unwrappedCounts"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + unwrappedCounts = array; + continue; + } + if (prop.NameEquals("unwrappedItems"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(XmlItem.DeserializeXmlItem(item, options)); + } + unwrappedItems = array; + continue; + } + if (prop.NameEquals("wrappedColors"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + wrappedColors = array; + continue; + } + if (prop.NameEquals("ItemCollection"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(XmlItem.DeserializeXmlItem(item, options)); + } + items = array; + continue; + } + if (prop.NameEquals("nestedModel"u8)) + { + nestedModel = XmlNestedModel.DeserializeXmlNestedModel(prop.Value, options); + continue; + } + if (prop.NameEquals("optionalNestedModel"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + optionalNestedModel = XmlNestedModel.DeserializeXmlNestedModel(prop.Value, options); + continue; + } + if (prop.NameEquals("metadata"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("createdAt"u8)) + { + createdAt = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("duration"u8)) + { + duration = prop.Value.GetTimeSpan("P"); + continue; + } + if (prop.NameEquals("data"u8)) + { + data = BinaryData.FromBytes(prop.Value.GetBytesFromBase64("D")); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new XmlAdvancedModel( + name, + age, + enabled, + score, + optionalString, + optionalInt, + nullableString, + id, + version, + isActive, + originalName, + xmlIdentifier, + content, + unwrappedStrings, + unwrappedCounts, + unwrappedItems, + wrappedColors, + items, + nestedModel, + optionalNestedModel, + metadata, + createdAt, + duration, + data, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, SampleTypeSpecContext.Default); + default: + throw new FormatException($"The model {nameof(XmlAdvancedModel)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + XmlAdvancedModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual XmlAdvancedModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeXmlAdvancedModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(XmlAdvancedModel)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator XmlAdvancedModel(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeXmlAdvancedModel(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlAdvancedModel.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlAdvancedModel.cs new file mode 100644 index 00000000000..86357abb2b1 --- /dev/null +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlAdvancedModel.cs @@ -0,0 +1,206 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace SampleTypeSpec +{ + /// An advanced XML model for testing various property types and XML features. + public partial class XmlAdvancedModel + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// A simple string property. + /// An integer property. + /// A boolean property. + /// A float property. + /// A nullable string. + /// A string as XML attribute. + /// An integer as XML attribute. + /// A boolean as XML attribute. + /// A property with a custom XML element name. + /// An attribute with a custom XML name. + /// Text content in the element (unwrapped string). + /// An unwrapped array of strings - items appear directly without wrapper. + /// An unwrapped array of integers. + /// An unwrapped array of models. + /// A wrapped array of strings (default). + /// A wrapped array with custom wrapper name. + /// A nested model property. + /// A dictionary property. + /// A date-time property. + /// A duration property. + /// A bytes property. + internal XmlAdvancedModel(string name, int age, bool enabled, float score, string nullableString, string id, int version, bool isActive, string originalName, string xmlIdentifier, string content, IEnumerable unwrappedStrings, IEnumerable unwrappedCounts, IEnumerable unwrappedItems, IEnumerable wrappedColors, IEnumerable items, XmlNestedModel nestedModel, IDictionary metadata, DateTimeOffset createdAt, TimeSpan duration, BinaryData data) + { + Name = name; + Age = age; + Enabled = enabled; + Score = score; + NullableString = nullableString; + Id = id; + Version = version; + IsActive = isActive; + OriginalName = originalName; + XmlIdentifier = xmlIdentifier; + Content = content; + UnwrappedStrings = unwrappedStrings.ToList(); + UnwrappedCounts = unwrappedCounts.ToList(); + UnwrappedItems = unwrappedItems.ToList(); + WrappedColors = wrappedColors.ToList(); + Items = items.ToList(); + NestedModel = nestedModel; + Metadata = metadata; + CreatedAt = createdAt; + Duration = duration; + Data = data; + } + + /// Initializes a new instance of . + /// A simple string property. + /// An integer property. + /// A boolean property. + /// A float property. + /// An optional string. + /// An optional integer. + /// A nullable string. + /// A string as XML attribute. + /// An integer as XML attribute. + /// A boolean as XML attribute. + /// A property with a custom XML element name. + /// An attribute with a custom XML name. + /// Text content in the element (unwrapped string). + /// An unwrapped array of strings - items appear directly without wrapper. + /// An unwrapped array of integers. + /// An unwrapped array of models. + /// A wrapped array of strings (default). + /// A wrapped array with custom wrapper name. + /// A nested model property. + /// An optional nested model. + /// A dictionary property. + /// A date-time property. + /// A duration property. + /// A bytes property. + /// Keeps track of any properties unknown to the library. + internal XmlAdvancedModel(string name, int age, bool enabled, float score, string optionalString, int? optionalInt, string nullableString, string id, int version, bool isActive, string originalName, string xmlIdentifier, string content, IList unwrappedStrings, IList unwrappedCounts, IList unwrappedItems, IList wrappedColors, IList items, XmlNestedModel nestedModel, XmlNestedModel optionalNestedModel, IDictionary metadata, DateTimeOffset createdAt, TimeSpan duration, BinaryData data, IDictionary additionalBinaryDataProperties) + { + Name = name; + Age = age; + Enabled = enabled; + Score = score; + OptionalString = optionalString; + OptionalInt = optionalInt; + NullableString = nullableString; + Id = id; + Version = version; + IsActive = isActive; + OriginalName = originalName; + XmlIdentifier = xmlIdentifier; + Content = content; + UnwrappedStrings = unwrappedStrings; + UnwrappedCounts = unwrappedCounts; + UnwrappedItems = unwrappedItems; + WrappedColors = wrappedColors; + Items = items; + NestedModel = nestedModel; + OptionalNestedModel = optionalNestedModel; + Metadata = metadata; + CreatedAt = createdAt; + Duration = duration; + Data = data; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A simple string property. + public string Name { get; } + + /// An integer property. + public int Age { get; } + + /// A boolean property. + public bool Enabled { get; } + + /// A float property. + public float Score { get; } + + /// An optional string. + public string OptionalString { get; } + + /// An optional integer. + public int? OptionalInt { get; } + + /// A nullable string. + public string NullableString { get; } + + /// A string as XML attribute. + public string Id { get; } + + /// An integer as XML attribute. + public int Version { get; } + + /// A boolean as XML attribute. + public bool IsActive { get; } + + /// A property with a custom XML element name. + public string OriginalName { get; } + + /// An attribute with a custom XML name. + public string XmlIdentifier { get; } + + /// Text content in the element (unwrapped string). + public string Content { get; } + + /// An unwrapped array of strings - items appear directly without wrapper. + public IList UnwrappedStrings { get; } + + /// An unwrapped array of integers. + public IList UnwrappedCounts { get; } + + /// An unwrapped array of models. + public IList UnwrappedItems { get; } + + /// A wrapped array of strings (default). + public IList WrappedColors { get; } + + /// A wrapped array with custom wrapper name. + public IList Items { get; } + + /// A nested model property. + public XmlNestedModel NestedModel { get; } + + /// An optional nested model. + public XmlNestedModel OptionalNestedModel { get; } + + /// A dictionary property. + public IDictionary Metadata { get; } + + /// A date-time property. + public DateTimeOffset CreatedAt { get; } + + /// A duration property. + public TimeSpan Duration { get; } + + /// + /// A bytes property + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }). + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData Data { get; } + } +} diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlItem.Serialization.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlItem.Serialization.cs new file mode 100644 index 00000000000..4ff55dda314 --- /dev/null +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlItem.Serialization.cs @@ -0,0 +1,155 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace SampleTypeSpec +{ + /// An item model for XML array testing. + public partial class XmlItem : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal XmlItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(XmlItem)} does not support writing '{format}' format."); + } + writer.WritePropertyName("itemName"u8); + writer.WriteStringValue(ItemName); + writer.WritePropertyName("itemValue"u8); + writer.WriteNumberValue(ItemValue); + writer.WritePropertyName("itemId"u8); + writer.WriteStringValue(ItemId); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + XmlItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual XmlItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(XmlItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeXmlItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static XmlItem DeserializeXmlItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string itemName = default; + int itemValue = default; + string itemId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("itemName"u8)) + { + itemName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("itemValue"u8)) + { + itemValue = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("itemId"u8)) + { + itemId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new XmlItem(itemName, itemValue, itemId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, SampleTypeSpecContext.Default); + default: + throw new FormatException($"The model {nameof(XmlItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + XmlItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual XmlItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeXmlItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(XmlItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlItem.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlItem.cs new file mode 100644 index 00000000000..e291e9324a7 --- /dev/null +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlItem.cs @@ -0,0 +1,49 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace SampleTypeSpec +{ + /// An item model for XML array testing. + public partial class XmlItem + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The item name. + /// The item value. + /// Item ID as attribute. + internal XmlItem(string itemName, int itemValue, string itemId) + { + ItemName = itemName; + ItemValue = itemValue; + ItemId = itemId; + } + + /// Initializes a new instance of . + /// The item name. + /// The item value. + /// Item ID as attribute. + /// Keeps track of any properties unknown to the library. + internal XmlItem(string itemName, int itemValue, string itemId, IDictionary additionalBinaryDataProperties) + { + ItemName = itemName; + ItemValue = itemValue; + ItemId = itemId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The item name. + public string ItemName { get; } + + /// The item value. + public int ItemValue { get; } + + /// Item ID as attribute. + public string ItemId { get; } + } +} diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlNestedModel.Serialization.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlNestedModel.Serialization.cs new file mode 100644 index 00000000000..9f463bc25fb --- /dev/null +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlNestedModel.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace SampleTypeSpec +{ + /// A nested model for XML testing. + public partial class XmlNestedModel : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal XmlNestedModel() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(XmlNestedModel)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + writer.WritePropertyName("nestedId"u8); + writer.WriteNumberValue(NestedId); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + XmlNestedModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual XmlNestedModel JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(XmlNestedModel)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeXmlNestedModel(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static XmlNestedModel DeserializeXmlNestedModel(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + int nestedId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + value = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("nestedId"u8)) + { + nestedId = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new XmlNestedModel(value, nestedId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, SampleTypeSpecContext.Default); + default: + throw new FormatException($"The model {nameof(XmlNestedModel)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + XmlNestedModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual XmlNestedModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeXmlNestedModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(XmlNestedModel)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlNestedModel.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlNestedModel.cs new file mode 100644 index 00000000000..ff4f7c80a97 --- /dev/null +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/XmlNestedModel.cs @@ -0,0 +1,42 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace SampleTypeSpec +{ + /// A nested model for XML testing. + public partial class XmlNestedModel + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The value of the nested model. + /// An attribute on the nested model. + internal XmlNestedModel(string value, int nestedId) + { + Value = value; + NestedId = nestedId; + } + + /// Initializes a new instance of . + /// The value of the nested model. + /// An attribute on the nested model. + /// Keeps track of any properties unknown to the library. + internal XmlNestedModel(string value, int nestedId, IDictionary additionalBinaryDataProperties) + { + Value = value; + NestedId = nestedId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The value of the nested model. + public string Value { get; } + + /// An attribute on the nested model. + public int NestedId { get; } + } +} diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.RestClient.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.RestClient.cs index 6037a87bb26..8b916e68004 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.RestClient.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.RestClient.cs @@ -403,5 +403,17 @@ internal PipelineMessage CreateDynamicModelOperationRequest(BinaryContent conten message.Apply(options); return message; } + + internal PipelineMessage CreateGetXmlAdvancedModelRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/xmlAdvanced", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } } } diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.cs index 3fe80eeac86..a93e481c5b5 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecClient.cs @@ -3033,6 +3033,110 @@ public virtual async Task DynamicModelOperationAsync(DynamicModel } } + /// + /// [Protocol Method] Get an advanced XML model with various property types + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult GetXmlAdvancedModel(RequestOptions options) + { + try + { + System.Console.WriteLine("Entering method GetXmlAdvancedModel."); + using PipelineMessage message = CreateGetXmlAdvancedModelRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetXmlAdvancedModel: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetXmlAdvancedModel."); + } + } + + /// + /// [Protocol Method] Get an advanced XML model with various property types + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetXmlAdvancedModelAsync(RequestOptions options) + { + try + { + System.Console.WriteLine("Entering method GetXmlAdvancedModelAsync."); + using PipelineMessage message = CreateGetXmlAdvancedModelRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetXmlAdvancedModelAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetXmlAdvancedModelAsync."); + } + } + + /// Get an advanced XML model with various property types. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult GetXmlAdvancedModel(CancellationToken cancellationToken = default) + { + try + { + System.Console.WriteLine("Entering method GetXmlAdvancedModel."); + ClientResult result = GetXmlAdvancedModel(cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetXmlAdvancedModel: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetXmlAdvancedModel."); + } + } + + /// Get an advanced XML model with various property types. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetXmlAdvancedModelAsync(CancellationToken cancellationToken = default) + { + try + { + System.Console.WriteLine("Entering method GetXmlAdvancedModelAsync."); + ClientResult result = await GetXmlAdvancedModelAsync(cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null).ConfigureAwait(false); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + } + catch (Exception ex) + { + System.Console.WriteLine($"An exception was thrown in method GetXmlAdvancedModelAsync: {ex}"); + throw; + } + finally + { + System.Console.WriteLine("Exiting method GetXmlAdvancedModelAsync."); + } + } + /// Initializes a new instance of AnimalOperations. public virtual AnimalOperations GetAnimalOperationsClient() { diff --git a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecModelFactory.cs b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecModelFactory.cs index ff9639bb364..ba951e61c45 100644 --- a/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecModelFactory.cs +++ b/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/SampleTypeSpecModelFactory.cs @@ -240,6 +240,88 @@ public static AnotherDynamicModel AnotherDynamicModel(string bar = default) return new AnotherDynamicModel(bar, additionalBinaryDataProperties: null); } + /// An advanced XML model for testing various property types and XML features. + /// A simple string property. + /// An integer property. + /// A boolean property. + /// A float property. + /// An optional string. + /// An optional integer. + /// A nullable string. + /// A string as XML attribute. + /// An integer as XML attribute. + /// A boolean as XML attribute. + /// A property with a custom XML element name. + /// An attribute with a custom XML name. + /// Text content in the element (unwrapped string). + /// An unwrapped array of strings - items appear directly without wrapper. + /// An unwrapped array of integers. + /// An unwrapped array of models. + /// A wrapped array of strings (default). + /// A wrapped array with custom wrapper name. + /// A nested model property. + /// An optional nested model. + /// A dictionary property. + /// A date-time property. + /// A duration property. + /// A bytes property. + /// A new instance for mocking. + public static XmlAdvancedModel XmlAdvancedModel(string name = default, int age = default, bool enabled = default, float score = default, string optionalString = default, int? optionalInt = default, string nullableString = default, string id = default, int version = default, bool isActive = default, string originalName = default, string xmlIdentifier = default, string content = default, IEnumerable unwrappedStrings = default, IEnumerable unwrappedCounts = default, IEnumerable unwrappedItems = default, IEnumerable wrappedColors = default, IEnumerable items = default, XmlNestedModel nestedModel = default, XmlNestedModel optionalNestedModel = default, IDictionary metadata = default, DateTimeOffset createdAt = default, TimeSpan duration = default, BinaryData data = default) + { + unwrappedStrings ??= new ChangeTrackingList(); + unwrappedCounts ??= new ChangeTrackingList(); + unwrappedItems ??= new ChangeTrackingList(); + wrappedColors ??= new ChangeTrackingList(); + items ??= new ChangeTrackingList(); + metadata ??= new ChangeTrackingDictionary(); + + return new XmlAdvancedModel( + name, + age, + enabled, + score, + optionalString, + optionalInt, + nullableString, + id, + version, + isActive, + originalName, + xmlIdentifier, + content, + unwrappedStrings.ToList(), + unwrappedCounts.ToList(), + unwrappedItems.ToList(), + wrappedColors.ToList(), + items.ToList(), + nestedModel, + optionalNestedModel, + metadata, + createdAt, + duration, + data, + additionalBinaryDataProperties: null); + } + + /// An item model for XML array testing. + /// The item name. + /// The item value. + /// Item ID as attribute. + /// A new instance for mocking. + public static XmlItem XmlItem(string itemName = default, int itemValue = default, string itemId = default) + { + return new XmlItem(itemName, itemValue, itemId, additionalBinaryDataProperties: null); + } + + /// A nested model for XML testing. + /// The value of the nested model. + /// An attribute on the nested model. + /// A new instance for mocking. + public static XmlNestedModel XmlNestedModel(string value = default, int nestedId = default) + { + return new XmlNestedModel(value, nestedId, additionalBinaryDataProperties: null); + } + /// /// Base animal with discriminator /// Please note this is the abstract base class. The derived classes available for instantiation are: and . diff --git a/docs/samples/client/csharp/SampleService/main.tsp b/docs/samples/client/csharp/SampleService/main.tsp index e93467b99b1..f107f78d68e 100644 --- a/docs/samples/client/csharp/SampleService/main.tsp +++ b/docs/samples/client/csharp/SampleService/main.tsp @@ -1,5 +1,6 @@ import "@typespec/rest"; import "@typespec/http"; +import "@typespec/xml"; import "@typespec/http-client-csharp"; import "@azure-tools/typespec-client-generator-core"; import "@azure-tools/typespec-azure-core"; @@ -20,6 +21,7 @@ namespace SampleTypeSpec; using TypeSpec.Http; using TypeSpec.Versioning; using TypeSpec.HttpClient.CSharp; +using TypeSpec.Xml; using Azure.ClientGenerator.Core; alias SampleOAuth2 = OAuth2Auth<[ @@ -309,6 +311,118 @@ model AnotherDynamicModel { bar: string; } +@doc("An advanced XML model for testing various property types and XML features.") +@Xml.name("AdvancedXmlModel") +model XmlAdvancedModel { + @doc("A simple string property") + name: string; + + @doc("An integer property") + age: int32; + + @doc("A boolean property") + enabled: boolean; + + @doc("A float property") + score: float32; + + @doc("An optional string") + optionalString?: string; + + @doc("An optional integer") + optionalInt?: int32; + + @doc("A nullable string") + nullableString: string | null; + + @doc("A string as XML attribute") + @attribute + id: string; + + @doc("An integer as XML attribute") + @attribute + version: int32; + + @doc("A boolean as XML attribute") + @attribute + isActive: boolean; + + @doc("A property with a custom XML element name") + @Xml.name("RenamedProperty") + originalName: string; + + @doc("An attribute with a custom XML name") + @attribute + @Xml.name("xml-id") + xmlIdentifier: string; + + + @doc("Text content in the element (unwrapped string)") + @unwrapped + content: string; + + @doc("An unwrapped array of strings - items appear directly without wrapper") + @unwrapped + unwrappedStrings: string[]; + + @doc("An unwrapped array of integers") + @unwrapped + unwrappedCounts: int32[]; + + @doc("An unwrapped array of models") + @unwrapped + unwrappedItems: XmlItem[]; + + @doc("A wrapped array of strings (default)") + wrappedColors: string[]; + + @doc("A wrapped array with custom wrapper name") + @Xml.name("ItemCollection") + items: XmlItem[]; + + @doc("A nested model property") + nestedModel: XmlNestedModel; + + @doc("An optional nested model") + optionalNestedModel?: XmlNestedModel; + + @doc("A dictionary property") + metadata: Record; + + @doc("A date-time property") + createdAt: utcDateTime; + + @doc("A duration property") + duration: duration; + + @doc("A bytes property") + data: bytes; +} + +@doc("A nested model for XML testing") +model XmlNestedModel { + @doc("The value of the nested model") + value: string; + + @doc("An attribute on the nested model") + @attribute + nestedId: int32; +} + +@doc("An item model for XML array testing") +@Xml.name("Item") +model XmlItem { + @doc("The item name") + itemName: string; + + @doc("The item value") + itemValue: int32; + + @doc("Item ID as attribute") + @attribute + itemId: string; +} + union DaysOfWeekExtensibleEnum { string, Monday: "Monday", @@ -513,6 +627,14 @@ op EmbeddedParameters(@bodyRoot body: ModelWithEmbeddedNonBodyParameters): void; @post op DynamicModelOperation(@body body: DynamicModel): void; +@route("xmlAdvanced") +@doc("Get an advanced XML model with various property types") +@get +op GetXmlAdvancedModel(): { + @header contentType: "application/xml"; + @body body: XmlAdvancedModel; +}; + @doc("Base animal with discriminator") @discriminator("kind") model Animal { diff --git a/packages/http-client-csharp/eng/scripts/Spector-Helper.psm1 b/packages/http-client-csharp/eng/scripts/Spector-Helper.psm1 index eb11f366015..8340e859ebe 100644 --- a/packages/http-client-csharp/eng/scripts/Spector-Helper.psm1 +++ b/packages/http-client-csharp/eng/scripts/Spector-Helper.psm1 @@ -1,7 +1,7 @@ $repoRoot = Resolve-Path (Join-Path $PSScriptRoot '..') $failingSpecs = @( - Join-Path 'http' 'payload' 'xml' + #Join-Path 'http' 'payload' 'xml' Join-Path 'http' 'type' 'model' 'flatten' Join-Path 'http' 'type' 'model' 'templated' Join-Path 'http' 'client' 'naming' # pending until https://github.com/microsoft/typespec/issues/5653 is resolved diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Primitives/ScmKnownParameters.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Primitives/ScmKnownParameters.cs index bfbefd24fbb..9ff28ed9363 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Primitives/ScmKnownParameters.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Primitives/ScmKnownParameters.cs @@ -21,7 +21,6 @@ internal static class ScmKnownParameters public static readonly ParameterProvider XmlWriter = new("writer", FormattableStringHelpers.Empty, typeof(XmlWriter)); public static readonly ParameterProvider NameHint = new("nameHint", FormattableStringHelpers.Empty, typeof(string)); - public static readonly ParameterProvider XElement = new("element", FormattableStringHelpers.Empty, typeof(XElement)); public static readonly ParameterProvider Utf8JsonWriter = new("writer", FormattableStringHelpers.Empty, typeof(Utf8JsonWriter)); public static readonly ParameterProvider Utf8JsonReader = new("reader", FormattableStringHelpers.Empty, typeof(Utf8JsonReader), isRef: true); public static readonly ParameterProvider JsonOptions = new("options", FormattableStringHelpers.Empty, typeof(JsonSerializerOptions)); diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensions.Xml.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensions.Xml.cs new file mode 100644 index 00000000000..1e004e0e115 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensions.Xml.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Xml.Linq; +using Microsoft.TypeSpec.Generator.ClientModel.Snippets; +using Microsoft.TypeSpec.Generator.Expressions; +using Microsoft.TypeSpec.Generator.Primitives; +using Microsoft.TypeSpec.Generator.Providers; +using Microsoft.TypeSpec.Generator.Snippets; +using static Microsoft.TypeSpec.Generator.Snippets.Snippet; + +namespace Microsoft.TypeSpec.Generator.ClientModel.Providers +{ + public sealed partial class ModelSerializationExtensionsDefinition + { + private readonly ParameterProvider _xElementParameter = + new ParameterProvider("element", FormattableStringHelpers.Empty, typeof(XElement)); + + private MethodProvider[] BuildXmlExtensionMethods() + { + if (!ScmCodeModelGenerator.Instance.InputLibrary.HasXmlModelSerialization) + { + return []; + } + + return + [ + BuildXmlGetDateTimeOffsetValueMethodProvider() + ]; + } + + private MethodProvider BuildXmlGetDateTimeOffsetValueMethodProvider() + { + var signature = new MethodSignature( + Name: _getDateTimeOffsetMethodName, + Modifiers: _methodModifiers, + Parameters: [_xElementParameter, _formatParameter], + ReturnType: typeof(DateTimeOffset), + Description: null, + ReturnDescription: null); + + var element = _xElementParameter.As(); + var body = new SwitchExpression( + _formatParameter, + new SwitchCaseExpression(Literal("U"), DateTimeOffsetSnippets.FromUnixTimeSeconds(element.CastTo(typeof(long)))), + SwitchCaseExpression.Default(TypeFormattersSnippets.ParseDateTimeOffset(element.Value(), _formatParameter))); + + return new MethodProvider(signature, body, this, XmlDocProvider.Empty); + } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs index 5a839f27088..2b1ecb328f4 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ModelSerializationExtensionsDefinition.cs @@ -8,7 +8,6 @@ using System.Diagnostics; using System.Globalization; using System.IO; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Text.Json; @@ -23,7 +22,7 @@ namespace Microsoft.TypeSpec.Generator.ClientModel.Providers { - public sealed class ModelSerializationExtensionsDefinition : TypeProvider + public sealed partial class ModelSerializationExtensionsDefinition : TypeProvider { public const string WireOptionsFieldName = "WireOptions"; public const string JsonDocumentOptionsFieldName = "JsonDocumentOptions"; @@ -158,7 +157,8 @@ protected override MethodProvider[] BuildMethods() BuildWriteObjectValueMethodGeneric(), BuildWriteObjectValueMethodProvider(), BuildGetUtf8BytesMethodProvider(), - .. BuildDynamicModelHelpers() + .. BuildDynamicModelHelpers(), + .. BuildXmlExtensionMethods() ]; } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.Dynamic.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.Dynamic.cs index c62dfd0df8b..609019fa210 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.Dynamic.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.Dynamic.cs @@ -503,14 +503,14 @@ private static string BuildJsonPathForElement(string propertySerializedName, Lis private static ValueExpression GetDeserializationMethodInvocationForType( ModelProvider model, - ScopedApi jsonElementVariable, + ScopedApi element, ValueExpression? dataVariable = null, ValueExpression? optionsVariable = null) { optionsVariable ??= ModelSerializationExtensionsSnippets.Wire; return model is ScmModelProvider { IsDynamicModel: true } - ? model.Type.Deserialize(jsonElementVariable, dataVariable, optionsVariable) - : model.Type.Deserialize(jsonElementVariable, null, optionsVariable); + ? model.Type.Deserialize(element, dataVariable, optionsVariable) + : model.Type.Deserialize(element, null, optionsVariable); } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.Xml.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.Xml.cs new file mode 100644 index 00000000000..0fe3743b20d --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.Xml.cs @@ -0,0 +1,448 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; +using Microsoft.TypeSpec.Generator.ClientModel.Snippets; +using Microsoft.TypeSpec.Generator.Expressions; +using Microsoft.TypeSpec.Generator.Primitives; +using Microsoft.TypeSpec.Generator.Providers; +using Microsoft.TypeSpec.Generator.Snippets; +using Microsoft.TypeSpec.Generator.Statements; +using static Microsoft.TypeSpec.Generator.Snippets.Snippet; + +namespace Microsoft.TypeSpec.Generator.ClientModel.Providers +{ + public partial class MrwSerializationTypeDefinition + { + private readonly ParameterProvider _xElementDeserializationParam = new("element", $"The xml element to deserialize.", typeof(XElement)); + + /// + /// Represents a property that can be deserialized from XML, categorized by its serialization type. + /// + private record XmlPropertyInfo( + CSharpType PropertyType, + VariableExpression PropertyExpression, + XmlWireInformation XmlWireInfo); + + /// + /// Categorized XML properties for deserialization. + /// + private record XmlPropertyCategories( + List? AttributeProperties, + List? ElementProperties, + XmlPropertyInfo? TextContentProperty); + + internal MethodProvider BuildXmlDeserializationMethod() + { + var methodName = $"{DeserializationMethodNamePrefix}{_model.Name}"; + var signatureModifiers = MethodSignatureModifiers.Internal | MethodSignatureModifiers.Static; + var parameters = new List + { + _xElementDeserializationParam, + _serializationOptionsParameter, + }; + + return new MethodProvider( + new MethodSignature(methodName, null, signatureModifiers, _model.Type, null, parameters), + BuildXmlDeserializationMethodBody(), + this); + } + + private MethodBodyStatement[] BuildXmlDeserializationMethodBody() + { + var elementParameter = _xElementDeserializationParam.As(); + var valueKindEqualsNullReturn = _isStruct + ? Return(Default) + : Return(Null); + + var categorizedProperties = CategorizeXmlProperties(); + var statements = new List + { + new IfStatement(elementParameter.Equal(Null)) { valueKindEqualsNullReturn }, + MethodBodyStatement.EmptyLine, + GetPropertyVariableDeclarations(), + MethodBodyStatement.EmptyLine + }; + + if (categorizedProperties.AttributeProperties?.Count > 0) + { + statements.Add(CreateXmlDeserializeForEachStatement( + elementParameter, + categorizedProperties.AttributeProperties, + isAttributes: true)); + statements.Add(MethodBodyStatement.EmptyLine); + } + + if (categorizedProperties.ElementProperties?.Count > 0) + { + statements.Add(CreateXmlDeserializeForEachStatement( + elementParameter, + categorizedProperties.ElementProperties, + isAttributes: false)); + } + + if (categorizedProperties.TextContentProperty != null) + { + statements.Add(categorizedProperties.TextContentProperty.PropertyExpression.Assign(elementParameter.Value()).Terminate()); + statements.Add(MethodBodyStatement.EmptyLine); + } + + statements.Add(Return(New.Instance(_model.Type, GetSerializationCtorParameterValues()))); + + return [.. statements]; + } + + private XmlPropertyCategories CategorizeXmlProperties() + { + List? attributeProperties = null; + List? elementProperties = null; + XmlPropertyInfo? textContentProperty = null; + + var parameters = SerializationConstructor.Signature.Parameters; + + for (int i = 0; i < parameters.Count; i++) + { + var parameter = parameters[i]; + if (parameter.Property == null && parameter.Field == null) + { + continue; + } + + var wireInfo = parameter.Property?.WireInfo ?? parameter.Field?.WireInfo; + var xmlWireInfo = wireInfo?.XmlWireInformation; + if (xmlWireInfo == null || wireInfo?.IsHttpMetadata == true) + { + continue; + } + + var propertyType = parameter.Property?.Type ?? parameter.Field?.Type; + var propertyExpression = parameter.Property?.AsVariableExpression ?? parameter.Field?.AsVariableExpression; + if (propertyType == null || propertyExpression == null) + { + continue; + } + + var propertyInfo = new XmlPropertyInfo(propertyType, propertyExpression, xmlWireInfo); + + // Categorize by XML serialization type + if (xmlWireInfo.Attribute == true) + { + (attributeProperties ??= []).Add(propertyInfo); + continue; + } + if (xmlWireInfo.Unwrapped == true && !propertyType.IsCollection) + { + textContentProperty = propertyInfo; + continue; + } + + (elementProperties ??= []).Add(propertyInfo); + } + + return new XmlPropertyCategories(attributeProperties, elementProperties, textContentProperty); + } + + private ForEachStatement CreateXmlDeserializeForEachStatement( + ScopedApi elementParameter, + List properties, + bool isAttributes) + { + return isAttributes switch + { + true => new ForEachStatement("attr", elementParameter.Attributes(), out var attr) + { + CreateXmlDeserializeAttributeStatements(attr.As(), properties) + }, + false => new ForEachStatement("child", elementParameter.Elements(), out var child) + { + CreateXmlDeserializeElementStatements(child.As(), properties) + } + }; + } + + private MethodBodyStatement CreateXmlDeserializeElementStatements( + ScopedApi childElement, + List elementProperties) + { + var statements = new List(); + var localNameVariable = new VariableExpression(typeof(string), "localName"); + + statements.Add(Declare(localNameVariable, childElement.GetLocalName())); + + foreach (var prop in elementProperties) + { + var checkIfLocalNameEquals = new IfStatement(localNameVariable.Equal(Literal(prop.XmlWireInfo.Name))) + { + CreateXmlDeserializePropertyAssignment(childElement, prop.PropertyType, prop.PropertyExpression, prop.XmlWireInfo), + Continue + }; + + statements.Add(checkIfLocalNameEquals); + } + + return statements; + } + + private MethodBodyStatement CreateXmlDeserializePropertyAssignment( + ScopedApi childElement, + CSharpType propertyType, + VariableExpression propertyExpression, + XmlWireInformation xmlWireInfo) + { + if (propertyType.IsList || propertyType.IsArray) + { + return CreateXmlDeserializeListAssignment(childElement, propertyType, propertyExpression, xmlWireInfo); + } + + if (propertyType.IsDictionary) + { + return CreateXmlDeserializeDictionaryAssignment(childElement, propertyType, propertyExpression, xmlWireInfo); + } + + var deserializedValue = CreateXmlDeserializeValueExpression(childElement, propertyType); + return propertyExpression.Assign(deserializedValue).Terminate(); + } + + private MethodBodyStatement CreateXmlDeserializeListAssignment( + ScopedApi childElement, + CSharpType listType, + VariableExpression listExpression, + XmlWireInformation xmlWireInfo) + { + var elementType = listType.ElementType; + if (xmlWireInfo.Unwrapped == true) + { + return new MethodBodyStatements( + [ + new IfStatement(listExpression.Equal(Null)) + { + listExpression.Assign(New.Instance(listType.PropertyInitializationType)).Terminate(), + }, + DeserializeXmlValue(childElement, elementType, out var itemValue), + listExpression.Invoke("Add", itemValue).Terminate() + ]); + } + else + { + var itemsName = xmlWireInfo.ItemsName; + var arrayDeclaration = Declare("array", New.List(listType.ElementType), out var listVariable); + var foreachStatement = ForEachStatement.Create("e", childElement.Elements(Literal(itemsName)), out ScopedApi item) + .Add(new MethodBodyStatement[] + { + DeserializeXmlValue(item, elementType, out var deserializedItem), + listVariable.Add(deserializedItem) + }); + + return new MethodBodyStatements( + [ + arrayDeclaration, + foreachStatement, + listExpression.Assign(listVariable).Terminate() + ]); + } + } + + private MethodBodyStatement CreateXmlDeserializeDictionaryAssignment( + ScopedApi childElement, + CSharpType dictionaryType, + VariableExpression dictionaryExpression, + XmlWireInformation xmlWireInfo) + { + var valueType = dictionaryType.ElementType; + if (xmlWireInfo.Unwrapped == true) + { + return new MethodBodyStatements( + [ + new IfStatement(dictionaryExpression.Equal(Null)) + { + dictionaryExpression.Assign(New.Dictionary(dictionaryType.Arguments[0], dictionaryType.Arguments[1])).Terminate(), + }, + CreateXmlDeserializeDictionaryValueStatement(valueType, dictionaryExpression, childElement) + ]); + } + + var dictionaryDeclaration = Declare( + "dictionary", + New.Dictionary(dictionaryType.Arguments[0], dictionaryType.Arguments[1]), + out var dictVariable); + + var foreachStatement = ForEachStatement.Create("e", childElement.Elements(), out ScopedApi item) + .Add(new MethodBodyStatement[] + { + CreateXmlDeserializeDictionaryValueStatement(valueType, dictVariable, item) + }); + + return new MethodBodyStatements( + [ + dictionaryDeclaration, + foreachStatement, + dictionaryExpression.Assign(dictVariable).Terminate() + ]); + } + + private MethodBodyStatement CreateXmlDeserializeDictionaryValueStatement( + CSharpType valueType, + ValueExpression dictionary, + ScopedApi element) + { + return new MethodBodyStatement[] + { + DeserializeXmlValue(element, valueType, out var value), + dictionary.Invoke("Add", element.GetLocalName(), value).Terminate() + }; + } + + private MethodBodyStatement DeserializeXmlValue( + ScopedApi element, + CSharpType valueType, + out ValueExpression value) + { + if (valueType.IsList || valueType.IsArray) + { + var listDeclaration = Declare("list", New.List(valueType.ElementType), out var listVariable); + var foreachStatement = ForEachStatement.Create("item", element.Elements(), out ScopedApi item) + .Add(new MethodBodyStatement[] + { + DeserializeXmlValue(item, valueType.ElementType, out var deserializedItem), + listVariable.Add(deserializedItem) + }); + + value = listVariable; + return new MethodBodyStatement[] { listDeclaration, foreachStatement }; + } + + if (valueType.IsDictionary) + { + var dictDeclaration = Declare("dict", New.Dictionary(valueType.Arguments[0], valueType.Arguments[1]), out var dictVariable); + var foreachStatement = ForEachStatement.Create("item", element.Elements(), out ScopedApi item) + .Add(CreateXmlDeserializeDictionaryValueStatement(valueType.ElementType, dictVariable, item)); + + value = dictVariable; + return new MethodBodyStatement[] { dictDeclaration, foreachStatement }; + } + + value = CreateXmlDeserializeValueExpression(element, valueType); + return MethodBodyStatement.Empty; + } + + private ValueExpression CreateXmlDeserializeValueExpression(ScopedApi element, CSharpType valueType) + { + var underlyingType = valueType.IsNullable && valueType.Arguments.Count > 0 + ? valueType.Arguments[0] + : valueType; + + if (underlyingType.IsEnum && underlyingType.UnderlyingEnumType != null) + { + var underlyingExpression = CreateXmlDeserializePrimitiveExpression(element, underlyingType.UnderlyingEnumType); + return underlyingType.ToEnum(underlyingExpression); + } + + if (!underlyingType.IsFrameworkType) + { + return GetDeserializationMethodInvocationForType(underlyingType, element, null, _serializationOptionsParameter); + } + + return CreateXmlDeserializePrimitiveExpression(element, valueType); + } + + private static ValueExpression CreateXmlDeserializePrimitiveExpression( + ScopedApi element, + CSharpType valueType) + { + // TO-DO: Use serialization extensions if needed for special cases + return valueType.FrameworkType switch + { + Type t when t == typeof(byte) => element.CastTo(typeof(int)).CastTo(typeof(byte)), + Type t when t == typeof(sbyte) => element.CastTo(typeof(int)).CastTo(typeof(sbyte)), + Type t when t == typeof(short) => element.CastTo(typeof(int)).CastTo(typeof(short)), + Type t when t == typeof(ushort) => element.CastTo(typeof(int)).CastTo(typeof(ushort)), + Type t when t == typeof(byte[]) => Static(typeof(Convert)).Invoke(nameof(Convert.FromBase64String), [element.CastTo(typeof(string))]), + Type t when t == typeof(BinaryData) => New.Instance(typeof(BinaryData), Static(typeof(Convert)).Invoke(nameof(Convert.FromBase64String), [element.CastTo(typeof(string))])), + _ => element.CastTo(valueType) + }; + } + + private static MethodBodyStatement CreateXmlDeserializeAttributeStatements( + ScopedApi attrVariable, + List attributeProperties) + { + var statements = new List + { + Declare("localName", typeof(string), attrVariable.GetLocalName(), out var localNameVar) + }; + + foreach (var prop in attributeProperties) + { + var deserializedValue = attrVariable.CastTo(prop.PropertyType); + var checkIfLocalNameEquals = new IfStatement(localNameVar.Equal(Literal(prop.XmlWireInfo.Name))) + { + prop.PropertyExpression.Assign(deserializedValue).Terminate(), + Continue + }; + + statements.Add(checkIfLocalNameEquals); + } + + return statements; + } + + private SwitchCaseStatement CreatePersistableModelCreateCoreXmlSwitchCase(CSharpType typeForDeserialize) + { + return new SwitchCaseStatement( + ModelReaderWriterOptionsSnippets.XmlFormat, + new MethodBodyStatement[] + { + new UsingScopeStatement(typeof(Stream), "dataStream", _dataParameter.As().ToStream(), out var streamVar) + { + Return(GetDeserializationMethodInvocationForType( + typeForDeserialize, + XElementSnippets.Load(streamVar.As(), XmlLinqSnippets.PreserveWhitespace), + _dataParameter, + _serializationOptionsParameter)) + }, + }); + } + + private MethodProvider BuildXmlExplicitFromClientResult() + { + var result = new ParameterProvider( + ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.ResponseParameterName, + $"The {ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.ClientResponseType:C} to deserialize the {Type:C} from.", + ScmCodeModelGenerator.Instance.TypeFactory.ClientResponseApi.ClientResponseType); + var modifiers = MethodSignatureModifiers.Public | MethodSignatureModifiers.Static | + MethodSignatureModifiers.Explicit | MethodSignatureModifiers.Operator; + + var response = result.ToApi(); + MethodBodyStatement responseDeclaration; + + if (response.Original == response.GetRawResponse().Original) + { + responseDeclaration = MethodBodyStatement.Empty; + } + else + { + responseDeclaration = UsingDeclare("response", ScmCodeModelGenerator.Instance.TypeFactory.HttpResponseApi.HttpResponseType, result.ToApi().GetRawResponse(), out var responseVar); + response = responseVar.ToApi(); + } + + MethodBodyStatement[] methodBody = + [ + responseDeclaration, + UsingDeclare("stream", typeof(Stream), response.Property(nameof(HttpResponseApi.ContentStream)), out var streamVar), + new IfStatement(streamVar.Equal(Null)) { Return(Default) }, + MethodBodyStatement.EmptyLine, + Return(GetDeserializationMethodInvocationForType( + _model, + XElementSnippets.Load(streamVar.As(), XmlLinqSnippets.PreserveWhitespace))) + ]; + + return new MethodProvider( + new MethodSignature(Type.Name, null, modifiers, Type, null, [result]), + methodBody, + this); + } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs index 4a36125f9e1..cded6c1d816 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs @@ -34,6 +34,7 @@ public partial class MrwSerializationTypeDefinition : TypeProvider private const string JsonModelCreateCoreMethodName = "JsonModelCreateCore"; private const string PersistableModelWriteCoreMethodName = "PersistableModelWriteCore"; private const string PersistableModelCreateCoreMethodName = "PersistableModelCreateCore"; + private const string DeserializationMethodNamePrefix = "Deserialize"; private const string WriteAction = "writing"; private const string ReadAction = "reading"; private readonly ParameterProvider _utf8JsonWriterParameter = new("writer", $"The JSON writer.", typeof(Utf8JsonWriter)); @@ -57,6 +58,8 @@ public partial class MrwSerializationTypeDefinition : TypeProvider private readonly Lazy _additionalBinaryDataProperty; private readonly PropertyProvider? _jsonPatchProperty; private readonly bool _isStruct; + private readonly bool _supportsJson; + private readonly bool _supportsXml; private ConstructorProvider? _serializationConstructor; // Flag to determine if the model should override the serialization methods private readonly bool _shouldOverrideMethods; @@ -73,6 +76,8 @@ public MrwSerializationTypeDefinition(InputModelType inputModel, ModelProvider m : null; _inputModel = inputModel; _isStruct = _model.DeclarationModifiers.HasFlag(TypeSignatureModifiers.Struct); + _supportsJson = inputModel.Usage.HasFlag(InputModelTypeUsage.Json); + _supportsXml = inputModel.Usage.HasFlag(InputModelTypeUsage.Xml); // Initialize the serialization interfaces var interfaceType = inputModel.IsUnknownDiscriminatorModel ? ScmCodeModelGenerator.Instance.TypeFactory.CreateModel(inputModel.BaseModel!)! : _model; _jsonModelTInterface = new CSharpType(typeof(IJsonModel<>), interfaceType.Type); @@ -165,45 +170,63 @@ protected override ConstructorProvider[] BuildConstructors() /// A list of serialization and deserialization methods for the model. protected override MethodProvider[] BuildMethods() { - var jsonModelWriteCoreMethod = BuildJsonModelWriteCoreMethod(); - var methods = new List() + var methods = new List(); + + if (_supportsJson || _supportsXml) { - // Add JsonModel serialization methods - BuildJsonModelWriteMethod(jsonModelWriteCoreMethod), - jsonModelWriteCoreMethod, + // TO-DO: Add all persistable model methods when XML support is complete. + methods.Add(BuildPersistableModelCreateCoreMethod()); + if (!_inputModel.IsUnknownDiscriminatorModel) + { + if (ScmCodeModelGenerator.Instance.TypeFactory.RootOutputModels.Contains(_inputModel)) + { + methods.Add(GetExplicitFromClientResultMethod(_supportsXml)); + } + } + } + + // Add JsonModel serialization methods only if the model supports JSON + if (_supportsJson) + { + var jsonModelWriteCoreMethod = BuildJsonModelWriteCoreMethod(); + methods.Add(BuildJsonModelWriteMethod(jsonModelWriteCoreMethod)); + methods.Add(jsonModelWriteCoreMethod); // Add JsonModel deserialization methods - BuildJsonModelCreateMethod(), - BuildJsonModelCreateCoreMethod(), - BuildDeserializationMethod(), + methods.Add(BuildJsonModelCreateMethod()); + methods.Add(BuildJsonModelCreateCoreMethod()); + methods.Add(BuildDeserializationMethod()); // Add PersistableModel serialization methods - BuildPersistableModelWriteMethod(), - BuildPersistableModelWriteCoreMethod(), - BuildPersistableModelCreateMethod(), - BuildPersistableModelCreateCoreMethod(), - BuildPersistableModelGetFormatFromOptionsMethod(), - }; + methods.Add(BuildPersistableModelWriteMethod()); + methods.Add(BuildPersistableModelWriteCoreMethod()); + methods.Add(BuildPersistableModelCreateMethod()); + methods.Add(BuildPersistableModelGetFormatFromOptionsMethod()); - if (!_inputModel.IsUnknownDiscriminatorModel) - { - //cast operators - if (ScmCodeModelGenerator.Instance.TypeFactory.RootInputModels.Contains(_inputModel)) + if (!_inputModel.IsUnknownDiscriminatorModel) { - methods.Add(BuildImplicitToBinaryContent()); + //cast operators + if (ScmCodeModelGenerator.Instance.TypeFactory.RootInputModels.Contains(_inputModel)) + { + methods.Add(BuildImplicitToBinaryContent()); + } } - if (ScmCodeModelGenerator.Instance.TypeFactory.RootOutputModels.Contains(_inputModel)) + if (_isStruct) { - methods.Add(BuildExplicitFromClientResult()); + methods.Add(BuildJsonModelWriteMethodObjectDeclaration()); + methods.Add(BuildJsonModelCreateMethodObjectDeclaration()); + methods.Add(BuildPersistableModelWriteMethodObjectDeclaration()); + methods.Add(BuildPersistableModelGetFormatFromOptionsObjectDeclaration()); + methods.Add(BuildPersistableModelCreateMethodObjectDeclaration()); } } - if (_isStruct) + if (_supportsXml) { - methods.Add(BuildJsonModelWriteMethodObjectDeclaration()); - methods.Add(BuildJsonModelCreateMethodObjectDeclaration()); - methods.Add(BuildPersistableModelWriteMethodObjectDeclaration()); - methods.Add(BuildPersistableModelGetFormatFromOptionsObjectDeclaration()); - methods.Add(BuildPersistableModelCreateMethodObjectDeclaration()); + var xmlDeserializationMethod = BuildXmlDeserializationMethod(); + if (xmlDeserializationMethod != null) + { + methods.Add(xmlDeserializationMethod); + } } if (_model is ScmModelProvider { IsDynamicModel: true, HasDynamicProperties: true }) @@ -214,6 +237,16 @@ protected override MethodProvider[] BuildMethods() return [.. methods]; } + private MethodProvider GetExplicitFromClientResultMethod(bool supportsXml) + { + if (supportsXml) + { + return BuildXmlExplicitFromClientResult(); + } + + return BuildExplicitFromClientResult(); + } + private MethodProvider BuildExplicitFromClientResult() { var result = new ParameterProvider( @@ -287,16 +320,18 @@ private MethodProvider BuildImplicitToBinaryContent() /// An array of types that the model implements. protected override CSharpType[] BuildImplements() { - int interfaceCount = _jsonModelObjectInterface != null ? 2 : 1; - CSharpType[] interfaces = new CSharpType[interfaceCount]; - interfaces[0] = _jsonModelTInterface; + var interfaces = new List(); - if (_jsonModelObjectInterface != null) + if (_supportsJson) { - interfaces[1] = _jsonModelObjectInterface; + interfaces.Add(_jsonModelTInterface); + if (_jsonModelObjectInterface != null) + { + interfaces.Add(_jsonModelObjectInterface); + } } - return interfaces; + return [.. interfaces]; } /// @@ -507,7 +542,7 @@ internal MethodProvider BuildJsonModelCreateCoreMethod() /// internal MethodProvider BuildDeserializationMethod() { - var methodName = $"Deserialize{_model.Name}"; + var methodName = $"{DeserializationMethodNamePrefix}{_model.Name}"; var signatureModifiers = MethodSignatureModifiers.Internal | MethodSignatureModifiers.Static; List parameters = _model is ScmModelProvider { IsDynamicModel: true } ? [_jsonElementDeserializationParam, _dataParameter, _serializationOptionsParameter] @@ -838,19 +873,30 @@ private MethodBodyStatement[] BuildPersistableModelWriteCoreMethodBody() private MethodBodyStatement[] BuildPersistableModelCreateCoreMethodBody() { var typeForDeserialize = _model.IsUnknownDiscriminatorModel ? _model.Type.BaseType! : _model.Type; - var switchCase = new SwitchCaseStatement( - ModelReaderWriterOptionsSnippets.JsonFormat, - new MethodBodyStatement[] - { - new UsingScopeStatement(typeof(JsonDocument), "document", JsonDocumentSnippets.Parse(_dataParameter, ModelSerializationExtensionsSnippets.JsonDocumentOptions), out var jsonDocumentVar) + var switchCases = new List(); + + if (_supportsJson) + { + switchCases.Add(new SwitchCaseStatement( + ModelReaderWriterOptionsSnippets.JsonFormat, + new MethodBodyStatement[] { - Return(GetDeserializationMethodInvocationForType( - typeForDeserialize, - jsonDocumentVar.As().RootElement(), - _dataParameter, - _serializationOptionsParameter)) - }, - }); + new UsingScopeStatement(typeof(JsonDocument), "document", JsonDocumentSnippets.Parse(_dataParameter, ModelSerializationExtensionsSnippets.JsonDocumentOptions), out var jsonDocumentVar) + { + Return(GetDeserializationMethodInvocationForType( + typeForDeserialize, + jsonDocumentVar.As().RootElement(), + _dataParameter, + _serializationOptionsParameter)) + }, + })); + } + + if (_supportsXml) + { + switchCases.Add(CreatePersistableModelCreateCoreXmlSwitchCase(typeForDeserialize)); + } + var typeOfT = _persistableModelTInterface.Arguments[0]; var defaultCase = SwitchCaseStatement.Default( ThrowValidationFailException(_mrwOptionsParameterSnippet.Format(), typeOfT, ReadAction)); @@ -858,7 +904,7 @@ private MethodBodyStatement[] BuildPersistableModelCreateCoreMethodBody() return [ GetConcreteFormat(_mrwOptionsParameterSnippet, _persistableModelTInterface, out VariableExpression format), - new SwitchStatement(format, [switchCase, defaultCase]) + new SwitchStatement(format, [.. switchCases, defaultCase]) ]; } @@ -2254,14 +2300,14 @@ private static bool TypeRequiresNullCheckInSerialization(CSharpType type) internal static ValueExpression GetDeserializationMethodInvocationForType( CSharpType modelType, - ScopedApi jsonElementVariable, - ValueExpression dataVariable, + ScopedApi element, + ValueExpression? dataVariable, ValueExpression? optionsVariable = null) { return ScmCodeModelGenerator.Instance.TypeFactory.CSharpTypeMap.TryGetValue(modelType, out var provider) && provider is ModelProvider modelProvider - ? GetDeserializationMethodInvocationForType(modelProvider, jsonElementVariable, dataVariable, optionsVariable) - : modelType.Deserialize(jsonElementVariable, null, optionsVariable); + ? GetDeserializationMethodInvocationForType(modelProvider, element, dataVariable, optionsVariable) + : modelType.Deserialize(element, null, optionsVariable); } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/ScmCodeModelGenerator.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/ScmCodeModelGenerator.cs index 0d9f0b3a36e..4dfc7e0146a 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/ScmCodeModelGenerator.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/ScmCodeModelGenerator.cs @@ -42,6 +42,7 @@ protected override void Configure() AddMetadataReference(MetadataReference.CreateFromFile(typeof(ClientResult).Assembly.Location)); AddMetadataReference(MetadataReference.CreateFromFile(typeof(BinaryData).Assembly.Location)); AddMetadataReference(MetadataReference.CreateFromFile(typeof(JsonSerializer).Assembly.Location)); + AddTypeToKeep(ModelReaderWriterContextDefinition.s_name, isRoot: false); } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/ScmTypeFactory.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/ScmTypeFactory.cs index 73127364c4e..bd301b41e96 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/ScmTypeFactory.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/ScmTypeFactory.cs @@ -143,7 +143,7 @@ protected override IReadOnlyList CreateSerializationsCore(InputTyp { switch (inputType) { - case InputModelType inputModel when inputModel.Usage.HasFlag(InputModelTypeUsage.Json): + case InputModelType inputModel when (inputModel.Usage & (InputModelTypeUsage.Json | InputModelTypeUsage.Xml)) != 0: if (typeProvider is ModelProvider modelProvider) { return [new MrwSerializationTypeDefinition(inputModel, modelProvider)]; diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Snippets/ModelReaderWriterOptionsSnippets.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Snippets/ModelReaderWriterOptionsSnippets.cs index 614719f2f29..f7b4ba31709 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Snippets/ModelReaderWriterOptionsSnippets.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Snippets/ModelReaderWriterOptionsSnippets.cs @@ -14,6 +14,7 @@ internal static class ModelReaderWriterOptionsSnippets public static ValueExpression Format(this ScopedApi mrwOptions) => mrwOptions.Property(nameof(ModelReaderWriterOptions.Format)); internal static ScopedApi WireFormat => Literal("W"); internal static ScopedApi JsonFormat => Literal("J"); + internal static ScopedApi XmlFormat => Literal("X"); internal static ScopedApi InitializeWireOptions => New.Instance(typeof(ModelReaderWriterOptions), Wire).As(); } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Snippets/XElementSnippets.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Snippets/XElementSnippets.cs new file mode 100644 index 00000000000..8e7ecda2683 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Snippets/XElementSnippets.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using System.Xml.Linq; +using Microsoft.TypeSpec.Generator.Expressions; +using Microsoft.TypeSpec.Generator.Snippets; +using static Microsoft.TypeSpec.Generator.Snippets.Snippet; + +namespace Microsoft.TypeSpec.Generator.ClientModel.Snippets +{ + /// + /// Provides extension methods for generating code that works with and . + /// + internal static class XElementSnippets + { + public static ScopedApi Name(this ScopedApi element) + => element.Property(nameof(XElement.Name)).As(); + public static ScopedApi GetLocalName(this ScopedApi element) + => Name(element).Property(nameof(XName.LocalName)).As(); + + public static ScopedApi> Elements(this ScopedApi element) + => element.Invoke(nameof(XElement.Elements)).As>(); + + public static ScopedApi> Elements(this ScopedApi element, ValueExpression name) + => element.Invoke(nameof(XElement.Elements), name).As>(); + + public static ScopedApi Value(this ScopedApi element) + => element.Property(nameof(XElement.Value)).As(); + + public static ScopedApi> Attributes(this ScopedApi element) + => element.Invoke(nameof(XElement.Attributes)).As>(); + public static ScopedApi Name(this ScopedApi attribute) + => attribute.Property(nameof(XAttribute.Name)).As(); + + public static ScopedApi GetLocalName(this ScopedApi attribute) + => Name(attribute).Property(nameof(XName.LocalName)).As(); + + public static ScopedApi Load(params ValueExpression[] args) + => Static().Invoke(nameof(XElement.Load), args).As(); + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Snippets/XmlLinqSnippets.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Snippets/XmlLinqSnippets.cs new file mode 100644 index 00000000000..fb783735891 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Snippets/XmlLinqSnippets.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Xml.Linq; +using Microsoft.TypeSpec.Generator.Snippets; +using static Microsoft.TypeSpec.Generator.Snippets.Snippet; + +namespace Microsoft.TypeSpec.Generator.ClientModel.Snippets +{ + public class XmlLinqSnippets + { + public static ScopedApi PreserveWhitespace + => Static().Property(nameof(LoadOptions.PreserveWhitespace)).As(); + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/MrwSerializationTypeDefinitions/XmlDeserializationTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/MrwSerializationTypeDefinitions/XmlDeserializationTests.cs new file mode 100644 index 00000000000..97e3d4c0ffe --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/MrwSerializationTypeDefinitions/XmlDeserializationTests.cs @@ -0,0 +1,306 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Linq; +using System.Xml.Linq; +using Microsoft.TypeSpec.Generator.ClientModel.Providers; +using Microsoft.TypeSpec.Generator.Input; +using Microsoft.TypeSpec.Generator.Primitives; +using Microsoft.TypeSpec.Generator.Providers; +using Microsoft.TypeSpec.Generator.Tests.Common; +using NUnit.Framework; + +namespace Microsoft.TypeSpec.Generator.ClientModel.Tests.Providers.MrwSerializationTypeDefinitions +{ + public class XmlDeserializationTests + { + public XmlDeserializationTests() + { + MockHelpers.LoadMockGenerator(createSerializationsCore: (inputType, typeProvider) + => inputType is InputModelType modelType ? [new MrwSerializationTypeDefinition(modelType, (typeProvider as ModelProvider)!)] : []); + } + + [Test] + public void XmlDeserializationMethodIsGeneratedForXmlModel() + { + // Arrange - create a model with XML usage + var inputModel = InputFactory.Model( + "TestXmlModel", + usage: InputModelTypeUsage.Input | InputModelTypeUsage.Xml, + properties: [InputFactory.Property("Name", InputPrimitiveType.String)]); + + // Act + var modelProvider = new ModelProvider(inputModel); + var mrwProvider = modelProvider.SerializationProviders.FirstOrDefault() as MrwSerializationTypeDefinition; + + // Assert + Assert.IsNotNull(mrwProvider); + var xmlDeserializationMethod = mrwProvider!.Methods.FirstOrDefault(m => m.Signature.Name == "DeserializeTestXmlModel" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(XElement)))); + Assert.IsNotNull(xmlDeserializationMethod, "XML deserialization method should be generated for models with XML usage"); + + // Verify method signature + Assert.AreEqual("DeserializeTestXmlModel", xmlDeserializationMethod!.Signature.Name); + Assert.AreEqual(2, xmlDeserializationMethod.Signature.Parameters.Count); + Assert.AreEqual(typeof(XElement), xmlDeserializationMethod.Signature.Parameters[0].Type.FrameworkType); + Assert.IsTrue(xmlDeserializationMethod.Signature.Modifiers.HasFlag(MethodSignatureModifiers.Internal)); + Assert.IsTrue(xmlDeserializationMethod.Signature.Modifiers.HasFlag(MethodSignatureModifiers.Static)); + } + + [Test] + public void XmlDeserializationMethodIsNotGeneratedForJsonOnlyModel() + { + // Arrange - create a model with only JSON usage (no XML) + var inputModel = InputFactory.Model( + "TestJsonModel", + usage: InputModelTypeUsage.Input | InputModelTypeUsage.Output | InputModelTypeUsage.Json, + properties: [InputFactory.Property("Name", InputPrimitiveType.String)]); + + // Act + var modelProvider = new ModelProvider(inputModel); + var mrwProvider = modelProvider.SerializationProviders.FirstOrDefault() as MrwSerializationTypeDefinition; + + // Assert + Assert.IsNotNull(mrwProvider); + var xmlDeserializationMethod = mrwProvider!.Methods.FirstOrDefault(m => m.Signature.Name == "DeserializeTestJsonModel" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(XElement)))); + Assert.IsNull(xmlDeserializationMethod, "XML deserialization method should NOT be generated for JSON-only models"); + } + + [Test] + public void XmlDeserializationMethodBodyContainsNullCheck() + { + // Arrange + var inputModel = InputFactory.Model( + "TestXmlModel", + usage: InputModelTypeUsage.Input | InputModelTypeUsage.Xml, + properties: [InputFactory.Property("Name", InputPrimitiveType.String)]); + + // Act + var modelProvider = new ModelProvider(inputModel); + var mrwProvider = modelProvider.SerializationProviders.FirstOrDefault() as MrwSerializationTypeDefinition; + var xmlDeserializationMethod = mrwProvider!.Methods.FirstOrDefault(m => m.Signature.Name == "DeserializeTestXmlModel" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(XElement)))); + + // Assert + Assert.IsNotNull(xmlDeserializationMethod); + var methodBody = xmlDeserializationMethod!.BodyStatements!.ToDisplayString(); + Assert.IsTrue(methodBody.Contains("element == null") || methodBody.Contains("element is null"), + "Method should contain null check for element parameter"); + } + + [Test] + public void XmlDeserializationMethodBodyContainsPropertyDeserialization() + { + // Arrange + var inputModel = InputFactory.Model( + "TestXmlModel", + usage: InputModelTypeUsage.Input | InputModelTypeUsage.Xml, + properties: [InputFactory.Property("name", InputPrimitiveType.String, isRequired: true)]); + + // Act + var modelProvider = new ModelProvider(inputModel); + var mrwProvider = modelProvider.SerializationProviders.FirstOrDefault() as MrwSerializationTypeDefinition; + var xmlDeserializationMethod = mrwProvider!.Methods.FirstOrDefault(m => m.Signature.Name == "DeserializeTestXmlModel" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(XElement)))); + + // Assert + Assert.IsNotNull(xmlDeserializationMethod); + var methodBody = xmlDeserializationMethod!.BodyStatements!.ToDisplayString(); + + // Should iterate over child elements + Assert.IsTrue(methodBody.Contains("foreach") && methodBody.Contains("Elements()"), + "Method should iterate over child elements"); + + // Should check for property names + Assert.IsTrue(methodBody.Contains("localName") || methodBody.Contains("LocalName"), + "Method should check element local names"); + } + + [Test] + public void XmlDeserializationMethodReturnsNewInstance() + { + // Arrange + var inputModel = InputFactory.Model( + "TestXmlModel", + usage: InputModelTypeUsage.Input | InputModelTypeUsage.Xml, + properties: [InputFactory.Property("Name", InputPrimitiveType.String)]); + + // Act + var modelProvider = new ModelProvider(inputModel); + var mrwProvider = modelProvider.SerializationProviders.FirstOrDefault() as MrwSerializationTypeDefinition; + var xmlDeserializationMethod = mrwProvider!.Methods.FirstOrDefault(m => m.Signature.Name == "DeserializeTestXmlModel" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(XElement)))); + + // Assert + Assert.IsNotNull(xmlDeserializationMethod); + var methodBody = xmlDeserializationMethod!.BodyStatements!.ToDisplayString(); + Assert.IsTrue(methodBody.Contains("return new") && methodBody.Contains("TestXmlModel"), + "Method should return a new instance of the model"); + } + + [Test] + public void XmlDeserializationMethodHandlesMultipleProperties() + { + // Arrange + var inputModel = InputFactory.Model( + "TestXmlModel", + usage: InputModelTypeUsage.Input | InputModelTypeUsage.Xml, + properties: + [ + InputFactory.Property("id", InputPrimitiveType.String, isRequired: true), + InputFactory.Property("name", InputPrimitiveType.String, isRequired: true), + InputFactory.Property("count", InputPrimitiveType.Int32) + ]); + + // Act + var modelProvider = new ModelProvider(inputModel); + var mrwProvider = modelProvider.SerializationProviders.FirstOrDefault() as MrwSerializationTypeDefinition; + var xmlDeserializationMethod = mrwProvider!.Methods.FirstOrDefault(m => m.Signature.Name == "DeserializeTestXmlModel" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(XElement)))); + + // Assert + Assert.IsNotNull(xmlDeserializationMethod); + var methodBody = xmlDeserializationMethod!.BodyStatements!.ToDisplayString(); + + // Should have checks for all properties + Assert.IsTrue(methodBody.Contains("\"id\""), "Method should check for 'id' property"); + Assert.IsTrue(methodBody.Contains("\"name\""), "Method should check for 'name' property"); + Assert.IsTrue(methodBody.Contains("\"count\""), "Method should check for 'count' property"); + } + + [Test] + public void XmlDeserializationMethodHandlesNestedModel() + { + // Arrange + var innerModel = InputFactory.Model( + "InnerModel", + usage: InputModelTypeUsage.Input | InputModelTypeUsage.Xml, + properties: [InputFactory.Property("value", InputPrimitiveType.String)]); + + var outerModel = InputFactory.Model( + "OuterModel", + usage: InputModelTypeUsage.Input | InputModelTypeUsage.Xml, + properties: [InputFactory.Property("inner", innerModel)]); + + MockHelpers.LoadMockGenerator( + inputModels: () => [innerModel, outerModel], + createSerializationsCore: (inputType, typeProvider) + => inputType is InputModelType modelType ? [new MrwSerializationTypeDefinition(modelType, (typeProvider as ModelProvider)!)] : []); + + // Act + var modelProvider = new ModelProvider(outerModel); + var mrwProvider = modelProvider.SerializationProviders.FirstOrDefault() as MrwSerializationTypeDefinition; + var xmlDeserializationMethod = mrwProvider!.Methods.FirstOrDefault(m => m.Signature.Name == "DeserializeOuterModel" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(XElement)))); + + // Assert + Assert.IsNotNull(xmlDeserializationMethod); + var methodBody = xmlDeserializationMethod!.BodyStatements!.ToDisplayString(); + + // Should call deserialize on inner model + Assert.IsTrue(methodBody.Contains("DeserializeInnerModel"), + "Method should call DeserializeInnerModel for nested model property"); + } + + [Test] + public void XmlDeserializationMethodHandlesUnwrappedListProperty() + { + // Arrange - create a model with an unwrapped list property (items are direct children) + var listProperty = new InputModelProperty( + name: "colors", + summary: null, + doc: "List of colors", + type: new InputArrayType("colors", "TypeSpec.Array", InputPrimitiveType.String), + isRequired: true, + isReadOnly: false, + isApiVersion: false, + defaultValue: null, + isHttpMetadata: false, + access: null, + isDiscriminator: false, + serializedName: "colors", + serializationOptions: new( + json: new("colors"), + xml: new("colors", unwrapped: true))); + + var inputModel = InputFactory.Model( + "ModelWithUnwrappedList", + usage: InputModelTypeUsage.Input | InputModelTypeUsage.Xml, + properties: [listProperty]); + + MockHelpers.LoadMockGenerator(createSerializationsCore: (inputType, typeProvider) + => inputType is InputModelType modelType ? [new MrwSerializationTypeDefinition(modelType, (typeProvider as ModelProvider)!)] : []); + + // Act + var modelProvider = new ModelProvider(inputModel); + var mrwProvider = modelProvider.SerializationProviders.FirstOrDefault() as MrwSerializationTypeDefinition; + var xmlDeserializationMethod = mrwProvider!.Methods.FirstOrDefault(m => m.Signature.Name == "DeserializeModelWithUnwrappedList" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(XElement)))); + + // Assert + Assert.IsNotNull(xmlDeserializationMethod); + var methodBody = xmlDeserializationMethod!.BodyStatements!.ToDisplayString(); + + // Unwrapped list should check for null and initialize if needed + Assert.IsTrue(methodBody.Contains("colors == null") || methodBody.Contains("colors is null"), + $"Unwrapped list should check for null before initializing. Actual:\n{methodBody}"); + + // Unwrapped list should be initialized with a new list when null + Assert.IsTrue(methodBody.Contains("colors = new"), + $"Unwrapped list should be initialized when null. Actual:\n{methodBody}"); + + // Unwrapped list should use Add() method directly + Assert.IsTrue(methodBody.Contains("colors.Add("), + $"Unwrapped list should use Add() method for items. Actual:\n{methodBody}"); + } + + [Test] + public void XmlDeserializationMethodHandlesWrappedListProperty() + { + // Arrange - create a model with a wrapped list property (items are inside a wrapper element) + var listProperty = new InputModelProperty( + name: "counts", + summary: null, + doc: "List of counts", + type: new InputArrayType("counts", "TypeSpec.Array", InputPrimitiveType.Int32), + isRequired: true, + isReadOnly: false, + isApiVersion: false, + defaultValue: null, + isHttpMetadata: false, + access: null, + isDiscriminator: false, + serializedName: "counts", + serializationOptions: new( + json: new("counts"), + xml: new("counts", unwrapped: false, itemsName: "int32"))); + + var inputModel = InputFactory.Model( + "ModelWithWrappedList", + usage: InputModelTypeUsage.Input | InputModelTypeUsage.Xml, + properties: [listProperty]); + + MockHelpers.LoadMockGenerator(createSerializationsCore: (inputType, typeProvider) + => inputType is InputModelType modelType ? [new MrwSerializationTypeDefinition(modelType, (typeProvider as ModelProvider)!)] : []); + + // Act + var modelProvider = new ModelProvider(inputModel); + var mrwProvider = modelProvider.SerializationProviders.FirstOrDefault() as MrwSerializationTypeDefinition; + var xmlDeserializationMethod = mrwProvider!.Methods.FirstOrDefault(m => m.Signature.Name == "DeserializeModelWithWrappedList" && + m.Signature.Parameters.Any(p => p.Type.Equals(typeof(XElement)))); + + // Assert + Assert.IsNotNull(xmlDeserializationMethod); + var methodBody = xmlDeserializationMethod!.BodyStatements!.ToDisplayString(); + + // Wrapped list should iterate over child elements with specific name + Assert.IsTrue(methodBody.Contains("Elements(\"int32\")"), + "Wrapped list should iterate over child elements with items name 'int32'"); + + // Wrapped list should create a temp array and assign it + Assert.IsTrue(methodBody.Contains("counts = array"), + "Wrapped list should assign temp array to property"); + } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.Input/src/InputLibrary.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.Input/src/InputLibrary.cs index d49942c1e39..01ceed10a25 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.Input/src/InputLibrary.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.Input/src/InputLibrary.cs @@ -45,6 +45,9 @@ internal InputNamespace Load() private bool? _hasMultiServiceClient; public bool HasMultiServiceClient => _hasMultiServiceClient ??= GetHasMultiServiceClient(); + private bool? _hasXmlModelSerialization; + public bool HasXmlModelSerialization => _hasXmlModelSerialization ??= GetHasXmlModelSerialization(); + private bool GetHasMultipartFormDataOperation() { foreach (var client in InputNamespace.Clients) @@ -73,5 +76,25 @@ private bool GetHasMultiServiceClient() return false; } + + private bool GetHasXmlModelSerialization() + { + foreach (var model in InputNamespace.Models) + { + if (model.Usage.HasFlag(InputModelTypeUsage.Xml)) + { + return true; + } + } + + foreach (var enumType in InputNamespace.Enums) + { + if (enumType.Usage.HasFlag(InputModelTypeUsage.Xml)) + { + return true; + } + } + return false; + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/PropertyWireInformation.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/PropertyWireInformation.cs index 68b43a1c015..65a3c166bad 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/PropertyWireInformation.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/PropertyWireInformation.cs @@ -16,6 +16,8 @@ public class PropertyWireInformation : WireInformation public bool IsHttpMetadata { get; } public bool IsApiVersion { get; } internal FormattableString? Description { get; } + public XmlWireInformation? XmlWireInformation { get; } + public PropertyWireInformation(SerializationFormat serializationFormat, bool isRequired, bool isReadOnly, bool isNullable, bool isDiscriminator, string serializedName, bool isHttpMetadata, bool isApiVersion) : base(serializationFormat, serializedName) { @@ -43,6 +45,9 @@ internal PropertyWireInformation(InputProperty inputProperty) IsDiscriminator = modelProperty != null && modelProperty.IsDiscriminator; Description = DocHelpers.GetFormattableDescription(inputProperty.Summary, inputProperty.Doc); IsApiVersion = inputProperty.IsApiVersion; + XmlWireInformation = modelProperty?.SerializationOptions?.Xml != null + ? new XmlWireInformation(modelProperty.SerializationOptions.Xml) + : null; } } } diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/XmlWireInformation.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/XmlWireInformation.cs new file mode 100644 index 00000000000..a8352ddddfa --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/XmlWireInformation.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.TypeSpec.Generator.Input; + +namespace Microsoft.TypeSpec.Generator.Primitives +{ + public class XmlWireInformation + { + public XmlWireInformation(InputXmlSerializationOptions xmlOptions) + { + Name = xmlOptions.Name; + Attribute = xmlOptions.Attribute; + Namespace = xmlOptions.Namespace != null + ? new(xmlOptions.Namespace) + : null; + Unwrapped = xmlOptions.Unwrapped; + ItemsName = xmlOptions.ItemsName; + ItemsNamespace = xmlOptions.ItemsNamespace != null + ? new(xmlOptions.ItemsNamespace) + : null; + } + + public string Name { get; } + + public bool? Attribute { get; } + + public XmlWireNamespaceOptions? Namespace { get; } + + public bool? Unwrapped { get; } + + public string? ItemsName { get; } + + public XmlWireNamespaceOptions? ItemsNamespace { get; } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/XmlWireNamespaceOptions.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/XmlWireNamespaceOptions.cs new file mode 100644 index 00000000000..7b1645c2db5 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/XmlWireNamespaceOptions.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.TypeSpec.Generator.Input; + +namespace Microsoft.TypeSpec.Generator.Primitives +{ + public class XmlWireNamespaceOptions + { + public XmlWireNamespaceOptions(InputXmlNamespaceOptions options) + { + Namespace = options.Namespace; + Prefix = options.Prefix; + } + + public string Namespace { get; } + + public string Prefix { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index 099511239df..60766b2c495 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -14,6 +14,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Text.Json; +using System.Xml.Linq; namespace SampleTypeSpec { @@ -342,5 +343,11 @@ public static ReadOnlySpan GetRemainder(this ReadOnlySpan jsonPath, { return index >= jsonPath.Length ? ReadOnlySpan.Empty : jsonPath[index] == '.' ? jsonPath.Slice(index) : jsonPath.Slice(index + 2); } + + public static DateTimeOffset GetDateTimeOffset(this XElement element, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds((long)element), + _ => TypeFormatters.ParseDateTimeOffset(element.Value, format) + }; } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Animal.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Animal.Serialization.cs index 36d704a717f..8e21be79945 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Animal.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Animal.Serialization.cs @@ -24,6 +24,31 @@ internal Animal() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Animal PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAnimal(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Animal)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator Animal(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAnimal(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -121,23 +146,6 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. Animal IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual Animal PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeAnimal(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Animal)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; @@ -150,13 +158,5 @@ public static implicit operator BinaryContent(Animal animal) } return BinaryContent.Create(animal, ModelSerializationExtensions.WireOptions); } - - /// The to deserialize the from. - public static explicit operator Animal(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeAnimal(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/AnotherDynamicModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/AnotherDynamicModel.Serialization.cs index 05e288342d8..76d814574ca 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/AnotherDynamicModel.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/AnotherDynamicModel.Serialization.cs @@ -20,6 +20,23 @@ internal AnotherDynamicModel() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AnotherDynamicModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAnotherDynamicModel(document.RootElement, data, options); + } + default: + throw new FormatException($"The model {nameof(AnotherDynamicModel)} does not support reading '{options.Format}' format."); + } + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -119,23 +136,6 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. AnotherDynamicModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual AnotherDynamicModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeAnotherDynamicModel(document.RootElement, data, options); - } - default: - throw new FormatException($"The model {nameof(AnotherDynamicModel)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Dog.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Dog.Serialization.cs index 470450f2c6e..e312c1a2ec5 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Dog.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Dog.Serialization.cs @@ -21,6 +21,31 @@ internal Dog() { } + /// The data to parse. + /// The client options for reading and writing models. + protected override Animal PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeDog(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Dog)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator Dog(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDog(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -124,23 +149,6 @@ protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. Dog IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (Dog)PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected override Animal PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeDog(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Dog)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; @@ -153,13 +161,5 @@ public static implicit operator BinaryContent(Dog dog) } return BinaryContent.Create(dog, ModelSerializationExtensions.WireOptions); } - - /// The to deserialize the from. - public static explicit operator Dog(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeDog(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/DynamicModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/DynamicModel.Serialization.cs index acf28b88405..64d91d7577a 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/DynamicModel.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/DynamicModel.Serialization.cs @@ -22,6 +22,23 @@ internal DynamicModel() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DynamicModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeDynamicModel(document.RootElement, data, options); + } + default: + throw new FormatException($"The model {nameof(DynamicModel)} does not support reading '{options.Format}' format."); + } + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -725,23 +742,6 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. DynamicModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual DynamicModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeDynamicModel(document.RootElement, data, options); - } - default: - throw new FormatException($"The model {nameof(DynamicModel)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Friend.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Friend.Serialization.cs index 715466fac81..9368f2860ec 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Friend.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Friend.Serialization.cs @@ -22,6 +22,31 @@ internal Friend() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Friend PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeFriend(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Friend)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator Friend(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFriend(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -121,23 +146,6 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. Friend IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual Friend PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeFriend(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Friend)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; @@ -150,13 +158,5 @@ public static implicit operator BinaryContent(Friend friend) } return BinaryContent.Create(friend, ModelSerializationExtensions.WireOptions); } - - /// The to deserialize the from. - public static explicit operator Friend(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeFriend(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/GetWidgetMetricsResponse.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/GetWidgetMetricsResponse.Serialization.cs index d7a261e2e5b..203f73fcd66 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/GetWidgetMetricsResponse.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/GetWidgetMetricsResponse.Serialization.cs @@ -21,6 +21,31 @@ internal GetWidgetMetricsResponse() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GetWidgetMetricsResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeGetWidgetMetricsResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetWidgetMetricsResponse)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator GetWidgetMetricsResponse(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetWidgetMetricsResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -128,32 +153,7 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. GetWidgetMetricsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual GetWidgetMetricsResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeGetWidgetMetricsResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GetWidgetMetricsResponse)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to deserialize the from. - public static explicit operator GetWidgetMetricsResponse(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeGetWidgetMetricsResponse(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithContinuationTokenHeaderResponseResponse.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithContinuationTokenHeaderResponseResponse.Serialization.cs index 753e36cf347..39b7850d230 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithContinuationTokenHeaderResponseResponse.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithContinuationTokenHeaderResponseResponse.Serialization.cs @@ -21,6 +21,31 @@ internal ListWithContinuationTokenHeaderResponseResponse() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ListWithContinuationTokenHeaderResponseResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeListWithContinuationTokenHeaderResponseResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListWithContinuationTokenHeaderResponseResponse)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ListWithContinuationTokenHeaderResponseResponse(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeListWithContinuationTokenHeaderResponseResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -130,32 +155,7 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. ListWithContinuationTokenHeaderResponseResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual ListWithContinuationTokenHeaderResponseResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeListWithContinuationTokenHeaderResponseResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ListWithContinuationTokenHeaderResponseResponse)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to deserialize the from. - public static explicit operator ListWithContinuationTokenHeaderResponseResponse(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeListWithContinuationTokenHeaderResponseResponse(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithContinuationTokenResponse.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithContinuationTokenResponse.Serialization.cs index 1f3bdc3a151..5768d610033 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithContinuationTokenResponse.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithContinuationTokenResponse.Serialization.cs @@ -21,6 +21,31 @@ internal ListWithContinuationTokenResponse() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ListWithContinuationTokenResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeListWithContinuationTokenResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListWithContinuationTokenResponse)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ListWithContinuationTokenResponse(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeListWithContinuationTokenResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -141,32 +166,7 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. ListWithContinuationTokenResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual ListWithContinuationTokenResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeListWithContinuationTokenResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ListWithContinuationTokenResponse)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to deserialize the from. - public static explicit operator ListWithContinuationTokenResponse(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeListWithContinuationTokenResponse(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithNextLinkResponse.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithNextLinkResponse.Serialization.cs index a7b7a76b808..c7de729f4a5 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithNextLinkResponse.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithNextLinkResponse.Serialization.cs @@ -21,6 +21,31 @@ internal ListWithNextLinkResponse() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ListWithNextLinkResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeListWithNextLinkResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListWithNextLinkResponse)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ListWithNextLinkResponse(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeListWithNextLinkResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -145,32 +170,7 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. ListWithNextLinkResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual ListWithNextLinkResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeListWithNextLinkResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ListWithNextLinkResponse)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to deserialize the from. - public static explicit operator ListWithNextLinkResponse(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeListWithNextLinkResponse(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithStringNextLinkResponse.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithStringNextLinkResponse.Serialization.cs index d67a1f445b4..74606f9283c 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithStringNextLinkResponse.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ListWithStringNextLinkResponse.Serialization.cs @@ -21,6 +21,31 @@ internal ListWithStringNextLinkResponse() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ListWithStringNextLinkResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeListWithStringNextLinkResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ListWithStringNextLinkResponse)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ListWithStringNextLinkResponse(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeListWithStringNextLinkResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -141,32 +166,7 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. ListWithStringNextLinkResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual ListWithStringNextLinkResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeListWithStringNextLinkResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ListWithStringNextLinkResponse)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to deserialize the from. - public static explicit operator ListWithStringNextLinkResponse(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeListWithStringNextLinkResponse(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ModelWithEmbeddedNonBodyParameters.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ModelWithEmbeddedNonBodyParameters.Serialization.cs index 89013095b0b..3278bcbccd6 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ModelWithEmbeddedNonBodyParameters.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ModelWithEmbeddedNonBodyParameters.Serialization.cs @@ -21,6 +21,23 @@ internal ModelWithEmbeddedNonBodyParameters() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithEmbeddedNonBodyParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeModelWithEmbeddedNonBodyParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModelWithEmbeddedNonBodyParameters)} does not support reading '{options.Format}' format."); + } + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -130,23 +147,6 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. ModelWithEmbeddedNonBodyParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual ModelWithEmbeddedNonBodyParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeModelWithEmbeddedNonBodyParameters(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ModelWithEmbeddedNonBodyParameters)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ModelWithRequiredNullableProperties.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ModelWithRequiredNullableProperties.Serialization.cs index 9871324e6a1..7671388ac90 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ModelWithRequiredNullableProperties.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ModelWithRequiredNullableProperties.Serialization.cs @@ -20,6 +20,23 @@ internal ModelWithRequiredNullableProperties() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithRequiredNullableProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeModelWithRequiredNullableProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModelWithRequiredNullableProperties)} does not support reading '{options.Format}' format."); + } + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -171,23 +188,6 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. ModelWithRequiredNullableProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual ModelWithRequiredNullableProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeModelWithRequiredNullableProperties(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ModelWithRequiredNullableProperties)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/PageThing.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/PageThing.Serialization.cs index c1c6b331996..dda7f8cd2dc 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/PageThing.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/PageThing.Serialization.cs @@ -21,6 +21,31 @@ internal PageThing() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PageThing PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePageThing(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PageThing)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator PageThing(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePageThing(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -130,32 +155,7 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. PageThing IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual PageThing PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializePageThing(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(PageThing)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to deserialize the from. - public static explicit operator PageThing(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializePageThing(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Pet.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Pet.Serialization.cs index e7d61d27402..9f6c2a6fd5d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Pet.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Pet.Serialization.cs @@ -20,6 +20,31 @@ internal Pet() { } + /// The data to parse. + /// The client options for reading and writing models. + protected override Animal PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePet(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Pet)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator Pet(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePet(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -99,23 +124,6 @@ protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. Pet IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (Pet)PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected override Animal PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializePet(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Pet)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; @@ -128,13 +136,5 @@ public static implicit operator BinaryContent(Pet pet) } return BinaryContent.Create(pet, ModelSerializationExtensions.WireOptions); } - - /// The to deserialize the from. - public static explicit operator Pet(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializePet(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/RenamedModelCustom.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/RenamedModelCustom.Serialization.cs index 667d863ca58..ec084524432 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/RenamedModelCustom.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/RenamedModelCustom.Serialization.cs @@ -22,6 +22,31 @@ internal RenamedModelCustom() { } + /// The data to parse. + /// The client options for reading and writing models. + protected override Friend PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRenamedModelCustom(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RenamedModelCustom)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator RenamedModelCustom(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRenamedModelCustom(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -113,23 +138,6 @@ protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. RenamedModelCustom IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (RenamedModelCustom)PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected override Friend PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeRenamedModelCustom(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RenamedModelCustom)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; @@ -142,13 +150,5 @@ public static implicit operator BinaryContent(RenamedModelCustom renamedModelCus } return BinaryContent.Create(renamedModelCustom, ModelSerializationExtensions.WireOptions); } - - /// The to deserialize the from. - public static explicit operator RenamedModelCustom(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRenamedModelCustom(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ReturnsAnonymousModelResponse.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ReturnsAnonymousModelResponse.Serialization.cs index 28685cb3e92..9bfad705646 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ReturnsAnonymousModelResponse.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/ReturnsAnonymousModelResponse.Serialization.cs @@ -16,6 +16,31 @@ namespace SampleTypeSpec /// The ReturnsAnonymousModelResponse. public partial class ReturnsAnonymousModelResponse : IJsonModel { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ReturnsAnonymousModelResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeReturnsAnonymousModelResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ReturnsAnonymousModelResponse)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ReturnsAnonymousModelResponse(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeReturnsAnonymousModelResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -107,32 +132,7 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. ReturnsAnonymousModelResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual ReturnsAnonymousModelResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeReturnsAnonymousModelResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ReturnsAnonymousModelResponse)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// The to deserialize the from. - public static explicit operator ReturnsAnonymousModelResponse(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeReturnsAnonymousModelResponse(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/RoundTripModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/RoundTripModel.Serialization.cs index 59152f4ac49..569577f9543 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/RoundTripModel.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/RoundTripModel.Serialization.cs @@ -21,6 +21,31 @@ internal RoundTripModel() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RoundTripModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRoundTripModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RoundTripModel)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator RoundTripModel(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRoundTripModel(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -625,23 +650,6 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. RoundTripModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual RoundTripModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeRoundTripModel(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RoundTripModel)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; @@ -654,13 +662,5 @@ public static implicit operator BinaryContent(RoundTripModel roundTripModel) } return BinaryContent.Create(roundTripModel, ModelSerializationExtensions.WireOptions); } - - /// The to deserialize the from. - public static explicit operator RoundTripModel(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeRoundTripModel(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/SampleTypeSpecContext.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/SampleTypeSpecContext.cs index 2a2fe6a977f..d9b3a919f0c 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/SampleTypeSpecContext.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/SampleTypeSpecContext.cs @@ -34,6 +34,9 @@ namespace SampleTypeSpec [ModelReaderWriterBuildable(typeof(Thing))] [ModelReaderWriterBuildable(typeof(UnknownAnimal))] [ModelReaderWriterBuildable(typeof(UnknownPet))] + [ModelReaderWriterBuildable(typeof(XmlAdvancedModel))] + [ModelReaderWriterBuildable(typeof(XmlItem))] + [ModelReaderWriterBuildable(typeof(XmlNestedModel))] public partial class SampleTypeSpecContext : ModelReaderWriterContext { } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Thing.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Thing.Serialization.cs index cc309d6d3ad..36d8bd8a023 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Thing.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/Thing.Serialization.cs @@ -21,6 +21,31 @@ internal Thing() { } + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Thing PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeThing(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Thing)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator Thing(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeThing(document.RootElement, ModelSerializationExtensions.WireOptions); + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -372,23 +397,6 @@ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. Thing IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected virtual Thing PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeThing(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Thing)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; @@ -401,13 +409,5 @@ public static implicit operator BinaryContent(Thing thing) } return BinaryContent.Create(thing, ModelSerializationExtensions.WireOptions); } - - /// The to deserialize the from. - public static explicit operator Thing(ClientResult result) - { - PipelineResponse response = result.GetRawResponse(); - using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeThing(document.RootElement, ModelSerializationExtensions.WireOptions); - } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/UnknownAnimal.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/UnknownAnimal.Serialization.cs index 535dd928e85..02f798558f9 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/UnknownAnimal.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/UnknownAnimal.Serialization.cs @@ -19,6 +19,23 @@ internal UnknownAnimal() { } + /// The data to parse. + /// The client options for reading and writing models. + protected override Animal PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAnimal(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Animal)} does not support reading '{options.Format}' format."); + } + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -108,23 +125,6 @@ protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. Animal IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected override Animal PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializeAnimal(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Animal)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/UnknownPet.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/UnknownPet.Serialization.cs index b0074ad04b3..6a2c3ad5adc 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/UnknownPet.Serialization.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/UnknownPet.Serialization.cs @@ -19,6 +19,23 @@ internal UnknownPet() { } + /// The data to parse. + /// The client options for reading and writing models. + protected override Animal PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePet(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Pet)} does not support reading '{options.Format}' format."); + } + } + /// The JSON writer. /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -114,23 +131,6 @@ protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions /// The client options for reading and writing models. Pet IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (UnknownPet)PersistableModelCreateCore(data, options); - /// The data to parse. - /// The client options for reading and writing models. - protected override Animal PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) - { - string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) - { - return DeserializePet(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Pet)} does not support reading '{options.Format}' format."); - } - } - /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/XmlAdvancedModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/XmlAdvancedModel.Serialization.cs new file mode 100644 index 00000000000..c80cbd20f35 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/XmlAdvancedModel.Serialization.cs @@ -0,0 +1,271 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace SampleTypeSpec +{ + /// An advanced XML model for testing various property types and XML features. + public partial class XmlAdvancedModel + { + /// Initializes a new instance of for deserialization. + internal XmlAdvancedModel() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual XmlAdvancedModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeXmlAdvancedModel(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(XmlAdvancedModel)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator XmlAdvancedModel(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeXmlAdvancedModel(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static XmlAdvancedModel DeserializeXmlAdvancedModel(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + string name = default; + int age = default; + bool enabled = default; + float score = default; + string optionalString = default; + int? optionalInt = default; + string nullableString = default; + string id = default; + int version = default; + bool isActive = default; + string originalName = default; + string xmlIdentifier = default; + string content = default; + IList unwrappedStrings = default; + IList unwrappedCounts = default; + IList unwrappedItems = default; + IList wrappedColors = default; + IList items = default; + XmlNestedModel nestedModel = default; + XmlNestedModel optionalNestedModel = default; + IDictionary metadata = default; + DateTimeOffset createdAt = default; + TimeSpan duration = default; + BinaryData data = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var attr in element.Attributes()) + { + string localName = attr.Name.LocalName; + if (localName == "id") + { + id = (string)attr; + continue; + } + if (localName == "version") + { + version = (int)attr; + continue; + } + if (localName == "isActive") + { + isActive = (bool)attr; + continue; + } + if (localName == "xml-id") + { + xmlIdentifier = (string)attr; + continue; + } + } + + foreach (var child in element.Elements()) + { + string localName = child.Name.LocalName; + if (localName == "name") + { + name = (string)child; + continue; + } + if (localName == "age") + { + age = (int)child; + continue; + } + if (localName == "enabled") + { + enabled = (bool)child; + continue; + } + if (localName == "score") + { + score = (float)child; + continue; + } + if (localName == "optionalString") + { + optionalString = (string)child; + continue; + } + if (localName == "optionalInt") + { + optionalInt = (int?)child; + continue; + } + if (localName == "nullableString") + { + nullableString = (string)child; + continue; + } + if (localName == "RenamedProperty") + { + originalName = (string)child; + continue; + } + if (localName == "unwrappedStrings") + { + if (unwrappedStrings == null) + { + unwrappedStrings = new ChangeTrackingList(); + } + unwrappedStrings.Add((string)child); + continue; + } + if (localName == "unwrappedCounts") + { + if (unwrappedCounts == null) + { + unwrappedCounts = new ChangeTrackingList(); + } + unwrappedCounts.Add((int)child); + continue; + } + if (localName == "unwrappedItems") + { + if (unwrappedItems == null) + { + unwrappedItems = new ChangeTrackingList(); + } + unwrappedItems.Add(XmlItem.DeserializeXmlItem(child, options)); + continue; + } + if (localName == "wrappedColors") + { + List array = new List(); + foreach (var e in child.Elements("string")) + { + array.Add((string)e); + } + wrappedColors = array; + continue; + } + if (localName == "ItemCollection") + { + List array = new List(); + foreach (var e in child.Elements("Item")) + { + array.Add(XmlItem.DeserializeXmlItem(e, options)); + } + items = array; + continue; + } + if (localName == "nestedModel") + { + nestedModel = XmlNestedModel.DeserializeXmlNestedModel(child, options); + continue; + } + if (localName == "optionalNestedModel") + { + optionalNestedModel = XmlNestedModel.DeserializeXmlNestedModel(child, options); + continue; + } + if (localName == "metadata") + { + Dictionary dictionary = new Dictionary(); + foreach (var e in child.Elements()) + { + dictionary.Add(e.Name.LocalName, (string)e); + } + metadata = dictionary; + continue; + } + if (localName == "createdAt") + { + createdAt = (DateTimeOffset)child; + continue; + } + if (localName == "duration") + { + duration = (TimeSpan)child; + continue; + } + if (localName == "data") + { + data = (BinaryData)child; + continue; + } + } + content = element.Value; + + return new XmlAdvancedModel( + name, + age, + enabled, + score, + optionalString, + optionalInt, + nullableString, + id, + version, + isActive, + originalName, + xmlIdentifier, + content, + unwrappedStrings, + unwrappedCounts, + unwrappedItems, + wrappedColors, + items, + nestedModel, + optionalNestedModel, + metadata, + createdAt, + duration, + data, + additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/XmlAdvancedModel.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/XmlAdvancedModel.cs new file mode 100644 index 00000000000..d047cb53e18 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/XmlAdvancedModel.cs @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace SampleTypeSpec +{ + /// An advanced XML model for testing various property types and XML features. + public partial class XmlAdvancedModel + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// A simple string property. + /// An integer property. + /// A boolean property. + /// A float property. + /// A nullable string. + /// A string as XML attribute. + /// An integer as XML attribute. + /// A boolean as XML attribute. + /// A property with a custom XML element name. + /// An attribute with a custom XML name. + /// Text content in the element (unwrapped string). + /// An unwrapped array of strings - items appear directly without wrapper. + /// An unwrapped array of integers. + /// An unwrapped array of models. + /// A wrapped array of strings (default). + /// A wrapped array with custom wrapper name. + /// A nested model property. + /// A dictionary property. + /// A date-time property. + /// A duration property. + /// A bytes property. + internal XmlAdvancedModel(string name, int age, bool enabled, float score, string nullableString, string id, int version, bool isActive, string originalName, string xmlIdentifier, string content, IEnumerable unwrappedStrings, IEnumerable unwrappedCounts, IEnumerable unwrappedItems, IEnumerable wrappedColors, IEnumerable items, XmlNestedModel nestedModel, IDictionary metadata, DateTimeOffset createdAt, TimeSpan duration, BinaryData data) + { + Name = name; + Age = age; + Enabled = enabled; + Score = score; + NullableString = nullableString; + Id = id; + Version = version; + IsActive = isActive; + OriginalName = originalName; + XmlIdentifier = xmlIdentifier; + Content = content; + UnwrappedStrings = unwrappedStrings.ToList(); + UnwrappedCounts = unwrappedCounts.ToList(); + UnwrappedItems = unwrappedItems.ToList(); + WrappedColors = wrappedColors.ToList(); + Items = items.ToList(); + NestedModel = nestedModel; + Metadata = metadata; + CreatedAt = createdAt; + Duration = duration; + Data = data; + } + + /// Initializes a new instance of . + /// A simple string property. + /// An integer property. + /// A boolean property. + /// A float property. + /// An optional string. + /// An optional integer. + /// A nullable string. + /// A string as XML attribute. + /// An integer as XML attribute. + /// A boolean as XML attribute. + /// A property with a custom XML element name. + /// An attribute with a custom XML name. + /// Text content in the element (unwrapped string). + /// An unwrapped array of strings - items appear directly without wrapper. + /// An unwrapped array of integers. + /// An unwrapped array of models. + /// A wrapped array of strings (default). + /// A wrapped array with custom wrapper name. + /// A nested model property. + /// An optional nested model. + /// A dictionary property. + /// A date-time property. + /// A duration property. + /// A bytes property. + /// Keeps track of any properties unknown to the library. + internal XmlAdvancedModel(string name, int age, bool enabled, float score, string optionalString, int? optionalInt, string nullableString, string id, int version, bool isActive, string originalName, string xmlIdentifier, string content, IList unwrappedStrings, IList unwrappedCounts, IList unwrappedItems, IList wrappedColors, IList items, XmlNestedModel nestedModel, XmlNestedModel optionalNestedModel, IDictionary metadata, DateTimeOffset createdAt, TimeSpan duration, BinaryData data, IDictionary additionalBinaryDataProperties) + { + Name = name; + Age = age; + Enabled = enabled; + Score = score; + OptionalString = optionalString; + OptionalInt = optionalInt; + NullableString = nullableString; + Id = id; + Version = version; + IsActive = isActive; + OriginalName = originalName; + XmlIdentifier = xmlIdentifier; + Content = content; + UnwrappedStrings = unwrappedStrings; + UnwrappedCounts = unwrappedCounts; + UnwrappedItems = unwrappedItems; + WrappedColors = wrappedColors; + Items = items; + NestedModel = nestedModel; + OptionalNestedModel = optionalNestedModel; + Metadata = metadata; + CreatedAt = createdAt; + Duration = duration; + Data = data; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A simple string property. + public string Name { get; } + + /// An integer property. + public int Age { get; } + + /// A boolean property. + public bool Enabled { get; } + + /// A float property. + public float Score { get; } + + /// An optional string. + public string OptionalString { get; } + + /// An optional integer. + public int? OptionalInt { get; } + + /// A nullable string. + public string NullableString { get; } + + /// A string as XML attribute. + public string Id { get; } + + /// An integer as XML attribute. + public int Version { get; } + + /// A boolean as XML attribute. + public bool IsActive { get; } + + /// A property with a custom XML element name. + public string OriginalName { get; } + + /// An attribute with a custom XML name. + public string XmlIdentifier { get; } + + /// Text content in the element (unwrapped string). + public string Content { get; } + + /// An unwrapped array of strings - items appear directly without wrapper. + public IList UnwrappedStrings { get; } + + /// An unwrapped array of integers. + public IList UnwrappedCounts { get; } + + /// An unwrapped array of models. + public IList UnwrappedItems { get; } + + /// A wrapped array of strings (default). + public IList WrappedColors { get; } + + /// A wrapped array with custom wrapper name. + public IList Items { get; } + + /// A nested model property. + public XmlNestedModel NestedModel { get; } + + /// An optional nested model. + public XmlNestedModel OptionalNestedModel { get; } + + /// A dictionary property. + public IDictionary Metadata { get; } + + /// A date-time property. + public DateTimeOffset CreatedAt { get; } + + /// A duration property. + public TimeSpan Duration { get; } + + /// + /// A bytes property + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }). + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData Data { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.RestClient.cs index ef5e2f87d29..808b5d40608 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.RestClient.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.RestClient.cs @@ -406,5 +406,17 @@ internal PipelineMessage CreateDynamicModelOperationRequest(BinaryContent conten message.Apply(options); return message; } + + internal PipelineMessage CreateGetXmlAdvancedModelRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/xmlAdvanced", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } } } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs index 83acde20eb0..90bd8bd5d47 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs @@ -1735,6 +1735,58 @@ public virtual async Task DynamicModelOperationAsync(DynamicModel return await DynamicModelOperationAsync(body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); } + /// + /// [Protocol Method] Get an advanced XML model with various property types + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult GetXmlAdvancedModel(RequestOptions options) + { + using PipelineMessage message = CreateGetXmlAdvancedModelRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get an advanced XML model with various property types + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetXmlAdvancedModelAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetXmlAdvancedModelRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get an advanced XML model with various property types. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult GetXmlAdvancedModel(CancellationToken cancellationToken = default) + { + ClientResult result = GetXmlAdvancedModel(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + } + + /// Get an advanced XML model with various property types. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetXmlAdvancedModelAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetXmlAdvancedModelAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((XmlAdvancedModel)result, result.GetRawResponse()); + } + /// Initializes a new instance of AnimalOperations. public virtual AnimalOperations GetAnimalOperationsClient() { diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecModelFactory.cs index f8616b3f57e..0971184b975 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecModelFactory.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecModelFactory.cs @@ -236,6 +236,88 @@ public static AnotherDynamicModel AnotherDynamicModel(string bar = default) return new AnotherDynamicModel(bar, default); } + /// An advanced XML model for testing various property types and XML features. + /// A simple string property. + /// An integer property. + /// A boolean property. + /// A float property. + /// An optional string. + /// An optional integer. + /// A nullable string. + /// A string as XML attribute. + /// An integer as XML attribute. + /// A boolean as XML attribute. + /// A property with a custom XML element name. + /// An attribute with a custom XML name. + /// Text content in the element (unwrapped string). + /// An unwrapped array of strings - items appear directly without wrapper. + /// An unwrapped array of integers. + /// An unwrapped array of models. + /// A wrapped array of strings (default). + /// A wrapped array with custom wrapper name. + /// A nested model property. + /// An optional nested model. + /// A dictionary property. + /// A date-time property. + /// A duration property. + /// A bytes property. + /// A new instance for mocking. + public static XmlAdvancedModel XmlAdvancedModel(string name = default, int age = default, bool enabled = default, float score = default, string optionalString = default, int? optionalInt = default, string nullableString = default, string id = default, int version = default, bool isActive = default, string originalName = default, string xmlIdentifier = default, string content = default, IEnumerable unwrappedStrings = default, IEnumerable unwrappedCounts = default, IEnumerable unwrappedItems = default, IEnumerable wrappedColors = default, IEnumerable items = default, XmlNestedModel nestedModel = default, XmlNestedModel optionalNestedModel = default, IDictionary metadata = default, DateTimeOffset createdAt = default, TimeSpan duration = default, BinaryData data = default) + { + unwrappedStrings ??= new ChangeTrackingList(); + unwrappedCounts ??= new ChangeTrackingList(); + unwrappedItems ??= new ChangeTrackingList(); + wrappedColors ??= new ChangeTrackingList(); + items ??= new ChangeTrackingList(); + metadata ??= new ChangeTrackingDictionary(); + + return new XmlAdvancedModel( + name, + age, + enabled, + score, + optionalString, + optionalInt, + nullableString, + id, + version, + isActive, + originalName, + xmlIdentifier, + content, + unwrappedStrings.ToList(), + unwrappedCounts.ToList(), + unwrappedItems.ToList(), + wrappedColors.ToList(), + items.ToList(), + nestedModel, + optionalNestedModel, + metadata, + createdAt, + duration, + data, + additionalBinaryDataProperties: null); + } + + /// An item model for XML array testing. + /// The item name. + /// The item value. + /// Item ID as attribute. + /// A new instance for mocking. + public static XmlItem XmlItem(string itemName = default, int itemValue = default, string itemId = default) + { + return new XmlItem(itemName, itemValue, itemId, additionalBinaryDataProperties: null); + } + + /// A nested model for XML testing. + /// The value of the nested model. + /// An attribute on the nested model. + /// A new instance for mocking. + public static XmlNestedModel XmlNestedModel(string value = default, int nestedId = default) + { + return new XmlNestedModel(value, nestedId, additionalBinaryDataProperties: null); + } + /// /// Base animal with discriminator /// Please note this is the abstract base class. The derived classes available for instantiation are: and . diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/tspCodeModel.json index 43e7b9552c0..80d527a211d 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/tspCodeModel.json @@ -1631,7 +1631,7 @@ { "$id": "174", "kind": "constant", - "name": "updatePetAsAnimalContentType", + "name": "GetXmlAdvancedModelContentType", "namespace": "", "usage": "None", "valueType": { @@ -1641,13 +1641,13 @@ "crossLanguageDefinitionId": "TypeSpec.string", "decorators": [] }, - "value": "application/json", + "value": "application/xml", "decorators": [] }, { "$id": "176", "kind": "constant", - "name": "updatePetAsAnimalContentType1", + "name": "GetXmlAdvancedModelResponseContentType", "namespace": "", "usage": "None", "valueType": { @@ -1657,13 +1657,13 @@ "crossLanguageDefinitionId": "TypeSpec.string", "decorators": [] }, - "value": "application/json", + "value": "application/xml", "decorators": [] }, { "$id": "178", "kind": "constant", - "name": "updateDogAsAnimalContentType", + "name": "updatePetAsAnimalContentType", "namespace": "", "usage": "None", "valueType": { @@ -1679,7 +1679,7 @@ { "$id": "180", "kind": "constant", - "name": "updateDogAsAnimalContentType1", + "name": "updatePetAsAnimalContentType1", "namespace": "", "usage": "None", "valueType": { @@ -1695,7 +1695,7 @@ { "$id": "182", "kind": "constant", - "name": "updatePetAsPetContentType", + "name": "updateDogAsAnimalContentType", "namespace": "", "usage": "None", "valueType": { @@ -1711,7 +1711,7 @@ { "$id": "184", "kind": "constant", - "name": "updatePetAsPetContentType1", + "name": "updateDogAsAnimalContentType1", "namespace": "", "usage": "None", "valueType": { @@ -1727,7 +1727,7 @@ { "$id": "186", "kind": "constant", - "name": "updateDogAsPetContentType", + "name": "updatePetAsPetContentType", "namespace": "", "usage": "None", "valueType": { @@ -1743,7 +1743,7 @@ { "$id": "188", "kind": "constant", - "name": "updateDogAsPetContentType1", + "name": "updatePetAsPetContentType1", "namespace": "", "usage": "None", "valueType": { @@ -1759,7 +1759,7 @@ { "$id": "190", "kind": "constant", - "name": "updateDogAsDogContentType", + "name": "updateDogAsPetContentType", "namespace": "", "usage": "None", "valueType": { @@ -1775,7 +1775,7 @@ { "$id": "192", "kind": "constant", - "name": "updateDogAsDogContentType1", + "name": "updateDogAsPetContentType1", "namespace": "", "usage": "None", "valueType": { @@ -1791,7 +1791,7 @@ { "$id": "194", "kind": "constant", - "name": "getWidgetMetricsContentType", + "name": "updateDogAsDogContentType", "namespace": "", "usage": "None", "valueType": { @@ -1803,11 +1803,43 @@ }, "value": "application/json", "decorators": [] + }, + { + "$id": "196", + "kind": "constant", + "name": "updateDogAsDogContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "197", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + { + "$id": "198", + "kind": "constant", + "name": "getWidgetMetricsContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "199", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] } ], "models": [ { - "$id": "196", + "$id": "200", "kind": "model", "name": "Thing", "namespace": "SampleTypeSpec", @@ -1822,13 +1854,13 @@ }, "properties": [ { - "$id": "197", + "$id": "201", "kind": "property", "name": "name", "serializedName": "name", "doc": "name of the Thing", "type": { - "$id": "198", + "$id": "202", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -1848,29 +1880,29 @@ "isHttpMetadata": false }, { - "$id": "199", + "$id": "203", "kind": "property", "name": "requiredUnion", "serializedName": "requiredUnion", "doc": "required Union", "type": { - "$id": "200", + "$id": "204", "kind": "union", "name": "ThingRequiredUnion", "variantTypes": [ { - "$id": "201", + "$id": "205", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", "decorators": [] }, { - "$id": "202", + "$id": "206", "kind": "array", "name": "Array", "valueType": { - "$id": "203", + "$id": "207", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -1880,7 +1912,7 @@ "decorators": [] }, { - "$id": "204", + "$id": "208", "kind": "int32", "name": "int32", "crossLanguageDefinitionId": "TypeSpec.int32", @@ -1904,7 +1936,7 @@ "isHttpMetadata": false }, { - "$id": "205", + "$id": "209", "kind": "property", "name": "requiredLiteralString", "serializedName": "requiredLiteralString", @@ -1926,16 +1958,16 @@ "isHttpMetadata": false }, { - "$id": "206", + "$id": "210", "kind": "property", "name": "requiredNullableString", "serializedName": "requiredNullableString", "doc": "required nullable string", "type": { - "$id": "207", + "$id": "211", "kind": "nullable", "type": { - "$id": "208", + "$id": "212", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -1957,16 +1989,16 @@ "isHttpMetadata": false }, { - "$id": "209", + "$id": "213", "kind": "property", "name": "optionalNullableString", "serializedName": "optionalNullableString", "doc": "required optional string", "type": { - "$id": "210", + "$id": "214", "kind": "nullable", "type": { - "$id": "211", + "$id": "215", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -1988,7 +2020,7 @@ "isHttpMetadata": false }, { - "$id": "212", + "$id": "216", "kind": "property", "name": "requiredLiteralInt", "serializedName": "requiredLiteralInt", @@ -2010,7 +2042,7 @@ "isHttpMetadata": false }, { - "$id": "213", + "$id": "217", "kind": "property", "name": "requiredLiteralFloat", "serializedName": "requiredLiteralFloat", @@ -2032,7 +2064,7 @@ "isHttpMetadata": false }, { - "$id": "214", + "$id": "218", "kind": "property", "name": "requiredLiteralBool", "serializedName": "requiredLiteralBool", @@ -2054,7 +2086,7 @@ "isHttpMetadata": false }, { - "$id": "215", + "$id": "219", "kind": "property", "name": "optionalLiteralString", "serializedName": "optionalLiteralString", @@ -2076,13 +2108,13 @@ "isHttpMetadata": false }, { - "$id": "216", + "$id": "220", "kind": "property", "name": "requiredNullableLiteralString", "serializedName": "requiredNullableLiteralString", "doc": "required nullable literal string", "type": { - "$id": "217", + "$id": "221", "kind": "nullable", "type": { "$ref": "5" @@ -2103,7 +2135,7 @@ "isHttpMetadata": false }, { - "$id": "218", + "$id": "222", "kind": "property", "name": "optionalLiteralInt", "serializedName": "optionalLiteralInt", @@ -2125,7 +2157,7 @@ "isHttpMetadata": false }, { - "$id": "219", + "$id": "223", "kind": "property", "name": "optionalLiteralFloat", "serializedName": "optionalLiteralFloat", @@ -2147,7 +2179,7 @@ "isHttpMetadata": false }, { - "$id": "220", + "$id": "224", "kind": "property", "name": "optionalLiteralBool", "serializedName": "optionalLiteralBool", @@ -2169,13 +2201,13 @@ "isHttpMetadata": false }, { - "$id": "221", + "$id": "225", "kind": "property", "name": "requiredBadDescription", "serializedName": "requiredBadDescription", "doc": "description with xml <|endoftext|>", "type": { - "$id": "222", + "$id": "226", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -2195,20 +2227,20 @@ "isHttpMetadata": false }, { - "$id": "223", + "$id": "227", "kind": "property", "name": "optionalNullableList", "serializedName": "optionalNullableList", "doc": "optional nullable collection", "type": { - "$id": "224", + "$id": "228", "kind": "nullable", "type": { - "$id": "225", + "$id": "229", "kind": "array", "name": "Array1", "valueType": { - "$id": "226", + "$id": "230", "kind": "int32", "name": "int32", "crossLanguageDefinitionId": "TypeSpec.int32", @@ -2233,16 +2265,16 @@ "isHttpMetadata": false }, { - "$id": "227", + "$id": "231", "kind": "property", "name": "requiredNullableList", "serializedName": "requiredNullableList", "doc": "required nullable collection", "type": { - "$id": "228", + "$id": "232", "kind": "nullable", "type": { - "$ref": "225" + "$ref": "229" }, "namespace": "SampleTypeSpec" }, @@ -2260,13 +2292,13 @@ "isHttpMetadata": false }, { - "$id": "229", + "$id": "233", "kind": "property", "name": "propertyWithSpecialDocs", "serializedName": "propertyWithSpecialDocs", "doc": "This tests:\n- Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines.\n- Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple lines in the generated documentation.\n- Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output.\n- Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases.\n- **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold formatting is maintained across wrapped lines.\n- *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic formatting is correctly applied even when the text spans multiple lines.", "type": { - "$id": "230", + "$id": "234", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -2288,7 +2320,7 @@ ] }, { - "$id": "231", + "$id": "235", "kind": "model", "name": "RoundTripModel", "namespace": "SampleTypeSpec", @@ -2303,13 +2335,13 @@ }, "properties": [ { - "$id": "232", + "$id": "236", "kind": "property", "name": "requiredString", "serializedName": "requiredString", "doc": "Required string, illustrating a reference type property.", "type": { - "$id": "233", + "$id": "237", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -2329,13 +2361,13 @@ "isHttpMetadata": false }, { - "$id": "234", + "$id": "238", "kind": "property", "name": "requiredInt", "serializedName": "requiredInt", "doc": "Required int, illustrating a value type property.", "type": { - "$id": "235", + "$id": "239", "kind": "int32", "name": "int32", "encode": "string", @@ -2356,13 +2388,13 @@ "isHttpMetadata": false }, { - "$id": "236", + "$id": "240", "kind": "property", "name": "requiredCollection", "serializedName": "requiredCollection", "doc": "Required collection of enums", "type": { - "$id": "237", + "$id": "241", "kind": "array", "name": "ArrayStringFixedEnum", "valueType": { @@ -2385,16 +2417,16 @@ "isHttpMetadata": false }, { - "$id": "238", + "$id": "242", "kind": "property", "name": "requiredDictionary", "serializedName": "requiredDictionary", "doc": "Required dictionary of enums", "type": { - "$id": "239", + "$id": "243", "kind": "dict", "keyType": { - "$id": "240", + "$id": "244", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -2419,13 +2451,13 @@ "isHttpMetadata": false }, { - "$id": "241", + "$id": "245", "kind": "property", "name": "requiredModel", "serializedName": "requiredModel", "doc": "Required model", "type": { - "$ref": "196" + "$ref": "200" }, "optional": false, "readOnly": false, @@ -2441,7 +2473,7 @@ "isHttpMetadata": false }, { - "$id": "242", + "$id": "246", "kind": "property", "name": "intExtensibleEnum", "serializedName": "intExtensibleEnum", @@ -2463,13 +2495,13 @@ "isHttpMetadata": false }, { - "$id": "243", + "$id": "247", "kind": "property", "name": "intExtensibleEnumCollection", "serializedName": "intExtensibleEnumCollection", "doc": "this is a collection of int based extensible enum", "type": { - "$id": "244", + "$id": "248", "kind": "array", "name": "ArrayIntExtensibleEnum", "valueType": { @@ -2492,7 +2524,7 @@ "isHttpMetadata": false }, { - "$id": "245", + "$id": "249", "kind": "property", "name": "floatExtensibleEnum", "serializedName": "floatExtensibleEnum", @@ -2514,7 +2546,7 @@ "isHttpMetadata": false }, { - "$id": "246", + "$id": "250", "kind": "property", "name": "floatExtensibleEnumWithIntValue", "serializedName": "floatExtensibleEnumWithIntValue", @@ -2536,13 +2568,13 @@ "isHttpMetadata": false }, { - "$id": "247", + "$id": "251", "kind": "property", "name": "floatExtensibleEnumCollection", "serializedName": "floatExtensibleEnumCollection", "doc": "this is a collection of float based extensible enum", "type": { - "$id": "248", + "$id": "252", "kind": "array", "name": "ArrayFloatExtensibleEnum", "valueType": { @@ -2565,7 +2597,7 @@ "isHttpMetadata": false }, { - "$id": "249", + "$id": "253", "kind": "property", "name": "floatFixedEnum", "serializedName": "floatFixedEnum", @@ -2587,7 +2619,7 @@ "isHttpMetadata": false }, { - "$id": "250", + "$id": "254", "kind": "property", "name": "floatFixedEnumWithIntValue", "serializedName": "floatFixedEnumWithIntValue", @@ -2609,13 +2641,13 @@ "isHttpMetadata": false }, { - "$id": "251", + "$id": "255", "kind": "property", "name": "floatFixedEnumCollection", "serializedName": "floatFixedEnumCollection", "doc": "this is a collection of float based fixed enum", "type": { - "$id": "252", + "$id": "256", "kind": "array", "name": "ArrayFloatFixedEnum", "valueType": { @@ -2638,7 +2670,7 @@ "isHttpMetadata": false }, { - "$id": "253", + "$id": "257", "kind": "property", "name": "intFixedEnum", "serializedName": "intFixedEnum", @@ -2660,13 +2692,13 @@ "isHttpMetadata": false }, { - "$id": "254", + "$id": "258", "kind": "property", "name": "intFixedEnumCollection", "serializedName": "intFixedEnumCollection", "doc": "this is a collection of int based fixed enum", "type": { - "$id": "255", + "$id": "259", "kind": "array", "name": "ArrayIntFixedEnum", "valueType": { @@ -2689,7 +2721,7 @@ "isHttpMetadata": false }, { - "$id": "256", + "$id": "260", "kind": "property", "name": "stringFixedEnum", "serializedName": "stringFixedEnum", @@ -2711,13 +2743,13 @@ "isHttpMetadata": false }, { - "$id": "257", + "$id": "261", "kind": "property", "name": "requiredUnknown", "serializedName": "requiredUnknown", "doc": "required unknown", "type": { - "$id": "258", + "$id": "262", "kind": "unknown", "name": "unknown", "crossLanguageDefinitionId": "", @@ -2737,13 +2769,13 @@ "isHttpMetadata": false }, { - "$id": "259", + "$id": "263", "kind": "property", "name": "optionalUnknown", "serializedName": "optionalUnknown", "doc": "optional unknown", "type": { - "$id": "260", + "$id": "264", "kind": "unknown", "name": "unknown", "crossLanguageDefinitionId": "", @@ -2763,23 +2795,23 @@ "isHttpMetadata": false }, { - "$id": "261", + "$id": "265", "kind": "property", "name": "requiredRecordUnknown", "serializedName": "requiredRecordUnknown", "doc": "required record of unknown", "type": { - "$id": "262", + "$id": "266", "kind": "dict", "keyType": { - "$id": "263", + "$id": "267", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", "decorators": [] }, "valueType": { - "$id": "264", + "$id": "268", "kind": "unknown", "name": "unknown", "crossLanguageDefinitionId": "", @@ -2801,13 +2833,13 @@ "isHttpMetadata": false }, { - "$id": "265", + "$id": "269", "kind": "property", "name": "optionalRecordUnknown", "serializedName": "optionalRecordUnknown", "doc": "optional record of unknown", "type": { - "$ref": "262" + "$ref": "266" }, "optional": true, "readOnly": false, @@ -2823,13 +2855,13 @@ "isHttpMetadata": false }, { - "$id": "266", + "$id": "270", "kind": "property", "name": "readOnlyRequiredRecordUnknown", "serializedName": "readOnlyRequiredRecordUnknown", "doc": "required readonly record of unknown", "type": { - "$ref": "262" + "$ref": "266" }, "optional": false, "readOnly": true, @@ -2845,13 +2877,13 @@ "isHttpMetadata": false }, { - "$id": "267", + "$id": "271", "kind": "property", "name": "readOnlyOptionalRecordUnknown", "serializedName": "readOnlyOptionalRecordUnknown", "doc": "optional readonly record of unknown", "type": { - "$ref": "262" + "$ref": "266" }, "optional": true, "readOnly": true, @@ -2867,13 +2899,13 @@ "isHttpMetadata": false }, { - "$id": "268", + "$id": "272", "kind": "property", "name": "modelWithRequiredNullable", "serializedName": "modelWithRequiredNullable", "doc": "this is a model with required nullable properties", "type": { - "$id": "269", + "$id": "273", "kind": "model", "name": "ModelWithRequiredNullableProperties", "namespace": "SampleTypeSpec", @@ -2888,16 +2920,16 @@ }, "properties": [ { - "$id": "270", + "$id": "274", "kind": "property", "name": "requiredNullablePrimitive", "serializedName": "requiredNullablePrimitive", "doc": "required nullable primitive type", "type": { - "$id": "271", + "$id": "275", "kind": "nullable", "type": { - "$id": "272", + "$id": "276", "kind": "int32", "name": "int32", "crossLanguageDefinitionId": "TypeSpec.int32", @@ -2919,13 +2951,13 @@ "isHttpMetadata": false }, { - "$id": "273", + "$id": "277", "kind": "property", "name": "requiredExtensibleEnum", "serializedName": "requiredExtensibleEnum", "doc": "required nullable extensible enum type", "type": { - "$id": "274", + "$id": "278", "kind": "nullable", "type": { "$ref": "22" @@ -2946,13 +2978,13 @@ "isHttpMetadata": false }, { - "$id": "275", + "$id": "279", "kind": "property", "name": "requiredFixedEnum", "serializedName": "requiredFixedEnum", "doc": "required nullable fixed enum type", "type": { - "$id": "276", + "$id": "280", "kind": "nullable", "type": { "$ref": "17" @@ -2988,13 +3020,13 @@ "isHttpMetadata": false }, { - "$id": "277", + "$id": "281", "kind": "property", "name": "requiredBytes", "serializedName": "requiredBytes", "doc": "Required bytes", "type": { - "$id": "278", + "$id": "282", "kind": "bytes", "name": "bytes", "encode": "base64", @@ -3017,10 +3049,10 @@ ] }, { - "$ref": "269" + "$ref": "273" }, { - "$id": "279", + "$id": "283", "kind": "model", "name": "Friend", "namespace": "SampleTypeSpec", @@ -3035,13 +3067,13 @@ }, "properties": [ { - "$id": "280", + "$id": "284", "kind": "property", "name": "name", "serializedName": "name", "doc": "name of the NotFriend", "type": { - "$id": "281", + "$id": "285", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -3063,7 +3095,7 @@ ] }, { - "$id": "282", + "$id": "286", "kind": "model", "name": "RenamedModel", "namespace": "SampleTypeSpec", @@ -3078,13 +3110,13 @@ }, "properties": [ { - "$id": "283", + "$id": "287", "kind": "property", "name": "otherName", "serializedName": "otherName", "doc": "name of the ModelWithClientName", "type": { - "$id": "284", + "$id": "288", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -3106,7 +3138,7 @@ ] }, { - "$id": "285", + "$id": "289", "kind": "model", "name": "ReturnsAnonymousModelResponse", "namespace": "SampleTypeSpec", @@ -3121,7 +3153,7 @@ "properties": [] }, { - "$id": "286", + "$id": "290", "kind": "model", "name": "ListWithNextLinkResponse", "namespace": "SampleTypeSpec", @@ -3135,16 +3167,16 @@ }, "properties": [ { - "$id": "287", + "$id": "291", "kind": "property", "name": "things", "serializedName": "things", "type": { - "$id": "288", + "$id": "292", "kind": "array", "name": "ArrayThing", "valueType": { - "$ref": "196" + "$ref": "200" }, "crossLanguageDefinitionId": "TypeSpec.Array", "decorators": [] @@ -3163,12 +3195,12 @@ "isHttpMetadata": false }, { - "$id": "289", + "$id": "293", "kind": "property", "name": "next", "serializedName": "next", "type": { - "$id": "290", + "$id": "294", "kind": "url", "name": "url", "crossLanguageDefinitionId": "TypeSpec.url", @@ -3190,7 +3222,7 @@ ] }, { - "$id": "291", + "$id": "295", "kind": "model", "name": "ListWithStringNextLinkResponse", "namespace": "SampleTypeSpec", @@ -3204,12 +3236,12 @@ }, "properties": [ { - "$id": "292", + "$id": "296", "kind": "property", "name": "things", "serializedName": "things", "type": { - "$ref": "288" + "$ref": "292" }, "optional": false, "readOnly": false, @@ -3225,12 +3257,12 @@ "isHttpMetadata": false }, { - "$id": "293", + "$id": "297", "kind": "property", "name": "next", "serializedName": "next", "type": { - "$id": "294", + "$id": "298", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -3252,7 +3284,7 @@ ] }, { - "$id": "295", + "$id": "299", "kind": "model", "name": "ListWithContinuationTokenResponse", "namespace": "SampleTypeSpec", @@ -3266,12 +3298,12 @@ }, "properties": [ { - "$id": "296", + "$id": "300", "kind": "property", "name": "things", "serializedName": "things", "type": { - "$ref": "288" + "$ref": "292" }, "optional": false, "readOnly": false, @@ -3287,12 +3319,12 @@ "isHttpMetadata": false }, { - "$id": "297", + "$id": "301", "kind": "property", "name": "nextToken", "serializedName": "nextToken", "type": { - "$id": "298", + "$id": "302", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -3314,7 +3346,7 @@ ] }, { - "$id": "299", + "$id": "303", "kind": "model", "name": "ListWithContinuationTokenHeaderResponseResponse", "namespace": "", @@ -3328,12 +3360,12 @@ }, "properties": [ { - "$id": "300", + "$id": "304", "kind": "property", "name": "things", "serializedName": "things", "type": { - "$ref": "288" + "$ref": "292" }, "optional": false, "readOnly": false, @@ -3351,7 +3383,7 @@ ] }, { - "$id": "301", + "$id": "305", "kind": "model", "name": "PageThing", "namespace": "SampleTypeSpec", @@ -3365,12 +3397,12 @@ }, "properties": [ { - "$id": "302", + "$id": "306", "kind": "property", "name": "items", "serializedName": "items", "type": { - "$ref": "288" + "$ref": "292" }, "optional": false, "readOnly": false, @@ -3388,7 +3420,7 @@ ] }, { - "$id": "303", + "$id": "307", "kind": "model", "name": "ModelWithEmbeddedNonBodyParameters", "namespace": "SampleTypeSpec", @@ -3402,13 +3434,13 @@ }, "properties": [ { - "$id": "304", + "$id": "308", "kind": "property", "name": "name", "serializedName": "name", "doc": "name of the ModelWithEmbeddedNonBodyParameters", "type": { - "$id": "305", + "$id": "309", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -3428,13 +3460,13 @@ "isHttpMetadata": false }, { - "$id": "306", + "$id": "310", "kind": "property", "name": "requiredHeader", "serializedName": "requiredHeader", "doc": "required header parameter", "type": { - "$id": "307", + "$id": "311", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -3454,13 +3486,13 @@ "isHttpMetadata": true }, { - "$id": "308", + "$id": "312", "kind": "property", "name": "optionalHeader", "serializedName": "optionalHeader", "doc": "optional header parameter", "type": { - "$id": "309", + "$id": "313", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -3480,13 +3512,13 @@ "isHttpMetadata": true }, { - "$id": "310", + "$id": "314", "kind": "property", "name": "requiredQuery", "serializedName": "requiredQuery", "doc": "required query parameter", "type": { - "$id": "311", + "$id": "315", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -3506,13 +3538,13 @@ "isHttpMetadata": true }, { - "$id": "312", + "$id": "316", "kind": "property", "name": "optionalQuery", "serializedName": "optionalQuery", "doc": "optional query parameter", "type": { - "$id": "313", + "$id": "317", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -3534,7 +3566,7 @@ ] }, { - "$id": "314", + "$id": "318", "kind": "model", "name": "DynamicModel", "namespace": "SampleTypeSpec", @@ -3554,12 +3586,12 @@ }, "properties": [ { - "$id": "315", + "$id": "319", "kind": "property", "name": "name", "serializedName": "name", "type": { - "$id": "316", + "$id": "320", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -3579,12 +3611,12 @@ "isHttpMetadata": false }, { - "$id": "317", + "$id": "321", "kind": "property", "name": "optionalUnknown", "serializedName": "optionalUnknown", "type": { - "$id": "318", + "$id": "322", "kind": "unknown", "name": "unknown", "crossLanguageDefinitionId": "", @@ -3604,12 +3636,12 @@ "isHttpMetadata": false }, { - "$id": "319", + "$id": "323", "kind": "property", "name": "optionalInt", "serializedName": "optionalInt", "type": { - "$id": "320", + "$id": "324", "kind": "int32", "name": "int32", "crossLanguageDefinitionId": "TypeSpec.int32", @@ -3629,15 +3661,15 @@ "isHttpMetadata": false }, { - "$id": "321", + "$id": "325", "kind": "property", "name": "optionalNullableList", "serializedName": "optionalNullableList", "type": { - "$id": "322", + "$id": "326", "kind": "nullable", "type": { - "$ref": "225" + "$ref": "229" }, "namespace": "SampleTypeSpec" }, @@ -3655,15 +3687,15 @@ "isHttpMetadata": false }, { - "$id": "323", + "$id": "327", "kind": "property", "name": "requiredNullableList", "serializedName": "requiredNullableList", "type": { - "$id": "324", + "$id": "328", "kind": "nullable", "type": { - "$ref": "225" + "$ref": "229" }, "namespace": "SampleTypeSpec" }, @@ -3681,25 +3713,25 @@ "isHttpMetadata": false }, { - "$id": "325", + "$id": "329", "kind": "property", "name": "optionalNullableDictionary", "serializedName": "optionalNullableDictionary", "type": { - "$id": "326", + "$id": "330", "kind": "nullable", "type": { - "$id": "327", + "$id": "331", "kind": "dict", "keyType": { - "$id": "328", + "$id": "332", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", "decorators": [] }, "valueType": { - "$id": "329", + "$id": "333", "kind": "int32", "name": "int32", "crossLanguageDefinitionId": "TypeSpec.int32", @@ -3723,15 +3755,15 @@ "isHttpMetadata": false }, { - "$id": "330", + "$id": "334", "kind": "property", "name": "requiredNullableDictionary", "serializedName": "requiredNullableDictionary", "type": { - "$id": "331", + "$id": "335", "kind": "nullable", "type": { - "$ref": "327" + "$ref": "331" }, "namespace": "SampleTypeSpec" }, @@ -3749,12 +3781,12 @@ "isHttpMetadata": false }, { - "$id": "332", + "$id": "336", "kind": "property", "name": "primitiveDictionary", "serializedName": "primitiveDictionary", "type": { - "$ref": "327" + "$ref": "331" }, "optional": false, "readOnly": false, @@ -3770,12 +3802,12 @@ "isHttpMetadata": false }, { - "$id": "333", + "$id": "337", "kind": "property", "name": "foo", "serializedName": "foo", "type": { - "$id": "334", + "$id": "338", "kind": "model", "name": "AnotherDynamicModel", "namespace": "SampleTypeSpec", @@ -3795,12 +3827,12 @@ }, "properties": [ { - "$id": "335", + "$id": "339", "kind": "property", "name": "bar", "serializedName": "bar", "type": { - "$id": "336", + "$id": "340", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -3835,16 +3867,16 @@ "isHttpMetadata": false }, { - "$id": "337", + "$id": "341", "kind": "property", "name": "listFoo", "serializedName": "listFoo", "type": { - "$id": "338", + "$id": "342", "kind": "array", "name": "ArrayAnotherDynamicModel", "valueType": { - "$ref": "334" + "$ref": "338" }, "crossLanguageDefinitionId": "TypeSpec.Array", "decorators": [] @@ -3863,16 +3895,16 @@ "isHttpMetadata": false }, { - "$id": "339", + "$id": "343", "kind": "property", "name": "listOfListFoo", "serializedName": "listOfListFoo", "type": { - "$id": "340", + "$id": "344", "kind": "array", "name": "ArrayArray", "valueType": { - "$ref": "338" + "$ref": "342" }, "crossLanguageDefinitionId": "TypeSpec.Array", "decorators": [] @@ -3891,22 +3923,22 @@ "isHttpMetadata": false }, { - "$id": "341", + "$id": "345", "kind": "property", "name": "dictionaryFoo", "serializedName": "dictionaryFoo", "type": { - "$id": "342", + "$id": "346", "kind": "dict", "keyType": { - "$id": "343", + "$id": "347", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", "decorators": [] }, "valueType": { - "$ref": "334" + "$ref": "338" }, "decorators": [] }, @@ -3924,22 +3956,22 @@ "isHttpMetadata": false }, { - "$id": "344", + "$id": "348", "kind": "property", "name": "dictionaryOfDictionaryFoo", "serializedName": "dictionaryOfDictionaryFoo", "type": { - "$id": "345", + "$id": "349", "kind": "dict", "keyType": { - "$id": "346", + "$id": "350", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", "decorators": [] }, "valueType": { - "$ref": "342" + "$ref": "346" }, "decorators": [] }, @@ -3957,22 +3989,22 @@ "isHttpMetadata": false }, { - "$id": "347", + "$id": "351", "kind": "property", "name": "dictionaryListFoo", "serializedName": "dictionaryListFoo", "type": { - "$id": "348", + "$id": "352", "kind": "dict", "keyType": { - "$id": "349", + "$id": "353", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", "decorators": [] }, "valueType": { - "$ref": "338" + "$ref": "342" }, "decorators": [] }, @@ -3990,16 +4022,16 @@ "isHttpMetadata": false }, { - "$id": "350", + "$id": "354", "kind": "property", "name": "listOfDictionaryFoo", "serializedName": "listOfDictionaryFoo", "type": { - "$id": "351", + "$id": "355", "kind": "array", "name": "ArrayRecord", "valueType": { - "$ref": "342" + "$ref": "346" }, "crossLanguageDefinitionId": "TypeSpec.Array", "decorators": [] @@ -4009,10 +4041,978 @@ "discriminator": false, "flatten": false, "decorators": [], - "crossLanguageDefinitionId": "SampleTypeSpec.DynamicModel.listOfDictionaryFoo", + "crossLanguageDefinitionId": "SampleTypeSpec.DynamicModel.listOfDictionaryFoo", + "serializationOptions": { + "json": { + "name": "listOfDictionaryFoo" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$ref": "338" + }, + { + "$id": "356", + "kind": "model", + "name": "XmlAdvancedModel", + "namespace": "SampleTypeSpec", + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel", + "usage": "Output,Xml", + "doc": "An advanced XML model for testing various property types and XML features.", + "decorators": [ + { + "name": "TypeSpec.Xml.@name", + "arguments": { + "name": "AdvancedXmlModel" + } + } + ], + "serializationOptions": { + "xml": { + "name": "AdvancedXmlModel", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "357", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "A simple string property", + "type": { + "$id": "358", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.name", + "serializationOptions": { + "xml": { + "name": "name", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "359", + "kind": "property", + "name": "age", + "serializedName": "age", + "doc": "An integer property", + "type": { + "$id": "360", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.age", + "serializationOptions": { + "xml": { + "name": "age", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "361", + "kind": "property", + "name": "enabled", + "serializedName": "enabled", + "doc": "A boolean property", + "type": { + "$id": "362", + "kind": "boolean", + "name": "boolean", + "crossLanguageDefinitionId": "TypeSpec.boolean", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.enabled", + "serializationOptions": { + "xml": { + "name": "enabled", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "363", + "kind": "property", + "name": "score", + "serializedName": "score", + "doc": "A float property", + "type": { + "$id": "364", + "kind": "float32", + "name": "float32", + "crossLanguageDefinitionId": "TypeSpec.float32", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.score", + "serializationOptions": { + "xml": { + "name": "score", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "365", + "kind": "property", + "name": "optionalString", + "serializedName": "optionalString", + "doc": "An optional string", + "type": { + "$id": "366", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.optionalString", + "serializationOptions": { + "xml": { + "name": "optionalString", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "367", + "kind": "property", + "name": "optionalInt", + "serializedName": "optionalInt", + "doc": "An optional integer", + "type": { + "$id": "368", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.optionalInt", + "serializationOptions": { + "xml": { + "name": "optionalInt", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "369", + "kind": "property", + "name": "nullableString", + "serializedName": "nullableString", + "doc": "A nullable string", + "type": { + "$id": "370", + "kind": "nullable", + "type": { + "$id": "371", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "namespace": "SampleTypeSpec" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.nullableString", + "serializationOptions": { + "xml": { + "name": "nullableString", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "372", + "kind": "property", + "name": "id", + "serializedName": "id", + "doc": "A string as XML attribute", + "type": { + "$id": "373", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@attribute", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.id", + "serializationOptions": { + "xml": { + "name": "id", + "attribute": true, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "374", + "kind": "property", + "name": "version", + "serializedName": "version", + "doc": "An integer as XML attribute", + "type": { + "$id": "375", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@attribute", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.version", + "serializationOptions": { + "xml": { + "name": "version", + "attribute": true, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "376", + "kind": "property", + "name": "isActive", + "serializedName": "isActive", + "doc": "A boolean as XML attribute", + "type": { + "$id": "377", + "kind": "boolean", + "name": "boolean", + "crossLanguageDefinitionId": "TypeSpec.boolean", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@attribute", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.isActive", + "serializationOptions": { + "xml": { + "name": "isActive", + "attribute": true, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "378", + "kind": "property", + "name": "originalName", + "serializedName": "RenamedProperty", + "doc": "A property with a custom XML element name", + "type": { + "$id": "379", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@name", + "arguments": { + "name": "RenamedProperty" + } + } + ], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.originalName", + "serializationOptions": { + "xml": { + "name": "RenamedProperty", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "380", + "kind": "property", + "name": "xmlIdentifier", + "serializedName": "xml-id", + "doc": "An attribute with a custom XML name", + "type": { + "$id": "381", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@name", + "arguments": { + "name": "xml-id" + } + }, + { + "name": "TypeSpec.Xml.@attribute", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.xmlIdentifier", + "serializationOptions": { + "xml": { + "name": "xml-id", + "attribute": true, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "382", + "kind": "property", + "name": "content", + "serializedName": "content", + "doc": "Text content in the element (unwrapped string)", + "type": { + "$id": "383", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@unwrapped", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.content", + "serializationOptions": { + "xml": { + "name": "content", + "attribute": false, + "unwrapped": true + } + }, + "isHttpMetadata": false + }, + { + "$id": "384", + "kind": "property", + "name": "unwrappedStrings", + "serializedName": "unwrappedStrings", + "doc": "An unwrapped array of strings - items appear directly without wrapper", + "type": { + "$ref": "206" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@unwrapped", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.unwrappedStrings", + "serializationOptions": { + "xml": { + "name": "unwrappedStrings", + "attribute": false, + "unwrapped": true, + "itemsName": "unwrappedStrings" + } + }, + "isHttpMetadata": false + }, + { + "$id": "385", + "kind": "property", + "name": "unwrappedCounts", + "serializedName": "unwrappedCounts", + "doc": "An unwrapped array of integers", + "type": { + "$ref": "229" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@unwrapped", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.unwrappedCounts", + "serializationOptions": { + "xml": { + "name": "unwrappedCounts", + "attribute": false, + "unwrapped": true, + "itemsName": "unwrappedCounts" + } + }, + "isHttpMetadata": false + }, + { + "$id": "386", + "kind": "property", + "name": "unwrappedItems", + "serializedName": "unwrappedItems", + "doc": "An unwrapped array of models", + "type": { + "$id": "387", + "kind": "array", + "name": "ArrayXmlItem", + "valueType": { + "$id": "388", + "kind": "model", + "name": "XmlItem", + "namespace": "SampleTypeSpec", + "crossLanguageDefinitionId": "SampleTypeSpec.XmlItem", + "usage": "Output,Xml", + "doc": "An item model for XML array testing", + "decorators": [ + { + "name": "TypeSpec.Xml.@name", + "arguments": { + "name": "Item" + } + } + ], + "serializationOptions": { + "xml": { + "name": "Item", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "389", + "kind": "property", + "name": "itemName", + "serializedName": "itemName", + "doc": "The item name", + "type": { + "$id": "390", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlItem.itemName", + "serializationOptions": { + "xml": { + "name": "itemName", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "391", + "kind": "property", + "name": "itemValue", + "serializedName": "itemValue", + "doc": "The item value", + "type": { + "$id": "392", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlItem.itemValue", + "serializationOptions": { + "xml": { + "name": "itemValue", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "393", + "kind": "property", + "name": "itemId", + "serializedName": "itemId", + "doc": "Item ID as attribute", + "type": { + "$id": "394", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@attribute", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlItem.itemId", + "serializationOptions": { + "xml": { + "name": "itemId", + "attribute": true, + "unwrapped": false + } + }, + "isHttpMetadata": false + } + ] + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@unwrapped", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.unwrappedItems", + "serializationOptions": { + "xml": { + "name": "unwrappedItems", + "attribute": false, + "unwrapped": true, + "itemsName": "unwrappedItems" + } + }, + "isHttpMetadata": false + }, + { + "$id": "395", + "kind": "property", + "name": "wrappedColors", + "serializedName": "wrappedColors", + "doc": "A wrapped array of strings (default)", + "type": { + "$ref": "206" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.wrappedColors", + "serializationOptions": { + "xml": { + "name": "wrappedColors", + "attribute": false, + "unwrapped": false, + "itemsName": "string" + } + }, + "isHttpMetadata": false + }, + { + "$id": "396", + "kind": "property", + "name": "items", + "serializedName": "ItemCollection", + "doc": "A wrapped array with custom wrapper name", + "type": { + "$ref": "387" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@name", + "arguments": { + "name": "ItemCollection" + } + } + ], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.items", + "serializationOptions": { + "xml": { + "name": "ItemCollection", + "attribute": false, + "unwrapped": false, + "itemsName": "Item" + } + }, + "isHttpMetadata": false + }, + { + "$id": "397", + "kind": "property", + "name": "nestedModel", + "serializedName": "nestedModel", + "doc": "A nested model property", + "type": { + "$id": "398", + "kind": "model", + "name": "XmlNestedModel", + "namespace": "SampleTypeSpec", + "crossLanguageDefinitionId": "SampleTypeSpec.XmlNestedModel", + "usage": "Output,Xml", + "doc": "A nested model for XML testing", + "decorators": [], + "serializationOptions": { + "xml": { + "name": "XmlNestedModel", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "399", + "kind": "property", + "name": "value", + "serializedName": "value", + "doc": "The value of the nested model", + "type": { + "$id": "400", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlNestedModel.value", + "serializationOptions": { + "xml": { + "name": "value", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "401", + "kind": "property", + "name": "nestedId", + "serializedName": "nestedId", + "doc": "An attribute on the nested model", + "type": { + "$id": "402", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@attribute", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlNestedModel.nestedId", + "serializationOptions": { + "xml": { + "name": "nestedId", + "attribute": true, + "unwrapped": false + } + }, + "isHttpMetadata": false + } + ] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.nestedModel", + "serializationOptions": { + "xml": { + "name": "nestedModel", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "403", + "kind": "property", + "name": "optionalNestedModel", + "serializedName": "optionalNestedModel", + "doc": "An optional nested model", + "type": { + "$ref": "398" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.optionalNestedModel", + "serializationOptions": { + "xml": { + "name": "optionalNestedModel", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "404", + "kind": "property", + "name": "metadata", + "serializedName": "metadata", + "doc": "A dictionary property", + "type": { + "$id": "405", + "kind": "dict", + "keyType": { + "$id": "406", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "valueType": { + "$id": "407", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.metadata", + "serializationOptions": { + "xml": { + "name": "metadata", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "408", + "kind": "property", + "name": "createdAt", + "serializedName": "createdAt", + "doc": "A date-time property", + "type": { + "$id": "409", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "410", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.createdAt", + "serializationOptions": { + "xml": { + "name": "createdAt", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "411", + "kind": "property", + "name": "duration", + "serializedName": "duration", + "doc": "A duration property", + "type": { + "$id": "412", + "kind": "duration", + "name": "duration", + "encode": "ISO8601", + "wireType": { + "$id": "413", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.duration", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.duration", + "serializationOptions": { + "xml": { + "name": "duration", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "414", + "kind": "property", + "name": "data", + "serializedName": "data", + "doc": "A bytes property", + "type": { + "$id": "415", + "kind": "bytes", + "name": "bytes", + "encode": "base64", + "crossLanguageDefinitionId": "TypeSpec.bytes", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.XmlAdvancedModel.data", "serializationOptions": { - "json": { - "name": "listOfDictionaryFoo" + "xml": { + "name": "data", + "attribute": false, + "unwrapped": false } }, "isHttpMetadata": false @@ -4020,10 +5020,13 @@ ] }, { - "$ref": "334" + "$ref": "388" + }, + { + "$ref": "398" }, { - "$id": "352", + "$id": "416", "kind": "model", "name": "Animal", "namespace": "SampleTypeSpec", @@ -4037,13 +5040,13 @@ } }, "discriminatorProperty": { - "$id": "353", + "$id": "417", "kind": "property", "name": "kind", "serializedName": "kind", "doc": "The kind of animal", "type": { - "$id": "354", + "$id": "418", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4064,16 +5067,16 @@ }, "properties": [ { - "$ref": "353" + "$ref": "417" }, { - "$id": "355", + "$id": "419", "kind": "property", "name": "name", "serializedName": "name", "doc": "Name of the animal", "type": { - "$id": "356", + "$id": "420", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4095,7 +5098,7 @@ ], "discriminatedSubtypes": { "pet": { - "$id": "357", + "$id": "421", "kind": "model", "name": "Pet", "namespace": "SampleTypeSpec", @@ -4110,7 +5113,7 @@ } }, "discriminatorProperty": { - "$id": "358", + "$id": "422", "kind": "property", "name": "kind", "serializedName": "kind", @@ -4131,20 +5134,20 @@ "isHttpMetadata": false }, "baseModel": { - "$ref": "352" + "$ref": "416" }, "properties": [ { - "$ref": "358" + "$ref": "422" }, { - "$id": "359", + "$id": "423", "kind": "property", "name": "trained", "serializedName": "trained", "doc": "Whether the pet is trained", "type": { - "$id": "360", + "$id": "424", "kind": "boolean", "name": "boolean", "crossLanguageDefinitionId": "TypeSpec.boolean", @@ -4166,7 +5169,7 @@ ], "discriminatedSubtypes": { "dog": { - "$id": "361", + "$id": "425", "kind": "model", "name": "Dog", "namespace": "SampleTypeSpec", @@ -4181,11 +5184,11 @@ } }, "baseModel": { - "$ref": "357" + "$ref": "421" }, "properties": [ { - "$id": "362", + "$id": "426", "kind": "property", "name": "kind", "serializedName": "kind", @@ -4206,13 +5209,13 @@ "isHttpMetadata": false }, { - "$id": "363", + "$id": "427", "kind": "property", "name": "breed", "serializedName": "breed", "doc": "The breed of the dog", "type": { - "$id": "364", + "$id": "428", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4236,18 +5239,18 @@ } }, "dog": { - "$ref": "361" + "$ref": "425" } } }, { - "$ref": "357" + "$ref": "421" }, { - "$ref": "361" + "$ref": "425" }, { - "$id": "365", + "$id": "429", "kind": "model", "name": "GetWidgetMetricsResponse", "namespace": "SampleTypeSpec", @@ -4261,12 +5264,12 @@ }, "properties": [ { - "$id": "366", + "$id": "430", "kind": "property", "name": "numSold", "serializedName": "numSold", "type": { - "$id": "367", + "$id": "431", "kind": "int32", "name": "int32", "crossLanguageDefinitionId": "TypeSpec.int32", @@ -4286,12 +5289,12 @@ "isHttpMetadata": false }, { - "$id": "368", + "$id": "432", "kind": "property", "name": "averagePrice", "serializedName": "averagePrice", "type": { - "$id": "369", + "$id": "433", "kind": "float32", "name": "float32", "crossLanguageDefinitionId": "TypeSpec.float32", @@ -4315,14 +5318,14 @@ ], "clients": [ { - "$id": "370", + "$id": "434", "kind": "client", "name": "SampleTypeSpecClient", "namespace": "SampleTypeSpec", "doc": "This is a sample typespec project.", "methods": [ { - "$id": "371", + "$id": "435", "kind": "basic", "name": "sayHi", "accessibility": "public", @@ -4332,19 +5335,19 @@ ], "doc": "Return hi", "operation": { - "$id": "372", + "$id": "436", "name": "sayHi", "resourceName": "SampleTypeSpec", "doc": "Return hi", "accessibility": "public", "parameters": [ { - "$id": "373", + "$id": "437", "kind": "header", "name": "headParameter", "serializedName": "head-parameter", "type": { - "$id": "374", + "$id": "438", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4359,12 +5362,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.sayHi.headParameter" }, { - "$id": "375", + "$id": "439", "kind": "query", "name": "queryParameter", "serializedName": "queryParameter", "type": { - "$id": "376", + "$id": "440", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4379,12 +5382,12 @@ "readOnly": false }, { - "$id": "377", + "$id": "441", "kind": "query", "name": "optionalQuery", "serializedName": "optionalQuery", "type": { - "$id": "378", + "$id": "442", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4399,7 +5402,7 @@ "readOnly": false }, { - "$id": "379", + "$id": "443", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -4421,7 +5424,7 @@ 200 ], "bodyType": { - "$ref": "196" + "$ref": "200" }, "headers": [], "isErrorResponse": false, @@ -4442,12 +5445,12 @@ }, "parameters": [ { - "$id": "380", + "$id": "444", "kind": "method", "name": "headParameter", "serializedName": "head-parameter", "type": { - "$id": "381", + "$id": "445", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4463,12 +5466,12 @@ "decorators": [] }, { - "$id": "382", + "$id": "446", "kind": "method", "name": "queryParameter", "serializedName": "queryParameter", "type": { - "$id": "383", + "$id": "447", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4484,12 +5487,12 @@ "decorators": [] }, { - "$id": "384", + "$id": "448", "kind": "method", "name": "optionalQuery", "serializedName": "optionalQuery", "type": { - "$id": "385", + "$id": "449", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4505,7 +5508,7 @@ "decorators": [] }, { - "$id": "386", + "$id": "450", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -4524,7 +5527,7 @@ ], "response": { "type": { - "$ref": "196" + "$ref": "200" } }, "isOverride": false, @@ -4533,7 +5536,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.sayHi" }, { - "$id": "387", + "$id": "451", "kind": "basic", "name": "helloAgain", "accessibility": "public", @@ -4543,19 +5546,19 @@ ], "doc": "Return hi again", "operation": { - "$id": "388", + "$id": "452", "name": "helloAgain", "resourceName": "SampleTypeSpec", "doc": "Return hi again", "accessibility": "public", "parameters": [ { - "$id": "389", + "$id": "453", "kind": "header", "name": "p1", "serializedName": "p1", "type": { - "$id": "390", + "$id": "454", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4570,7 +5573,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.helloAgain.p1" }, { - "$id": "391", + "$id": "455", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -4586,12 +5589,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.helloAgain.contentType" }, { - "$id": "392", + "$id": "456", "kind": "path", "name": "p2", "serializedName": "p2", "type": { - "$id": "393", + "$id": "457", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4609,7 +5612,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.helloAgain.p2" }, { - "$id": "394", + "$id": "458", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -4625,12 +5628,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.helloAgain.accept" }, { - "$id": "395", + "$id": "459", "kind": "body", "name": "action", "serializedName": "action", "type": { - "$ref": "231" + "$ref": "235" }, "isApiVersion": false, "contentTypes": [ @@ -4650,7 +5653,7 @@ 200 ], "bodyType": { - "$ref": "231" + "$ref": "235" }, "headers": [], "isErrorResponse": false, @@ -4674,12 +5677,12 @@ }, "parameters": [ { - "$id": "396", + "$id": "460", "kind": "method", "name": "p1", "serializedName": "p1", "type": { - "$id": "397", + "$id": "461", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4695,12 +5698,12 @@ "decorators": [] }, { - "$id": "398", + "$id": "462", "kind": "method", "name": "action", "serializedName": "action", "type": { - "$ref": "231" + "$ref": "235" }, "location": "Body", "isApiVersion": false, @@ -4712,7 +5715,7 @@ "decorators": [] }, { - "$id": "399", + "$id": "463", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -4729,12 +5732,12 @@ "decorators": [] }, { - "$id": "400", + "$id": "464", "kind": "method", "name": "p2", "serializedName": "p2", "type": { - "$id": "401", + "$id": "465", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4750,7 +5753,7 @@ "decorators": [] }, { - "$id": "402", + "$id": "466", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -4769,7 +5772,7 @@ ], "response": { "type": { - "$ref": "231" + "$ref": "235" } }, "isOverride": false, @@ -4778,7 +5781,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.helloAgain" }, { - "$id": "403", + "$id": "467", "kind": "basic", "name": "noContentType", "accessibility": "public", @@ -4788,19 +5791,19 @@ ], "doc": "Return hi again", "operation": { - "$id": "404", + "$id": "468", "name": "noContentType", "resourceName": "SampleTypeSpec", "doc": "Return hi again", "accessibility": "public", "parameters": [ { - "$id": "405", + "$id": "469", "kind": "header", "name": "p1", "serializedName": "p1", "type": { - "$id": "406", + "$id": "470", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4815,12 +5818,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.noContentType.p1" }, { - "$id": "407", + "$id": "471", "kind": "path", "name": "p2", "serializedName": "p2", "type": { - "$id": "408", + "$id": "472", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4838,7 +5841,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.noContentType.p2" }, { - "$id": "409", + "$id": "473", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -4855,7 +5858,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.noContentType.contentType" }, { - "$id": "410", + "$id": "474", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -4871,12 +5874,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.noContentType.accept" }, { - "$id": "411", + "$id": "475", "kind": "body", "name": "action", "serializedName": "action", "type": { - "$ref": "231" + "$ref": "235" }, "isApiVersion": false, "contentTypes": [ @@ -4896,7 +5899,7 @@ 200 ], "bodyType": { - "$ref": "231" + "$ref": "235" }, "headers": [], "isErrorResponse": false, @@ -4920,12 +5923,12 @@ }, "parameters": [ { - "$id": "412", + "$id": "476", "kind": "method", "name": "p1", "serializedName": "p1", "type": { - "$id": "413", + "$id": "477", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4941,12 +5944,12 @@ "decorators": [] }, { - "$id": "414", + "$id": "478", "kind": "method", "name": "action", "serializedName": "action", "type": { - "$ref": "231" + "$ref": "235" }, "location": "Body", "isApiVersion": false, @@ -4958,12 +5961,12 @@ "decorators": [] }, { - "$id": "415", + "$id": "479", "kind": "method", "name": "p2", "serializedName": "p2", "type": { - "$id": "416", + "$id": "480", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -4979,7 +5982,7 @@ "decorators": [] }, { - "$id": "417", + "$id": "481", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -4997,7 +6000,7 @@ "decorators": [] }, { - "$id": "418", + "$id": "482", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -5016,7 +6019,7 @@ ], "response": { "type": { - "$ref": "231" + "$ref": "235" } }, "isOverride": false, @@ -5025,7 +6028,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.noContentType" }, { - "$id": "419", + "$id": "483", "kind": "basic", "name": "helloDemo2", "accessibility": "public", @@ -5035,14 +6038,14 @@ ], "doc": "Return hi in demo2", "operation": { - "$id": "420", + "$id": "484", "name": "helloDemo2", "resourceName": "SampleTypeSpec", "doc": "Return hi in demo2", "accessibility": "public", "parameters": [ { - "$id": "421", + "$id": "485", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -5064,7 +6067,7 @@ 200 ], "bodyType": { - "$ref": "196" + "$ref": "200" }, "headers": [], "isErrorResponse": false, @@ -5085,7 +6088,7 @@ }, "parameters": [ { - "$id": "422", + "$id": "486", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -5104,7 +6107,7 @@ ], "response": { "type": { - "$ref": "196" + "$ref": "200" } }, "isOverride": false, @@ -5113,7 +6116,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.helloDemo2" }, { - "$id": "423", + "$id": "487", "kind": "basic", "name": "createLiteral", "accessibility": "public", @@ -5123,14 +6126,14 @@ ], "doc": "Create with literal value", "operation": { - "$id": "424", + "$id": "488", "name": "createLiteral", "resourceName": "SampleTypeSpec", "doc": "Create with literal value", "accessibility": "public", "parameters": [ { - "$id": "425", + "$id": "489", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -5147,7 +6150,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.createLiteral.contentType" }, { - "$id": "426", + "$id": "490", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -5163,12 +6166,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.createLiteral.accept" }, { - "$id": "427", + "$id": "491", "kind": "body", "name": "body", "serializedName": "body", "type": { - "$ref": "196" + "$ref": "200" }, "isApiVersion": false, "contentTypes": [ @@ -5188,7 +6191,7 @@ 200 ], "bodyType": { - "$ref": "196" + "$ref": "200" }, "headers": [], "isErrorResponse": false, @@ -5212,12 +6215,12 @@ }, "parameters": [ { - "$id": "428", + "$id": "492", "kind": "method", "name": "body", "serializedName": "body", "type": { - "$ref": "196" + "$ref": "200" }, "location": "Body", "isApiVersion": false, @@ -5229,7 +6232,7 @@ "decorators": [] }, { - "$id": "429", + "$id": "493", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -5247,7 +6250,7 @@ "decorators": [] }, { - "$id": "430", + "$id": "494", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -5266,7 +6269,7 @@ ], "response": { "type": { - "$ref": "196" + "$ref": "200" } }, "isOverride": false, @@ -5275,7 +6278,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.createLiteral" }, { - "$id": "431", + "$id": "495", "kind": "basic", "name": "helloLiteral", "accessibility": "public", @@ -5285,14 +6288,14 @@ ], "doc": "Send literal parameters", "operation": { - "$id": "432", + "$id": "496", "name": "helloLiteral", "resourceName": "SampleTypeSpec", "doc": "Send literal parameters", "accessibility": "public", "parameters": [ { - "$id": "433", + "$id": "497", "kind": "header", "name": "p1", "serializedName": "p1", @@ -5308,7 +6311,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.helloLiteral.p1" }, { - "$id": "434", + "$id": "498", "kind": "path", "name": "p2", "serializedName": "p2", @@ -5327,7 +6330,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.helloLiteral.p2" }, { - "$id": "435", + "$id": "499", "kind": "query", "name": "p3", "serializedName": "p3", @@ -5343,7 +6346,7 @@ "readOnly": false }, { - "$id": "436", + "$id": "500", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -5365,7 +6368,7 @@ 200 ], "bodyType": { - "$ref": "196" + "$ref": "200" }, "headers": [], "isErrorResponse": false, @@ -5386,7 +6389,7 @@ }, "parameters": [ { - "$id": "437", + "$id": "501", "kind": "method", "name": "p1", "serializedName": "p1", @@ -5403,7 +6406,7 @@ "decorators": [] }, { - "$id": "438", + "$id": "502", "kind": "method", "name": "p2", "serializedName": "p2", @@ -5420,7 +6423,7 @@ "decorators": [] }, { - "$id": "439", + "$id": "503", "kind": "method", "name": "p3", "serializedName": "p3", @@ -5437,7 +6440,7 @@ "decorators": [] }, { - "$id": "440", + "$id": "504", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -5456,7 +6459,7 @@ ], "response": { "type": { - "$ref": "196" + "$ref": "200" } }, "isOverride": false, @@ -5465,7 +6468,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.helloLiteral" }, { - "$id": "441", + "$id": "505", "kind": "basic", "name": "topAction", "accessibility": "public", @@ -5475,24 +6478,24 @@ ], "doc": "top level method", "operation": { - "$id": "442", + "$id": "506", "name": "topAction", "resourceName": "SampleTypeSpec", "doc": "top level method", "accessibility": "public", "parameters": [ { - "$id": "443", + "$id": "507", "kind": "path", "name": "action", "serializedName": "action", "type": { - "$id": "444", + "$id": "508", "kind": "utcDateTime", "name": "utcDateTime", "encode": "rfc3339", "wireType": { - "$id": "445", + "$id": "509", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -5513,7 +6516,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.topAction.action" }, { - "$id": "446", + "$id": "510", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -5535,7 +6538,7 @@ 200 ], "bodyType": { - "$ref": "196" + "$ref": "200" }, "headers": [], "isErrorResponse": false, @@ -5556,17 +6559,17 @@ }, "parameters": [ { - "$id": "447", + "$id": "511", "kind": "method", "name": "action", "serializedName": "action", "type": { - "$id": "448", + "$id": "512", "kind": "utcDateTime", "name": "utcDateTime", "encode": "rfc3339", "wireType": { - "$id": "449", + "$id": "513", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -5585,7 +6588,7 @@ "decorators": [] }, { - "$id": "450", + "$id": "514", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -5604,7 +6607,7 @@ ], "response": { "type": { - "$ref": "196" + "$ref": "200" } }, "isOverride": false, @@ -5613,7 +6616,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.topAction" }, { - "$id": "451", + "$id": "515", "kind": "basic", "name": "topAction2", "accessibility": "public", @@ -5623,14 +6626,14 @@ ], "doc": "top level method2", "operation": { - "$id": "452", + "$id": "516", "name": "topAction2", "resourceName": "SampleTypeSpec", "doc": "top level method2", "accessibility": "public", "parameters": [ { - "$id": "453", + "$id": "517", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -5652,7 +6655,7 @@ 200 ], "bodyType": { - "$ref": "196" + "$ref": "200" }, "headers": [], "isErrorResponse": false, @@ -5673,7 +6676,7 @@ }, "parameters": [ { - "$id": "454", + "$id": "518", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -5692,7 +6695,7 @@ ], "response": { "type": { - "$ref": "196" + "$ref": "200" } }, "isOverride": false, @@ -5701,7 +6704,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.topAction2" }, { - "$id": "455", + "$id": "519", "kind": "basic", "name": "patchAction", "accessibility": "public", @@ -5711,14 +6714,14 @@ ], "doc": "top level patch", "operation": { - "$id": "456", + "$id": "520", "name": "patchAction", "resourceName": "SampleTypeSpec", "doc": "top level patch", "accessibility": "public", "parameters": [ { - "$id": "457", + "$id": "521", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -5735,7 +6738,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.patchAction.contentType" }, { - "$id": "458", + "$id": "522", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -5751,12 +6754,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.patchAction.accept" }, { - "$id": "459", + "$id": "523", "kind": "body", "name": "body", "serializedName": "body", "type": { - "$ref": "196" + "$ref": "200" }, "isApiVersion": false, "contentTypes": [ @@ -5776,7 +6779,7 @@ 200 ], "bodyType": { - "$ref": "196" + "$ref": "200" }, "headers": [], "isErrorResponse": false, @@ -5800,12 +6803,12 @@ }, "parameters": [ { - "$id": "460", + "$id": "524", "kind": "method", "name": "body", "serializedName": "body", "type": { - "$ref": "196" + "$ref": "200" }, "location": "Body", "isApiVersion": false, @@ -5817,7 +6820,7 @@ "decorators": [] }, { - "$id": "461", + "$id": "525", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -5835,7 +6838,7 @@ "decorators": [] }, { - "$id": "462", + "$id": "526", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -5854,7 +6857,7 @@ ], "response": { "type": { - "$ref": "196" + "$ref": "200" } }, "isOverride": false, @@ -5863,7 +6866,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.patchAction" }, { - "$id": "463", + "$id": "527", "kind": "basic", "name": "anonymousBody", "accessibility": "public", @@ -5873,14 +6876,14 @@ ], "doc": "body parameter without body decorator", "operation": { - "$id": "464", + "$id": "528", "name": "anonymousBody", "resourceName": "SampleTypeSpec", "doc": "body parameter without body decorator", "accessibility": "public", "parameters": [ { - "$id": "465", + "$id": "529", "kind": "query", "name": "requiredQueryParam", "serializedName": "requiredQueryParam", @@ -5896,7 +6899,7 @@ "readOnly": false }, { - "$id": "466", + "$id": "530", "kind": "header", "name": "requiredHeader", "serializedName": "required-header", @@ -5912,7 +6915,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.anonymousBody.requiredHeader" }, { - "$id": "467", + "$id": "531", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -5929,7 +6932,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.anonymousBody.contentType" }, { - "$id": "468", + "$id": "532", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -5945,12 +6948,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.anonymousBody.accept" }, { - "$id": "469", + "$id": "533", "kind": "body", "name": "thing", "serializedName": "thing", "type": { - "$ref": "196" + "$ref": "200" }, "isApiVersion": false, "contentTypes": [ @@ -5970,7 +6973,7 @@ 200 ], "bodyType": { - "$ref": "196" + "$ref": "200" }, "headers": [], "isErrorResponse": false, @@ -5994,13 +6997,13 @@ }, "parameters": [ { - "$id": "470", + "$id": "534", "kind": "method", "name": "name", "serializedName": "name", "doc": "name of the Thing", "type": { - "$id": "471", + "$id": "535", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -6016,13 +7019,13 @@ "decorators": [] }, { - "$id": "472", + "$id": "536", "kind": "method", "name": "requiredUnion", "serializedName": "requiredUnion", "doc": "required Union", "type": { - "$ref": "200" + "$ref": "204" }, "location": "Body", "isApiVersion": false, @@ -6034,7 +7037,7 @@ "decorators": [] }, { - "$id": "473", + "$id": "537", "kind": "method", "name": "requiredLiteralString", "serializedName": "requiredLiteralString", @@ -6052,13 +7055,13 @@ "decorators": [] }, { - "$id": "474", + "$id": "538", "kind": "method", "name": "requiredNullableString", "serializedName": "requiredNullableString", "doc": "required nullable string", "type": { - "$ref": "207" + "$ref": "211" }, "location": "Body", "isApiVersion": false, @@ -6070,13 +7073,13 @@ "decorators": [] }, { - "$id": "475", + "$id": "539", "kind": "method", "name": "optionalNullableString", "serializedName": "optionalNullableString", "doc": "required optional string", "type": { - "$ref": "210" + "$ref": "214" }, "location": "Body", "isApiVersion": false, @@ -6088,7 +7091,7 @@ "decorators": [] }, { - "$id": "476", + "$id": "540", "kind": "method", "name": "requiredLiteralInt", "serializedName": "requiredLiteralInt", @@ -6106,7 +7109,7 @@ "decorators": [] }, { - "$id": "477", + "$id": "541", "kind": "method", "name": "requiredLiteralFloat", "serializedName": "requiredLiteralFloat", @@ -6124,7 +7127,7 @@ "decorators": [] }, { - "$id": "478", + "$id": "542", "kind": "method", "name": "requiredLiteralBool", "serializedName": "requiredLiteralBool", @@ -6142,18 +7145,18 @@ "decorators": [] }, { - "$id": "479", + "$id": "543", "kind": "method", "name": "optionalLiteralString", "serializedName": "optionalLiteralString", "doc": "optional literal string", "type": { - "$id": "480", + "$id": "544", "kind": "enum", "name": "ThingOptionalLiteralString", "crossLanguageDefinitionId": "", "valueType": { - "$id": "481", + "$id": "545", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -6161,12 +7164,12 @@ }, "values": [ { - "$id": "482", + "$id": "546", "kind": "enumvalue", "name": "reject", "value": "reject", "valueType": { - "$id": "483", + "$id": "547", "kind": "string", "decorators": [], "doc": "A sequence of textual characters.", @@ -6174,7 +7177,7 @@ "crossLanguageDefinitionId": "TypeSpec.string" }, "enumType": { - "$ref": "480" + "$ref": "544" }, "decorators": [] } @@ -6195,13 +7198,13 @@ "decorators": [] }, { - "$id": "484", + "$id": "548", "kind": "method", "name": "requiredNullableLiteralString", "serializedName": "requiredNullableLiteralString", "doc": "required nullable literal string", "type": { - "$ref": "217" + "$ref": "221" }, "location": "Body", "isApiVersion": false, @@ -6213,18 +7216,18 @@ "decorators": [] }, { - "$id": "485", + "$id": "549", "kind": "method", "name": "optionalLiteralInt", "serializedName": "optionalLiteralInt", "doc": "optional literal int", "type": { - "$id": "486", + "$id": "550", "kind": "enum", "name": "ThingOptionalLiteralInt", "crossLanguageDefinitionId": "", "valueType": { - "$id": "487", + "$id": "551", "kind": "int32", "name": "int32", "crossLanguageDefinitionId": "TypeSpec.int32", @@ -6232,12 +7235,12 @@ }, "values": [ { - "$id": "488", + "$id": "552", "kind": "enumvalue", "name": "456", "value": 456, "valueType": { - "$id": "489", + "$id": "553", "kind": "int32", "decorators": [], "doc": "A 32-bit integer. (`-2,147,483,648` to `2,147,483,647`)", @@ -6245,7 +7248,7 @@ "crossLanguageDefinitionId": "TypeSpec.int32" }, "enumType": { - "$ref": "486" + "$ref": "550" }, "decorators": [] } @@ -6266,18 +7269,18 @@ "decorators": [] }, { - "$id": "490", + "$id": "554", "kind": "method", "name": "optionalLiteralFloat", "serializedName": "optionalLiteralFloat", "doc": "optional literal float", "type": { - "$id": "491", + "$id": "555", "kind": "enum", "name": "ThingOptionalLiteralFloat", "crossLanguageDefinitionId": "", "valueType": { - "$id": "492", + "$id": "556", "kind": "float32", "name": "float32", "crossLanguageDefinitionId": "TypeSpec.float32", @@ -6285,12 +7288,12 @@ }, "values": [ { - "$id": "493", + "$id": "557", "kind": "enumvalue", "name": "4.56", "value": 4.56, "valueType": { - "$id": "494", + "$id": "558", "kind": "float32", "decorators": [], "doc": "A 32 bit floating point number. (`±1.5 x 10^−45` to `±3.4 x 10^38`)", @@ -6298,7 +7301,7 @@ "crossLanguageDefinitionId": "TypeSpec.float32" }, "enumType": { - "$ref": "491" + "$ref": "555" }, "decorators": [] } @@ -6319,7 +7322,7 @@ "decorators": [] }, { - "$id": "495", + "$id": "559", "kind": "method", "name": "optionalLiteralBool", "serializedName": "optionalLiteralBool", @@ -6337,13 +7340,13 @@ "decorators": [] }, { - "$id": "496", + "$id": "560", "kind": "method", "name": "requiredBadDescription", "serializedName": "requiredBadDescription", "doc": "description with xml <|endoftext|>", "type": { - "$id": "497", + "$id": "561", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -6359,13 +7362,13 @@ "decorators": [] }, { - "$id": "498", + "$id": "562", "kind": "method", "name": "optionalNullableList", "serializedName": "optionalNullableList", "doc": "optional nullable collection", "type": { - "$ref": "224" + "$ref": "228" }, "location": "Body", "isApiVersion": false, @@ -6377,13 +7380,13 @@ "decorators": [] }, { - "$id": "499", + "$id": "563", "kind": "method", "name": "requiredNullableList", "serializedName": "requiredNullableList", "doc": "required nullable collection", "type": { - "$ref": "228" + "$ref": "232" }, "location": "Body", "isApiVersion": false, @@ -6395,13 +7398,13 @@ "decorators": [] }, { - "$id": "500", + "$id": "564", "kind": "method", "name": "propertyWithSpecialDocs", "serializedName": "propertyWithSpecialDocs", "doc": "This tests:\n- Simple bullet point. This bullet point is going to be very long to test how text wrapping is handled in bullet points within documentation comments. It should properly indent the wrapped lines.\n- Another bullet point with **bold text**. This bullet point is also intentionally long to see how the formatting is preserved when the text wraps onto multiple lines in the generated documentation.\n- Third bullet point with *italic text*. Similar to the previous points, this one is extended to ensure that the wrapping and formatting are correctly applied in the output.\n- Complex bullet point with **bold** and *italic* combined. This bullet point combines both bold and italic formatting and is long enough to test the wrapping behavior in such cases.\n- **Bold bullet point**: A bullet point that is entirely bolded. This point is also made lengthy to observe how the bold formatting is maintained across wrapped lines.\n- *Italic bullet point*: A bullet point that is entirely italicized. This final point is extended to verify that italic formatting is correctly applied even when the text spans multiple lines.", "type": { - "$id": "501", + "$id": "565", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -6417,7 +7420,7 @@ "decorators": [] }, { - "$id": "502", + "$id": "566", "kind": "method", "name": "requiredQueryParam", "serializedName": "requiredQueryParam", @@ -6434,7 +7437,7 @@ "decorators": [] }, { - "$id": "503", + "$id": "567", "kind": "method", "name": "requiredHeader", "serializedName": "required-header", @@ -6451,7 +7454,7 @@ "decorators": [] }, { - "$id": "504", + "$id": "568", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -6469,7 +7472,7 @@ "decorators": [] }, { - "$id": "505", + "$id": "569", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -6488,7 +7491,7 @@ ], "response": { "type": { - "$ref": "196" + "$ref": "200" } }, "isOverride": false, @@ -6497,7 +7500,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.anonymousBody" }, { - "$id": "506", + "$id": "570", "kind": "basic", "name": "friendlyModel", "accessibility": "public", @@ -6507,14 +7510,14 @@ ], "doc": "Model can have its friendly name", "operation": { - "$id": "507", + "$id": "571", "name": "friendlyModel", "resourceName": "SampleTypeSpec", "doc": "Model can have its friendly name", "accessibility": "public", "parameters": [ { - "$id": "508", + "$id": "572", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -6531,7 +7534,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.friendlyModel.contentType" }, { - "$id": "509", + "$id": "573", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -6547,12 +7550,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.friendlyModel.accept" }, { - "$id": "510", + "$id": "574", "kind": "body", "name": "friend", "serializedName": "friend", "type": { - "$ref": "279" + "$ref": "283" }, "isApiVersion": false, "contentTypes": [ @@ -6572,7 +7575,7 @@ 200 ], "bodyType": { - "$ref": "279" + "$ref": "283" }, "headers": [], "isErrorResponse": false, @@ -6596,13 +7599,13 @@ }, "parameters": [ { - "$id": "511", + "$id": "575", "kind": "method", "name": "name", "serializedName": "name", "doc": "name of the NotFriend", "type": { - "$id": "512", + "$id": "576", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -6618,7 +7621,7 @@ "decorators": [] }, { - "$id": "513", + "$id": "577", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -6636,7 +7639,7 @@ "decorators": [] }, { - "$id": "514", + "$id": "578", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -6655,7 +7658,7 @@ ], "response": { "type": { - "$ref": "279" + "$ref": "283" } }, "isOverride": false, @@ -6664,7 +7667,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.friendlyModel" }, { - "$id": "515", + "$id": "579", "kind": "basic", "name": "addTimeHeader", "accessibility": "public", @@ -6673,23 +7676,23 @@ "2024-08-16-preview" ], "operation": { - "$id": "516", + "$id": "580", "name": "addTimeHeader", "resourceName": "SampleTypeSpec", "accessibility": "public", "parameters": [ { - "$id": "517", + "$id": "581", "kind": "header", "name": "repeatabilityFirstSent", "serializedName": "Repeatability-First-Sent", "type": { - "$id": "518", + "$id": "582", "kind": "utcDateTime", "name": "utcDateTime", "encode": "rfc7231", "wireType": { - "$id": "519", + "$id": "583", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -6728,17 +7731,17 @@ }, "parameters": [ { - "$id": "520", + "$id": "584", "kind": "method", "name": "repeatabilityFirstSent", "serializedName": "Repeatability-First-Sent", "type": { - "$id": "521", + "$id": "585", "kind": "utcDateTime", "name": "utcDateTime", "encode": "rfc7231", "wireType": { - "$id": "522", + "$id": "586", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -6764,7 +7767,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.addTimeHeader" }, { - "$id": "523", + "$id": "587", "kind": "basic", "name": "projectedNameModel", "accessibility": "public", @@ -6774,14 +7777,14 @@ ], "doc": "Model can have its projected name", "operation": { - "$id": "524", + "$id": "588", "name": "projectedNameModel", "resourceName": "SampleTypeSpec", "doc": "Model can have its projected name", "accessibility": "public", "parameters": [ { - "$id": "525", + "$id": "589", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -6798,7 +7801,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.projectedNameModel.contentType" }, { - "$id": "526", + "$id": "590", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -6814,12 +7817,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.projectedNameModel.accept" }, { - "$id": "527", + "$id": "591", "kind": "body", "name": "renamedModel", "serializedName": "renamedModel", "type": { - "$ref": "282" + "$ref": "286" }, "isApiVersion": false, "contentTypes": [ @@ -6839,7 +7842,7 @@ 200 ], "bodyType": { - "$ref": "282" + "$ref": "286" }, "headers": [], "isErrorResponse": false, @@ -6863,13 +7866,13 @@ }, "parameters": [ { - "$id": "528", + "$id": "592", "kind": "method", "name": "otherName", "serializedName": "otherName", "doc": "name of the ModelWithClientName", "type": { - "$id": "529", + "$id": "593", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -6885,7 +7888,7 @@ "decorators": [] }, { - "$id": "530", + "$id": "594", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -6903,7 +7906,7 @@ "decorators": [] }, { - "$id": "531", + "$id": "595", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -6922,7 +7925,7 @@ ], "response": { "type": { - "$ref": "282" + "$ref": "286" } }, "isOverride": false, @@ -6931,7 +7934,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.projectedNameModel" }, { - "$id": "532", + "$id": "596", "kind": "basic", "name": "returnsAnonymousModel", "accessibility": "public", @@ -6941,14 +7944,14 @@ ], "doc": "return anonymous model", "operation": { - "$id": "533", + "$id": "597", "name": "returnsAnonymousModel", "resourceName": "SampleTypeSpec", "doc": "return anonymous model", "accessibility": "public", "parameters": [ { - "$id": "534", + "$id": "598", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -6970,7 +7973,7 @@ 200 ], "bodyType": { - "$ref": "285" + "$ref": "289" }, "headers": [], "isErrorResponse": false, @@ -6991,7 +7994,7 @@ }, "parameters": [ { - "$id": "535", + "$id": "599", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -7010,7 +8013,7 @@ ], "response": { "type": { - "$ref": "285" + "$ref": "289" } }, "isOverride": false, @@ -7019,7 +8022,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.returnsAnonymousModel" }, { - "$id": "536", + "$id": "600", "kind": "basic", "name": "getUnknownValue", "accessibility": "public", @@ -7029,19 +8032,19 @@ ], "doc": "get extensible enum", "operation": { - "$id": "537", + "$id": "601", "name": "getUnknownValue", "resourceName": "SampleTypeSpec", "doc": "get extensible enum", "accessibility": "public", "parameters": [ { - "$id": "538", + "$id": "602", "kind": "header", "name": "accept", "serializedName": "Accept", "type": { - "$id": "539", + "$id": "603", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -7062,7 +8065,7 @@ 200 ], "bodyType": { - "$id": "540", + "$id": "604", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -7094,12 +8097,12 @@ }, "parameters": [ { - "$id": "541", + "$id": "605", "kind": "method", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "539" + "$ref": "603" }, "location": "Header", "isApiVersion": false, @@ -7113,7 +8116,7 @@ ], "response": { "type": { - "$ref": "540" + "$ref": "604" } }, "isOverride": false, @@ -7122,7 +8125,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.getUnknownValue" }, { - "$id": "542", + "$id": "606", "kind": "basic", "name": "internalProtocol", "accessibility": "public", @@ -7132,14 +8135,14 @@ ], "doc": "When set protocol false and convenient true, then the protocol method should be internal", "operation": { - "$id": "543", + "$id": "607", "name": "internalProtocol", "resourceName": "SampleTypeSpec", "doc": "When set protocol false and convenient true, then the protocol method should be internal", "accessibility": "public", "parameters": [ { - "$id": "544", + "$id": "608", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -7156,7 +8159,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.internalProtocol.contentType" }, { - "$id": "545", + "$id": "609", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -7172,12 +8175,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.internalProtocol.accept" }, { - "$id": "546", + "$id": "610", "kind": "body", "name": "body", "serializedName": "body", "type": { - "$ref": "196" + "$ref": "200" }, "isApiVersion": false, "contentTypes": [ @@ -7197,7 +8200,7 @@ 200 ], "bodyType": { - "$ref": "196" + "$ref": "200" }, "headers": [], "isErrorResponse": false, @@ -7221,12 +8224,12 @@ }, "parameters": [ { - "$id": "547", + "$id": "611", "kind": "method", "name": "body", "serializedName": "body", "type": { - "$ref": "196" + "$ref": "200" }, "location": "Body", "isApiVersion": false, @@ -7238,7 +8241,7 @@ "decorators": [] }, { - "$id": "548", + "$id": "612", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -7256,7 +8259,7 @@ "decorators": [] }, { - "$id": "549", + "$id": "613", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -7275,7 +8278,7 @@ ], "response": { "type": { - "$ref": "196" + "$ref": "200" } }, "isOverride": false, @@ -7284,7 +8287,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.internalProtocol" }, { - "$id": "550", + "$id": "614", "kind": "basic", "name": "stillConvenient", "accessibility": "public", @@ -7294,7 +8297,7 @@ ], "doc": "When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one", "operation": { - "$id": "551", + "$id": "615", "name": "stillConvenient", "resourceName": "SampleTypeSpec", "doc": "When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one", @@ -7327,7 +8330,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.stillConvenient" }, { - "$id": "552", + "$id": "616", "kind": "basic", "name": "headAsBoolean", "accessibility": "public", @@ -7337,19 +8340,19 @@ ], "doc": "head as boolean.", "operation": { - "$id": "553", + "$id": "617", "name": "headAsBoolean", "resourceName": "SampleTypeSpec", "doc": "head as boolean.", "accessibility": "public", "parameters": [ { - "$id": "554", + "$id": "618", "kind": "path", "name": "id", "serializedName": "id", "type": { - "$id": "555", + "$id": "619", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -7388,12 +8391,12 @@ }, "parameters": [ { - "$id": "556", + "$id": "620", "kind": "method", "name": "id", "serializedName": "id", "type": { - "$id": "557", + "$id": "621", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -7416,7 +8419,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.headAsBoolean" }, { - "$id": "558", + "$id": "622", "kind": "basic", "name": "WithApiVersion", "accessibility": "public", @@ -7426,19 +8429,19 @@ ], "doc": "Return hi again", "operation": { - "$id": "559", + "$id": "623", "name": "WithApiVersion", "resourceName": "SampleTypeSpec", "doc": "Return hi again", "accessibility": "public", "parameters": [ { - "$id": "560", + "$id": "624", "kind": "header", "name": "p1", "serializedName": "p1", "type": { - "$id": "561", + "$id": "625", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -7453,12 +8456,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.WithApiVersion.p1" }, { - "$id": "562", + "$id": "626", "kind": "query", "name": "apiVersion", "serializedName": "apiVersion", "type": { - "$id": "563", + "$id": "627", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -7468,7 +8471,7 @@ "explode": false, "defaultValue": { "type": { - "$id": "564", + "$id": "628", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string" @@ -7503,12 +8506,12 @@ }, "parameters": [ { - "$id": "565", + "$id": "629", "kind": "method", "name": "p1", "serializedName": "p1", "type": { - "$id": "566", + "$id": "630", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -7531,7 +8534,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.WithApiVersion" }, { - "$id": "567", + "$id": "631", "kind": "paging", "name": "ListWithNextLink", "accessibility": "public", @@ -7541,14 +8544,14 @@ ], "doc": "List things with nextlink", "operation": { - "$id": "568", + "$id": "632", "name": "ListWithNextLink", "resourceName": "SampleTypeSpec", "doc": "List things with nextlink", "accessibility": "public", "parameters": [ { - "$id": "569", + "$id": "633", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -7570,7 +8573,7 @@ 200 ], "bodyType": { - "$ref": "286" + "$ref": "290" }, "headers": [], "isErrorResponse": false, @@ -7591,7 +8594,7 @@ }, "parameters": [ { - "$id": "570", + "$id": "634", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -7610,7 +8613,7 @@ ], "response": { "type": { - "$ref": "288" + "$ref": "292" }, "resultSegments": [ "things" @@ -7634,7 +8637,7 @@ } }, { - "$id": "571", + "$id": "635", "kind": "paging", "name": "ListWithStringNextLink", "accessibility": "public", @@ -7644,14 +8647,14 @@ ], "doc": "List things with nextlink", "operation": { - "$id": "572", + "$id": "636", "name": "ListWithStringNextLink", "resourceName": "SampleTypeSpec", "doc": "List things with nextlink", "accessibility": "public", "parameters": [ { - "$id": "573", + "$id": "637", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -7673,7 +8676,7 @@ 200 ], "bodyType": { - "$ref": "291" + "$ref": "295" }, "headers": [], "isErrorResponse": false, @@ -7694,7 +8697,7 @@ }, "parameters": [ { - "$id": "574", + "$id": "638", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -7713,7 +8716,7 @@ ], "response": { "type": { - "$ref": "288" + "$ref": "292" }, "resultSegments": [ "things" @@ -7737,7 +8740,7 @@ } }, { - "$id": "575", + "$id": "639", "kind": "paging", "name": "ListWithContinuationToken", "accessibility": "public", @@ -7747,19 +8750,19 @@ ], "doc": "List things with continuation token", "operation": { - "$id": "576", + "$id": "640", "name": "ListWithContinuationToken", "resourceName": "SampleTypeSpec", "doc": "List things with continuation token", "accessibility": "public", "parameters": [ { - "$id": "577", + "$id": "641", "kind": "query", "name": "token", "serializedName": "token", "type": { - "$id": "578", + "$id": "642", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -7774,7 +8777,7 @@ "readOnly": false }, { - "$id": "579", + "$id": "643", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -7796,7 +8799,7 @@ 200 ], "bodyType": { - "$ref": "295" + "$ref": "299" }, "headers": [], "isErrorResponse": false, @@ -7817,12 +8820,12 @@ }, "parameters": [ { - "$id": "580", + "$id": "644", "kind": "method", "name": "token", "serializedName": "token", "type": { - "$id": "581", + "$id": "645", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -7838,7 +8841,7 @@ "decorators": [] }, { - "$id": "582", + "$id": "646", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -7857,7 +8860,7 @@ ], "response": { "type": { - "$ref": "288" + "$ref": "292" }, "resultSegments": [ "things" @@ -7873,7 +8876,7 @@ ], "continuationToken": { "parameter": { - "$ref": "577" + "$ref": "641" }, "responseSegments": [ "nextToken" @@ -7884,7 +8887,7 @@ } }, { - "$id": "583", + "$id": "647", "kind": "paging", "name": "ListWithContinuationTokenHeaderResponse", "accessibility": "public", @@ -7894,19 +8897,19 @@ ], "doc": "List things with continuation token header response", "operation": { - "$id": "584", + "$id": "648", "name": "ListWithContinuationTokenHeaderResponse", "resourceName": "SampleTypeSpec", "doc": "List things with continuation token header response", "accessibility": "public", "parameters": [ { - "$id": "585", + "$id": "649", "kind": "query", "name": "token", "serializedName": "token", "type": { - "$id": "586", + "$id": "650", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -7921,7 +8924,7 @@ "readOnly": false }, { - "$id": "587", + "$id": "651", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -7943,14 +8946,14 @@ 200 ], "bodyType": { - "$ref": "299" + "$ref": "303" }, "headers": [ { "name": "nextToken", "nameInResponse": "next-token", "type": { - "$id": "588", + "$id": "652", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -7976,12 +8979,12 @@ }, "parameters": [ { - "$id": "589", + "$id": "653", "kind": "method", "name": "token", "serializedName": "token", "type": { - "$id": "590", + "$id": "654", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -7997,7 +9000,7 @@ "decorators": [] }, { - "$id": "591", + "$id": "655", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -8016,7 +9019,7 @@ ], "response": { "type": { - "$ref": "288" + "$ref": "292" }, "resultSegments": [ "things" @@ -8032,7 +9035,7 @@ ], "continuationToken": { "parameter": { - "$ref": "585" + "$ref": "649" }, "responseSegments": [ "next-token" @@ -8043,7 +9046,7 @@ } }, { - "$id": "592", + "$id": "656", "kind": "paging", "name": "ListWithPaging", "accessibility": "public", @@ -8053,14 +9056,14 @@ ], "doc": "List things with paging", "operation": { - "$id": "593", + "$id": "657", "name": "ListWithPaging", "resourceName": "SampleTypeSpec", "doc": "List things with paging", "accessibility": "public", "parameters": [ { - "$id": "594", + "$id": "658", "kind": "header", "name": "accept", "serializedName": "Accept", @@ -8082,7 +9085,7 @@ 200 ], "bodyType": { - "$ref": "301" + "$ref": "305" }, "headers": [], "isErrorResponse": false, @@ -8103,7 +9106,7 @@ }, "parameters": [ { - "$id": "595", + "$id": "659", "kind": "method", "name": "accept", "serializedName": "Accept", @@ -8122,7 +9125,7 @@ ], "response": { "type": { - "$ref": "288" + "$ref": "292" }, "resultSegments": [ "items" @@ -8140,7 +9143,7 @@ } }, { - "$id": "596", + "$id": "660", "kind": "basic", "name": "EmbeddedParameters", "accessibility": "public", @@ -8150,20 +9153,20 @@ ], "doc": "An operation with embedded parameters within the body", "operation": { - "$id": "597", + "$id": "661", "name": "EmbeddedParameters", "resourceName": "SampleTypeSpec", "doc": "An operation with embedded parameters within the body", "accessibility": "public", "parameters": [ { - "$id": "598", + "$id": "662", "kind": "header", "name": "requiredHeader", "serializedName": "required-header", "doc": "required header parameter", "type": { - "$id": "599", + "$id": "663", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -8178,13 +9181,13 @@ "crossLanguageDefinitionId": "SampleTypeSpec.ModelWithEmbeddedNonBodyParameters.requiredHeader" }, { - "$id": "600", + "$id": "664", "kind": "header", "name": "optionalHeader", "serializedName": "optional-header", "doc": "optional header parameter", "type": { - "$id": "601", + "$id": "665", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -8199,13 +9202,13 @@ "crossLanguageDefinitionId": "SampleTypeSpec.ModelWithEmbeddedNonBodyParameters.optionalHeader" }, { - "$id": "602", + "$id": "666", "kind": "query", "name": "requiredQuery", "serializedName": "requiredQuery", "doc": "required query parameter", "type": { - "$id": "603", + "$id": "667", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -8220,13 +9223,13 @@ "readOnly": false }, { - "$id": "604", + "$id": "668", "kind": "query", "name": "optionalQuery", "serializedName": "optionalQuery", "doc": "optional query parameter", "type": { - "$id": "605", + "$id": "669", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -8241,7 +9244,7 @@ "readOnly": false }, { - "$id": "606", + "$id": "670", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -8258,12 +9261,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.EmbeddedParameters.contentType" }, { - "$id": "607", + "$id": "671", "kind": "body", "name": "body", "serializedName": "body", "type": { - "$ref": "303" + "$ref": "307" }, "isApiVersion": false, "contentTypes": [ @@ -8301,12 +9304,12 @@ }, "parameters": [ { - "$id": "608", + "$id": "672", "kind": "method", "name": "body", "serializedName": "body", "type": { - "$ref": "303" + "$ref": "307" }, "location": "Body", "isApiVersion": false, @@ -8318,7 +9321,7 @@ "decorators": [] }, { - "$id": "609", + "$id": "673", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -8343,7 +9346,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.EmbeddedParameters" }, { - "$id": "610", + "$id": "674", "kind": "basic", "name": "DynamicModelOperation", "accessibility": "public", @@ -8353,14 +9356,14 @@ ], "doc": "An operation with a dynamic model", "operation": { - "$id": "611", + "$id": "675", "name": "DynamicModelOperation", "resourceName": "SampleTypeSpec", "doc": "An operation with a dynamic model", "accessibility": "public", "parameters": [ { - "$id": "612", + "$id": "676", "kind": "header", "name": "contentType", "serializedName": "Content-Type", @@ -8377,12 +9380,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.DynamicModelOperation.contentType" }, { - "$id": "613", + "$id": "677", "kind": "body", "name": "body", "serializedName": "body", "type": { - "$ref": "314" + "$ref": "318" }, "isApiVersion": false, "contentTypes": [ @@ -8420,12 +9423,12 @@ }, "parameters": [ { - "$id": "614", + "$id": "678", "kind": "method", "name": "body", "serializedName": "body", "type": { - "$ref": "314" + "$ref": "318" }, "location": "Body", "isApiVersion": false, @@ -8437,7 +9440,7 @@ "decorators": [] }, { - "$id": "615", + "$id": "679", "kind": "method", "name": "contentType", "serializedName": "Content-Type", @@ -8460,16 +9463,112 @@ "generateConvenient": true, "generateProtocol": true, "crossLanguageDefinitionId": "SampleTypeSpec.DynamicModelOperation" + }, + { + "$id": "680", + "kind": "basic", + "name": "GetXmlAdvancedModel", + "accessibility": "public", + "apiVersions": [ + "2024-07-16-preview", + "2024-08-16-preview" + ], + "doc": "Get an advanced XML model with various property types", + "operation": { + "$id": "681", + "name": "GetXmlAdvancedModel", + "resourceName": "SampleTypeSpec", + "doc": "Get an advanced XML model with various property types", + "accessibility": "public", + "parameters": [ + { + "$id": "682", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "174" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "SampleTypeSpec.GetXmlAdvancedModel.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "356" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "176" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{sampleTypeSpecUrl}", + "path": "/xmlAdvanced", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "SampleTypeSpec.GetXmlAdvancedModel", + "decorators": [], + "namespace": "SampleTypeSpec" + }, + "parameters": [ + { + "$id": "683", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "174" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "SampleTypeSpec.GetXmlAdvancedModel.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "356" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "SampleTypeSpec.GetXmlAdvancedModel" } ], "parameters": [ { - "$id": "616", + "$id": "684", "kind": "endpoint", "name": "sampleTypeSpecUrl", "serializedName": "sampleTypeSpecUrl", "type": { - "$id": "617", + "$id": "685", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -8484,12 +9583,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.sampleTypeSpecUrl" }, { - "$id": "618", + "$id": "686", "kind": "method", "name": "apiVersion", "serializedName": "apiVersion", "type": { - "$id": "619", + "$id": "687", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string", @@ -8499,7 +9598,7 @@ "isApiVersion": true, "defaultValue": { "type": { - "$id": "620", + "$id": "688", "kind": "string", "name": "string", "crossLanguageDefinitionId": "TypeSpec.string" @@ -8523,13 +9622,13 @@ ], "children": [ { - "$id": "621", + "$id": "689", "kind": "client", "name": "AnimalOperations", "namespace": "SampleTypeSpec", "methods": [ { - "$id": "622", + "$id": "690", "kind": "basic", "name": "updatePetAsAnimal", "accessibility": "public", @@ -8539,20 +9638,20 @@ ], "doc": "Update a pet as an animal", "operation": { - "$id": "623", + "$id": "691", "name": "updatePetAsAnimal", "resourceName": "AnimalOperations", "doc": "Update a pet as an animal", "accessibility": "public", "parameters": [ { - "$id": "624", + "$id": "692", "kind": "header", "name": "contentType", "serializedName": "Content-Type", "doc": "Body parameter's content type. Known values are application/json", "type": { - "$ref": "174" + "$ref": "178" }, "isApiVersion": false, "optional": false, @@ -8563,12 +9662,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.AnimalOperations.updatePetAsAnimal.contentType" }, { - "$id": "625", + "$id": "693", "kind": "header", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "176" + "$ref": "180" }, "isApiVersion": false, "optional": false, @@ -8579,12 +9678,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.AnimalOperations.updatePetAsAnimal.accept" }, { - "$id": "626", + "$id": "694", "kind": "body", "name": "animal", "serializedName": "animal", "type": { - "$ref": "352" + "$ref": "416" }, "isApiVersion": false, "contentTypes": [ @@ -8604,7 +9703,7 @@ 200 ], "bodyType": { - "$ref": "352" + "$ref": "416" }, "headers": [], "isErrorResponse": false, @@ -8628,12 +9727,12 @@ }, "parameters": [ { - "$id": "627", + "$id": "695", "kind": "method", "name": "animal", "serializedName": "animal", "type": { - "$ref": "352" + "$ref": "416" }, "location": "Body", "isApiVersion": false, @@ -8645,13 +9744,13 @@ "decorators": [] }, { - "$id": "628", + "$id": "696", "kind": "method", "name": "contentType", "serializedName": "Content-Type", "doc": "Body parameter's content type. Known values are application/json", "type": { - "$ref": "174" + "$ref": "178" }, "location": "Header", "isApiVersion": false, @@ -8663,12 +9762,12 @@ "decorators": [] }, { - "$id": "629", + "$id": "697", "kind": "method", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "176" + "$ref": "180" }, "location": "Header", "isApiVersion": false, @@ -8682,7 +9781,7 @@ ], "response": { "type": { - "$ref": "352" + "$ref": "416" } }, "isOverride": false, @@ -8691,7 +9790,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.AnimalOperations.updatePetAsAnimal" }, { - "$id": "630", + "$id": "698", "kind": "basic", "name": "updateDogAsAnimal", "accessibility": "public", @@ -8701,20 +9800,20 @@ ], "doc": "Update a dog as an animal", "operation": { - "$id": "631", + "$id": "699", "name": "updateDogAsAnimal", "resourceName": "AnimalOperations", "doc": "Update a dog as an animal", "accessibility": "public", "parameters": [ { - "$id": "632", + "$id": "700", "kind": "header", "name": "contentType", "serializedName": "Content-Type", "doc": "Body parameter's content type. Known values are application/json", "type": { - "$ref": "178" + "$ref": "182" }, "isApiVersion": false, "optional": false, @@ -8725,12 +9824,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.AnimalOperations.updateDogAsAnimal.contentType" }, { - "$id": "633", + "$id": "701", "kind": "header", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "180" + "$ref": "184" }, "isApiVersion": false, "optional": false, @@ -8741,12 +9840,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.AnimalOperations.updateDogAsAnimal.accept" }, { - "$id": "634", + "$id": "702", "kind": "body", "name": "animal", "serializedName": "animal", "type": { - "$ref": "352" + "$ref": "416" }, "isApiVersion": false, "contentTypes": [ @@ -8766,7 +9865,7 @@ 200 ], "bodyType": { - "$ref": "352" + "$ref": "416" }, "headers": [], "isErrorResponse": false, @@ -8790,12 +9889,12 @@ }, "parameters": [ { - "$id": "635", + "$id": "703", "kind": "method", "name": "animal", "serializedName": "animal", "type": { - "$ref": "352" + "$ref": "416" }, "location": "Body", "isApiVersion": false, @@ -8807,13 +9906,13 @@ "decorators": [] }, { - "$id": "636", + "$id": "704", "kind": "method", "name": "contentType", "serializedName": "Content-Type", "doc": "Body parameter's content type. Known values are application/json", "type": { - "$ref": "178" + "$ref": "182" }, "location": "Header", "isApiVersion": false, @@ -8825,12 +9924,12 @@ "decorators": [] }, { - "$id": "637", + "$id": "705", "kind": "method", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "180" + "$ref": "184" }, "location": "Header", "isApiVersion": false, @@ -8844,7 +9943,7 @@ ], "response": { "type": { - "$ref": "352" + "$ref": "416" } }, "isOverride": false, @@ -8855,12 +9954,12 @@ ], "parameters": [ { - "$id": "638", + "$id": "706", "kind": "endpoint", "name": "sampleTypeSpecUrl", "serializedName": "sampleTypeSpecUrl", "type": { - "$id": "639", + "$id": "707", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -8883,18 +9982,18 @@ "2024-08-16-preview" ], "parent": { - "$ref": "370" + "$ref": "434" }, "isMultiServiceClient": false }, { - "$id": "640", + "$id": "708", "kind": "client", "name": "PetOperations", "namespace": "SampleTypeSpec", "methods": [ { - "$id": "641", + "$id": "709", "kind": "basic", "name": "updatePetAsPet", "accessibility": "public", @@ -8904,20 +10003,20 @@ ], "doc": "Update a pet as a pet", "operation": { - "$id": "642", + "$id": "710", "name": "updatePetAsPet", "resourceName": "PetOperations", "doc": "Update a pet as a pet", "accessibility": "public", "parameters": [ { - "$id": "643", + "$id": "711", "kind": "header", "name": "contentType", "serializedName": "Content-Type", "doc": "Body parameter's content type. Known values are application/json", "type": { - "$ref": "182" + "$ref": "186" }, "isApiVersion": false, "optional": false, @@ -8928,12 +10027,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PetOperations.updatePetAsPet.contentType" }, { - "$id": "644", + "$id": "712", "kind": "header", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "184" + "$ref": "188" }, "isApiVersion": false, "optional": false, @@ -8944,12 +10043,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PetOperations.updatePetAsPet.accept" }, { - "$id": "645", + "$id": "713", "kind": "body", "name": "pet", "serializedName": "pet", "type": { - "$ref": "357" + "$ref": "421" }, "isApiVersion": false, "contentTypes": [ @@ -8969,7 +10068,7 @@ 200 ], "bodyType": { - "$ref": "357" + "$ref": "421" }, "headers": [], "isErrorResponse": false, @@ -8993,12 +10092,12 @@ }, "parameters": [ { - "$id": "646", + "$id": "714", "kind": "method", "name": "pet", "serializedName": "pet", "type": { - "$ref": "357" + "$ref": "421" }, "location": "Body", "isApiVersion": false, @@ -9010,13 +10109,13 @@ "decorators": [] }, { - "$id": "647", + "$id": "715", "kind": "method", "name": "contentType", "serializedName": "Content-Type", "doc": "Body parameter's content type. Known values are application/json", "type": { - "$ref": "182" + "$ref": "186" }, "location": "Header", "isApiVersion": false, @@ -9028,12 +10127,12 @@ "decorators": [] }, { - "$id": "648", + "$id": "716", "kind": "method", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "184" + "$ref": "188" }, "location": "Header", "isApiVersion": false, @@ -9047,7 +10146,7 @@ ], "response": { "type": { - "$ref": "357" + "$ref": "421" } }, "isOverride": false, @@ -9056,7 +10155,7 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PetOperations.updatePetAsPet" }, { - "$id": "649", + "$id": "717", "kind": "basic", "name": "updateDogAsPet", "accessibility": "public", @@ -9066,20 +10165,20 @@ ], "doc": "Update a dog as a pet", "operation": { - "$id": "650", + "$id": "718", "name": "updateDogAsPet", "resourceName": "PetOperations", "doc": "Update a dog as a pet", "accessibility": "public", "parameters": [ { - "$id": "651", + "$id": "719", "kind": "header", "name": "contentType", "serializedName": "Content-Type", "doc": "Body parameter's content type. Known values are application/json", "type": { - "$ref": "186" + "$ref": "190" }, "isApiVersion": false, "optional": false, @@ -9090,12 +10189,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PetOperations.updateDogAsPet.contentType" }, { - "$id": "652", + "$id": "720", "kind": "header", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "188" + "$ref": "192" }, "isApiVersion": false, "optional": false, @@ -9106,12 +10205,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.PetOperations.updateDogAsPet.accept" }, { - "$id": "653", + "$id": "721", "kind": "body", "name": "pet", "serializedName": "pet", "type": { - "$ref": "357" + "$ref": "421" }, "isApiVersion": false, "contentTypes": [ @@ -9131,7 +10230,7 @@ 200 ], "bodyType": { - "$ref": "357" + "$ref": "421" }, "headers": [], "isErrorResponse": false, @@ -9155,12 +10254,12 @@ }, "parameters": [ { - "$id": "654", + "$id": "722", "kind": "method", "name": "pet", "serializedName": "pet", "type": { - "$ref": "357" + "$ref": "421" }, "location": "Body", "isApiVersion": false, @@ -9172,13 +10271,13 @@ "decorators": [] }, { - "$id": "655", + "$id": "723", "kind": "method", "name": "contentType", "serializedName": "Content-Type", "doc": "Body parameter's content type. Known values are application/json", "type": { - "$ref": "186" + "$ref": "190" }, "location": "Header", "isApiVersion": false, @@ -9190,12 +10289,12 @@ "decorators": [] }, { - "$id": "656", + "$id": "724", "kind": "method", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "188" + "$ref": "192" }, "location": "Header", "isApiVersion": false, @@ -9209,7 +10308,7 @@ ], "response": { "type": { - "$ref": "357" + "$ref": "421" } }, "isOverride": false, @@ -9220,12 +10319,12 @@ ], "parameters": [ { - "$id": "657", + "$id": "725", "kind": "endpoint", "name": "sampleTypeSpecUrl", "serializedName": "sampleTypeSpecUrl", "type": { - "$id": "658", + "$id": "726", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -9248,18 +10347,18 @@ "2024-08-16-preview" ], "parent": { - "$ref": "370" + "$ref": "434" }, "isMultiServiceClient": false }, { - "$id": "659", + "$id": "727", "kind": "client", "name": "DogOperations", "namespace": "SampleTypeSpec", "methods": [ { - "$id": "660", + "$id": "728", "kind": "basic", "name": "updateDogAsDog", "accessibility": "public", @@ -9269,20 +10368,20 @@ ], "doc": "Update a dog as a dog", "operation": { - "$id": "661", + "$id": "729", "name": "updateDogAsDog", "resourceName": "DogOperations", "doc": "Update a dog as a dog", "accessibility": "public", "parameters": [ { - "$id": "662", + "$id": "730", "kind": "header", "name": "contentType", "serializedName": "Content-Type", "doc": "Body parameter's content type. Known values are application/json", "type": { - "$ref": "190" + "$ref": "194" }, "isApiVersion": false, "optional": false, @@ -9293,12 +10392,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.DogOperations.updateDogAsDog.contentType" }, { - "$id": "663", + "$id": "731", "kind": "header", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "192" + "$ref": "196" }, "isApiVersion": false, "optional": false, @@ -9309,12 +10408,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.DogOperations.updateDogAsDog.accept" }, { - "$id": "664", + "$id": "732", "kind": "body", "name": "dog", "serializedName": "dog", "type": { - "$ref": "361" + "$ref": "425" }, "isApiVersion": false, "contentTypes": [ @@ -9334,7 +10433,7 @@ 200 ], "bodyType": { - "$ref": "361" + "$ref": "425" }, "headers": [], "isErrorResponse": false, @@ -9358,12 +10457,12 @@ }, "parameters": [ { - "$id": "665", + "$id": "733", "kind": "method", "name": "dog", "serializedName": "dog", "type": { - "$ref": "361" + "$ref": "425" }, "location": "Body", "isApiVersion": false, @@ -9375,13 +10474,13 @@ "decorators": [] }, { - "$id": "666", + "$id": "734", "kind": "method", "name": "contentType", "serializedName": "Content-Type", "doc": "Body parameter's content type. Known values are application/json", "type": { - "$ref": "190" + "$ref": "194" }, "location": "Header", "isApiVersion": false, @@ -9393,12 +10492,12 @@ "decorators": [] }, { - "$id": "667", + "$id": "735", "kind": "method", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "192" + "$ref": "196" }, "location": "Header", "isApiVersion": false, @@ -9412,7 +10511,7 @@ ], "response": { "type": { - "$ref": "361" + "$ref": "425" } }, "isOverride": false, @@ -9423,12 +10522,12 @@ ], "parameters": [ { - "$id": "668", + "$id": "736", "kind": "endpoint", "name": "sampleTypeSpecUrl", "serializedName": "sampleTypeSpecUrl", "type": { - "$id": "669", + "$id": "737", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -9451,18 +10550,18 @@ "2024-08-16-preview" ], "parent": { - "$ref": "370" + "$ref": "434" }, "isMultiServiceClient": false }, { - "$id": "670", + "$id": "738", "kind": "client", "name": "Metrics", "namespace": "SampleTypeSpec", "methods": [ { - "$id": "671", + "$id": "739", "kind": "basic", "name": "getWidgetMetrics", "accessibility": "public", @@ -9472,14 +10571,14 @@ ], "doc": "Get Widget metrics for given day of week", "operation": { - "$id": "672", + "$id": "740", "name": "getWidgetMetrics", "resourceName": "Metrics", "doc": "Get Widget metrics for given day of week", "accessibility": "public", "parameters": [ { - "$id": "673", + "$id": "741", "kind": "path", "name": "day", "serializedName": "day", @@ -9498,12 +10597,12 @@ "crossLanguageDefinitionId": "SampleTypeSpec.Metrics.getWidgetMetrics.day" }, { - "$id": "674", + "$id": "742", "kind": "header", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "194" + "$ref": "198" }, "isApiVersion": false, "optional": false, @@ -9520,7 +10619,7 @@ 200 ], "bodyType": { - "$ref": "365" + "$ref": "429" }, "headers": [], "isErrorResponse": false, @@ -9541,7 +10640,7 @@ }, "parameters": [ { - "$id": "675", + "$id": "743", "kind": "method", "name": "day", "serializedName": "day", @@ -9558,12 +10657,12 @@ "decorators": [] }, { - "$id": "676", + "$id": "744", "kind": "method", "name": "accept", "serializedName": "Accept", "type": { - "$ref": "194" + "$ref": "198" }, "location": "Header", "isApiVersion": false, @@ -9577,7 +10676,7 @@ ], "response": { "type": { - "$ref": "365" + "$ref": "429" } }, "isOverride": false, @@ -9588,12 +10687,12 @@ ], "parameters": [ { - "$id": "677", + "$id": "745", "kind": "endpoint", "name": "sampleTypeSpecUrl", "serializedName": "sampleTypeSpecUrl", "type": { - "$id": "678", + "$id": "746", "kind": "url", "name": "endpoint", "crossLanguageDefinitionId": "TypeSpec.url" @@ -9616,7 +10715,7 @@ "2024-08-16-preview" ], "parent": { - "$ref": "370" + "$ref": "434" }, "isMultiServiceClient": false } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/Configuration.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/Configuration.json new file mode 100644 index 00000000000..a7354dd1925 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/Configuration.json @@ -0,0 +1,3 @@ +{ + "package-name": "Payload.Xml" +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/Payload.Xml.sln b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/Payload.Xml.sln new file mode 100644 index 00000000000..ffe5c722514 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/Payload.Xml.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Payload.Xml", "src\Payload.Xml.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/Argument.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/Argument.cs new file mode 100644 index 00000000000..61865967545 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/Argument.cs @@ -0,0 +1,71 @@ +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Payload.Xml +{ + internal static partial class Argument + { + /// The value. + /// The name. + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CancellationTokenExtensions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CancellationTokenExtensions.cs new file mode 100644 index 00000000000..361aa6b20bb --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CancellationTokenExtensions.cs @@ -0,0 +1,14 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; + +namespace Payload.Xml +{ + internal static partial class CancellationTokenExtensions + { + public static RequestOptions ToRequestOptions(this CancellationToken cancellationToken) => cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ChangeTrackingDictionary.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 00000000000..0056945c396 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,186 @@ +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Payload.Xml +{ + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerDictionary == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + /// Gets the Keys. + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + /// Gets the Values. + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + /// Gets or sets the value associated with the specified key. + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + /// Gets the Keys. + IEnumerable IReadOnlyDictionary.Keys => Keys; + + /// Gets the Values. + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + /// The item to search for. + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + /// The array to copy. + /// The index. + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + /// The item to remove. + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + /// The key. + /// The value to add. + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + /// The key to search for. + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + /// The key. + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + /// The key to search for. + /// The value. + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ChangeTrackingList.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 00000000000..ee7f9dcdcbf --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Payload.Xml +{ + internal partial class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + /// The inner list. + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + /// The inner list. + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerList == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureList().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + /// Gets or sets the value associated with the specified key. + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + /// The item. + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + /// The array to copy to. + /// The array index. + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + /// The item. + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + /// The item. + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + /// The inner list. + /// The item. + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + /// The inner list. + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ClientPipelineExtensions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 00000000000..373be9eaa47 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,67 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + { + await pipeline.SendAsync(message).ConfigureAwait(false); + + if (message.Response.IsError && (options?.ErrorOptions & ClientErrorBehaviors.NoThrow) != ClientErrorBehaviors.NoThrow) + { + throw await ClientResultException.CreateAsync(message.Response).ConfigureAwait(false); + } + + PipelineResponse response = message.BufferResponse ? message.Response : message.ExtractResponse(); + return response; + } + + public static PipelineResponse ProcessMessage(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + { + pipeline.Send(message); + + if (message.Response.IsError && (options?.ErrorOptions & ClientErrorBehaviors.NoThrow) != ClientErrorBehaviors.NoThrow) + { + throw new ClientResultException(message.Response); + } + + PipelineResponse response = message.BufferResponse ? message.Response : message.ExtractResponse(); + return response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + { + PipelineResponse response = await pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return ClientResult.FromValue(true, response); + case >= 400 and < 500: + return ClientResult.FromValue(false, response); + default: + return new ErrorResult(response, new ClientResultException(response)); + } + } + + public static ClientResult ProcessHeadAsBoolMessage(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + { + PipelineResponse response = pipeline.ProcessMessage(message, options); + switch (response.Status) + { + case >= 200 and < 300: + return ClientResult.FromValue(true, response); + case >= 400 and < 500: + return ClientResult.FromValue(false, response); + default: + return new ErrorResult(response, new ClientResultException(response)); + } + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ClientUriBuilder.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ClientUriBuilder.cs new file mode 100644 index 00000000000..48d85a28311 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ClientUriBuilder.cs @@ -0,0 +1,181 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Payload.Xml +{ + internal partial class ClientUriBuilder + { + private UriBuilder _uriBuilder; + private StringBuilder _pathAndQuery; + private int _pathLength; + + public ClientUriBuilder() + { + } + + private UriBuilder UriBuilder => _uriBuilder ??= new UriBuilder(); + + private StringBuilder PathAndQuery => _pathAndQuery ??= new StringBuilder(); + + public void Reset(Uri uri) + { + _uriBuilder = new UriBuilder(uri); + PathAndQuery.Clear(); + PathAndQuery.Append(UriBuilder.Path); + _pathLength = PathAndQuery.Length; + PathAndQuery.Append(UriBuilder.Query); + } + + public void AppendPath(string value, bool escape) + { + if (escape) + { + value = Uri.EscapeDataString(value); + } + if (_pathLength > 0 && PathAndQuery[_pathLength - 1] == '/' && value[0] == '/') + { + PathAndQuery.Remove(_pathLength - 1, 1); + _pathLength = _pathLength - 1; + } + PathAndQuery.Insert(_pathLength, value); + _pathLength = _pathLength + value.Length; + } + + public void AppendPath(bool value, bool escape = false) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(float value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(double value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(int value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(byte[] value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); + + public void AppendPath(DateTimeOffset value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); + + public void AppendPath(TimeSpan value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); + + public void AppendPath(Guid value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(long value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPathDelimited(IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + AppendPath(string.Join(delimiter, stringValues), escape); + } + + public void AppendQuery(string name, string value, bool escape) + { + if (PathAndQuery.Length == _pathLength) + { + PathAndQuery.Append('?'); + } + if (PathAndQuery.Length > _pathLength && PathAndQuery[PathAndQuery.Length - 1] != '?') + { + PathAndQuery.Append('&'); + } + if (escape) + { + value = Uri.EscapeDataString(value); + } + PathAndQuery.Append(name); + PathAndQuery.Append('='); + PathAndQuery.Append(value); + } + + public void AppendQuery(string name, bool value, bool escape = false) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, float value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, DateTimeOffset value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); + + public void AppendQuery(string name, TimeSpan value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); + + public void AppendQuery(string name, double value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, decimal value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, int value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, long value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, TimeSpan value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, byte[] value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); + + public void AppendQuery(string name, Guid value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQueryDelimited(string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + + public void UpdateQuery(string name, string value) + { + if (PathAndQuery.Length == _pathLength) + { + AppendQuery(name, value, false); + } + else + { + int queryStartIndex = _pathLength + 1; + string searchPattern = name + "="; + string queryString = PathAndQuery.ToString(queryStartIndex, PathAndQuery.Length - queryStartIndex); + int paramStartIndex = -1; + if (queryString.StartsWith(searchPattern)) + { + paramStartIndex = 0; + } + if (paramStartIndex == -1) + { + int prefixedIndex = queryString.IndexOf("&" + searchPattern); + if (prefixedIndex >= 0) + { + paramStartIndex = prefixedIndex + 1; + } + } + if (paramStartIndex >= 0) + { + int valueStartIndex = paramStartIndex + searchPattern.Length; + int valueEndIndex = queryString.IndexOf('&', valueStartIndex); + if (valueEndIndex == -1) + { + valueEndIndex = queryString.Length; + } + int globalStart = queryStartIndex + valueStartIndex; + int globalEnd = queryStartIndex + valueEndIndex; + PathAndQuery.Remove(globalStart, globalEnd - globalStart); + PathAndQuery.Insert(globalStart, value); + } + else + { + AppendQuery(name, value, false); + } + } + } + + public Uri ToUri() + { + UriBuilder.Path = PathAndQuery.ToString(0, _pathLength); + if (PathAndQuery.Length > _pathLength) + { + UriBuilder.Query = PathAndQuery.ToString(_pathLength + 1, PathAndQuery.Length - _pathLength - 1); + } + if (PathAndQuery.Length == _pathLength) + { + UriBuilder.Query = ""; + } + return UriBuilder.Uri; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CodeGenMemberAttribute.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 00000000000..044dfe314c5 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,17 @@ +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CodeGenSerializationAttribute.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 00000000000..aedb8b359b8 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CodeGenSuppressAttribute.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 00000000000..601ded913ab --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,26 @@ +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CodeGenTypeAttribute.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 00000000000..d7b56bdccdf --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ErrorResult.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 00000000000..8c11e244e9b --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + internal partial class ErrorResult : ClientResult + { + private readonly PipelineResponse _response; + private readonly ClientResultException _exception; + + public ErrorResult(PipelineResponse response, ClientResultException exception) : base(default, response) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ModelSerializationExtensions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 00000000000..2a1c179a5db --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,272 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Runtime.InteropServices; +using System.Text.Json; +using System.Xml.Linq; + +namespace Payload.Xml +{ + internal static partial class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + Dictionary dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + List list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + string text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) + { + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + string value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + public static BinaryData GetUtf8Bytes(this JsonElement element) + { +#if NET9_0_OR_GREATER + return new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(element).ToArray()); +#else + return BinaryData.FromString(element.GetRawText()); +#endif + } + + public static DateTimeOffset GetDateTimeOffset(this XElement element, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds((long)element), + _ => TypeFormatters.ParseDateTimeOffset(element.Value, format) + }; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/SerializationFormat.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 00000000000..c64e47b0aa0 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,46 @@ +// + +#nullable disable + +namespace Payload.Xml +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/TypeFormatters.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 00000000000..a89aaea93b1 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,178 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Payload.Xml +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithArrayOfModelValue.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithArrayOfModelValue.RestClient.cs new file mode 100644 index 00000000000..a487bbbd348 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithArrayOfModelValue.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + public partial class ModelWithArrayOfModelValue + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithArrayOfModel", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreatePutRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithArrayOfModel", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/xml"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithArrayOfModelValue.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithArrayOfModelValue.cs new file mode 100644 index 00000000000..82c5f4fae89 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithArrayOfModelValue.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + /// Operations for the ModelWithArrayOfModel type. + public partial class ModelWithArrayOfModelValue + { + private readonly Uri _endpoint; + + /// Initializes a new instance of ModelWithArrayOfModelValue for mocking. + protected ModelWithArrayOfModelValue() + { + } + + /// Initializes a new instance of ModelWithArrayOfModelValue. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal ModelWithArrayOfModelValue(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ModelWithArrayOfModel)result, result.GetRawResponse()); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ModelWithArrayOfModel)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Put(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task PutAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Put(ModelWithArrayOfModel input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return this.Put(input, cancellationToken.ToRequestOptions()); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task PutAsync(ModelWithArrayOfModel input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return await this.PutAsync(input, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithAttributesValue.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithAttributesValue.RestClient.cs new file mode 100644 index 00000000000..8c59dd7f015 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithAttributesValue.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + public partial class ModelWithAttributesValue + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithAttributes", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreatePutRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithAttributes", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/xml"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithAttributesValue.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithAttributesValue.cs new file mode 100644 index 00000000000..53db99c4ecc --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithAttributesValue.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + /// Operations for the ModelWithAttributes type. + public partial class ModelWithAttributesValue + { + private readonly Uri _endpoint; + + /// Initializes a new instance of ModelWithAttributesValue for mocking. + protected ModelWithAttributesValue() + { + } + + /// Initializes a new instance of ModelWithAttributesValue. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal ModelWithAttributesValue(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ModelWithAttributes)result, result.GetRawResponse()); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ModelWithAttributes)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Put(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task PutAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Put(ModelWithAttributes input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return this.Put(input, cancellationToken.ToRequestOptions()); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task PutAsync(ModelWithAttributes input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return await this.PutAsync(input, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithDictionaryValue.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithDictionaryValue.RestClient.cs new file mode 100644 index 00000000000..f1a980fca48 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithDictionaryValue.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + public partial class ModelWithDictionaryValue + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithDictionary", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreatePutRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithDictionary", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/xml"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithDictionaryValue.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithDictionaryValue.cs new file mode 100644 index 00000000000..ccc1876a003 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithDictionaryValue.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + /// Operations for the ModelWithDictionary type. + public partial class ModelWithDictionaryValue + { + private readonly Uri _endpoint; + + /// Initializes a new instance of ModelWithDictionaryValue for mocking. + protected ModelWithDictionaryValue() + { + } + + /// Initializes a new instance of ModelWithDictionaryValue. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal ModelWithDictionaryValue(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ModelWithDictionary)result, result.GetRawResponse()); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ModelWithDictionary)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Put(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task PutAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Put(ModelWithDictionary input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return this.Put(input, cancellationToken.ToRequestOptions()); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task PutAsync(ModelWithDictionary input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return await this.PutAsync(input, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithEmptyArrayValue.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithEmptyArrayValue.RestClient.cs new file mode 100644 index 00000000000..3cc23f34804 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithEmptyArrayValue.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + public partial class ModelWithEmptyArrayValue + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithEmptyArray", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreatePutRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithEmptyArray", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/xml"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithEmptyArrayValue.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithEmptyArrayValue.cs new file mode 100644 index 00000000000..c49326a8ee9 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithEmptyArrayValue.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + /// Operations for the ModelWithEmptyArray type. + public partial class ModelWithEmptyArrayValue + { + private readonly Uri _endpoint; + + /// Initializes a new instance of ModelWithEmptyArrayValue for mocking. + protected ModelWithEmptyArrayValue() + { + } + + /// Initializes a new instance of ModelWithEmptyArrayValue. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal ModelWithEmptyArrayValue(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ModelWithEmptyArray)result, result.GetRawResponse()); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ModelWithEmptyArray)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Put(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task PutAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Put(ModelWithEmptyArray input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return this.Put(input, cancellationToken.ToRequestOptions()); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task PutAsync(ModelWithEmptyArray input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return await this.PutAsync(input, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithEncodedNamesValue.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithEncodedNamesValue.RestClient.cs new file mode 100644 index 00000000000..a2226ca4a5d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithEncodedNamesValue.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + public partial class ModelWithEncodedNamesValue + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithEncodedNames", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreatePutRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithEncodedNames", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/xml"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithEncodedNamesValue.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithEncodedNamesValue.cs new file mode 100644 index 00000000000..e92af421616 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithEncodedNamesValue.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + /// Operations for the ModelWithEncodedNames type. + public partial class ModelWithEncodedNamesValue + { + private readonly Uri _endpoint; + + /// Initializes a new instance of ModelWithEncodedNamesValue for mocking. + protected ModelWithEncodedNamesValue() + { + } + + /// Initializes a new instance of ModelWithEncodedNamesValue. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal ModelWithEncodedNamesValue(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ModelWithEncodedNames)result, result.GetRawResponse()); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ModelWithEncodedNames)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Put(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task PutAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Put(ModelWithEncodedNames input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return this.Put(input, cancellationToken.ToRequestOptions()); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task PutAsync(ModelWithEncodedNames input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return await this.PutAsync(input, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithOptionalFieldValue.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithOptionalFieldValue.RestClient.cs new file mode 100644 index 00000000000..188e04c6dd4 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithOptionalFieldValue.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + public partial class ModelWithOptionalFieldValue + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithOptionalField", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreatePutRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithOptionalField", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/xml"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithOptionalFieldValue.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithOptionalFieldValue.cs new file mode 100644 index 00000000000..72f22ec3ab1 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithOptionalFieldValue.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + /// Operations for the ModelWithOptionalField type. + public partial class ModelWithOptionalFieldValue + { + private readonly Uri _endpoint; + + /// Initializes a new instance of ModelWithOptionalFieldValue for mocking. + protected ModelWithOptionalFieldValue() + { + } + + /// Initializes a new instance of ModelWithOptionalFieldValue. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal ModelWithOptionalFieldValue(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ModelWithOptionalField)result, result.GetRawResponse()); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ModelWithOptionalField)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Put(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task PutAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Put(ModelWithOptionalField input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return this.Put(input, cancellationToken.ToRequestOptions()); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task PutAsync(ModelWithOptionalField input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return await this.PutAsync(input, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithRenamedArraysValue.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithRenamedArraysValue.RestClient.cs new file mode 100644 index 00000000000..a80e0c24040 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithRenamedArraysValue.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + public partial class ModelWithRenamedArraysValue + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithRenamedArrays", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreatePutRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithRenamedArrays", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/xml"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithRenamedArraysValue.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithRenamedArraysValue.cs new file mode 100644 index 00000000000..1b654e216f1 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithRenamedArraysValue.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + /// Operations for the ModelWithRenamedArrays type. + public partial class ModelWithRenamedArraysValue + { + private readonly Uri _endpoint; + + /// Initializes a new instance of ModelWithRenamedArraysValue for mocking. + protected ModelWithRenamedArraysValue() + { + } + + /// Initializes a new instance of ModelWithRenamedArraysValue. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal ModelWithRenamedArraysValue(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ModelWithRenamedArrays)result, result.GetRawResponse()); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ModelWithRenamedArrays)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Put(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task PutAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Put(ModelWithRenamedArrays input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return this.Put(input, cancellationToken.ToRequestOptions()); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task PutAsync(ModelWithRenamedArrays input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return await this.PutAsync(input, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithRenamedFieldsValue.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithRenamedFieldsValue.RestClient.cs new file mode 100644 index 00000000000..92054c8d4bd --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithRenamedFieldsValue.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + public partial class ModelWithRenamedFieldsValue + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithRenamedFields", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreatePutRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithRenamedFields", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/xml"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithRenamedFieldsValue.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithRenamedFieldsValue.cs new file mode 100644 index 00000000000..a9b954bfaaf --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithRenamedFieldsValue.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + /// Operations for the ModelWithRenamedFields type. + public partial class ModelWithRenamedFieldsValue + { + private readonly Uri _endpoint; + + /// Initializes a new instance of ModelWithRenamedFieldsValue for mocking. + protected ModelWithRenamedFieldsValue() + { + } + + /// Initializes a new instance of ModelWithRenamedFieldsValue. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal ModelWithRenamedFieldsValue(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ModelWithRenamedFields)result, result.GetRawResponse()); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ModelWithRenamedFields)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Put(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task PutAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Put(ModelWithRenamedFields input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return this.Put(input, cancellationToken.ToRequestOptions()); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task PutAsync(ModelWithRenamedFields input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return await this.PutAsync(input, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithSimpleArraysValue.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithSimpleArraysValue.RestClient.cs new file mode 100644 index 00000000000..07cc50bae41 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithSimpleArraysValue.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + public partial class ModelWithSimpleArraysValue + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithSimpleArrays", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreatePutRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithSimpleArrays", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/xml"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithSimpleArraysValue.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithSimpleArraysValue.cs new file mode 100644 index 00000000000..ebe802a4e05 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithSimpleArraysValue.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + /// Operations for the ModelWithSimpleArrays type. + public partial class ModelWithSimpleArraysValue + { + private readonly Uri _endpoint; + + /// Initializes a new instance of ModelWithSimpleArraysValue for mocking. + protected ModelWithSimpleArraysValue() + { + } + + /// Initializes a new instance of ModelWithSimpleArraysValue. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal ModelWithSimpleArraysValue(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ModelWithSimpleArrays)result, result.GetRawResponse()); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ModelWithSimpleArrays)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Put(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task PutAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Put(ModelWithSimpleArrays input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return this.Put(input, cancellationToken.ToRequestOptions()); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task PutAsync(ModelWithSimpleArrays input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return await this.PutAsync(input, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithTextValue.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithTextValue.RestClient.cs new file mode 100644 index 00000000000..b3f567a448c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithTextValue.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + public partial class ModelWithTextValue + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithText", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreatePutRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithText", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/xml"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithTextValue.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithTextValue.cs new file mode 100644 index 00000000000..20cd716f08b --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithTextValue.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + /// Operations for the ModelWithText type. + public partial class ModelWithTextValue + { + private readonly Uri _endpoint; + + /// Initializes a new instance of ModelWithTextValue for mocking. + protected ModelWithTextValue() + { + } + + /// Initializes a new instance of ModelWithTextValue. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal ModelWithTextValue(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ModelWithText)result, result.GetRawResponse()); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ModelWithText)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Put(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task PutAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Put(ModelWithText input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return this.Put(input, cancellationToken.ToRequestOptions()); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task PutAsync(ModelWithText input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return await this.PutAsync(input, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithUnwrappedArrayValue.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithUnwrappedArrayValue.RestClient.cs new file mode 100644 index 00000000000..476973a4a37 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithUnwrappedArrayValue.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + public partial class ModelWithUnwrappedArrayValue + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithUnwrappedArray", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreatePutRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/modelWithUnwrappedArray", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/xml"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithUnwrappedArrayValue.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithUnwrappedArrayValue.cs new file mode 100644 index 00000000000..07fb49fd8a0 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/ModelWithUnwrappedArrayValue.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + /// Operations for the ModelWithUnwrappedArray type. + public partial class ModelWithUnwrappedArrayValue + { + private readonly Uri _endpoint; + + /// Initializes a new instance of ModelWithUnwrappedArrayValue for mocking. + protected ModelWithUnwrappedArrayValue() + { + } + + /// Initializes a new instance of ModelWithUnwrappedArrayValue. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal ModelWithUnwrappedArrayValue(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ModelWithUnwrappedArray)result, result.GetRawResponse()); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ModelWithUnwrappedArray)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Put(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task PutAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Put(ModelWithUnwrappedArray input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return this.Put(input, cancellationToken.ToRequestOptions()); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task PutAsync(ModelWithUnwrappedArray input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return await this.PutAsync(input, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithArrayOfModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithArrayOfModel.Serialization.cs new file mode 100644 index 00000000000..2eddcf5e535 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithArrayOfModel.Serialization.cs @@ -0,0 +1,81 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace Payload.Xml +{ + /// Contains an array of models. + public partial class ModelWithArrayOfModel + { + /// Initializes a new instance of for deserialization. + internal ModelWithArrayOfModel() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithArrayOfModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeModelWithArrayOfModel(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(ModelWithArrayOfModel)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ModelWithArrayOfModel(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeModelWithArrayOfModel(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static ModelWithArrayOfModel DeserializeModelWithArrayOfModel(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + IList items = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var child in element.Elements()) + { + string localName = child.Name.LocalName; + if (localName == "items") + { + List array = new List(); + foreach (var e in child.Elements("SimpleModel")) + { + array.Add(SimpleModel.DeserializeSimpleModel(e, options)); + } + items = array; + continue; + } + } + return new ModelWithArrayOfModel(items, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithArrayOfModel.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithArrayOfModel.cs new file mode 100644 index 00000000000..c3812cf02d3 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithArrayOfModel.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Payload.Xml +{ + /// Contains an array of models. + public partial class ModelWithArrayOfModel + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// is null. + public ModelWithArrayOfModel(IEnumerable items) + { + Argument.AssertNotNull(items, nameof(items)); + + Items = items.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal ModelWithArrayOfModel(IList items, IDictionary additionalBinaryDataProperties) + { + Items = items; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Items. + public IList Items { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithAttributes.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithAttributes.Serialization.cs new file mode 100644 index 00000000000..3341dfe7879 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithAttributes.Serialization.cs @@ -0,0 +1,93 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace Payload.Xml +{ + /// Contains fields that are XML attributes. + public partial class ModelWithAttributes + { + /// Initializes a new instance of for deserialization. + internal ModelWithAttributes() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithAttributes PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeModelWithAttributes(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(ModelWithAttributes)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ModelWithAttributes(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeModelWithAttributes(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static ModelWithAttributes DeserializeModelWithAttributes(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + int id1 = default; + string id2 = default; + bool enabled = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var attr in element.Attributes()) + { + string localName = attr.Name.LocalName; + if (localName == "id1") + { + id1 = (int)attr; + continue; + } + if (localName == "id2") + { + id2 = (string)attr; + continue; + } + } + + foreach (var child in element.Elements()) + { + string localName = child.Name.LocalName; + if (localName == "enabled") + { + enabled = (bool)child; + continue; + } + } + return new ModelWithAttributes(id1, id2, enabled, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithAttributes.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithAttributes.cs new file mode 100644 index 00000000000..31fdc045a9c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithAttributes.cs @@ -0,0 +1,52 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Payload.Xml +{ + /// Contains fields that are XML attributes. + public partial class ModelWithAttributes + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// + /// is null. + public ModelWithAttributes(int id1, string id2, bool enabled) + { + Argument.AssertNotNull(id2, nameof(id2)); + + Id1 = id1; + Id2 = id2; + Enabled = enabled; + } + + /// Initializes a new instance of . + /// + /// + /// + /// Keeps track of any properties unknown to the library. + internal ModelWithAttributes(int id1, string id2, bool enabled, IDictionary additionalBinaryDataProperties) + { + Id1 = id1; + Id2 = id2; + Enabled = enabled; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Id1. + public int Id1 { get; set; } + + /// Gets or sets the Id2. + public string Id2 { get; set; } + + /// Gets or sets the Enabled. + public bool Enabled { get; set; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithDictionary.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithDictionary.Serialization.cs new file mode 100644 index 00000000000..1ab5d9dc008 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithDictionary.Serialization.cs @@ -0,0 +1,81 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace Payload.Xml +{ + /// Contains a dictionary of key value pairs. + public partial class ModelWithDictionary + { + /// Initializes a new instance of for deserialization. + internal ModelWithDictionary() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithDictionary PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeModelWithDictionary(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(ModelWithDictionary)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ModelWithDictionary(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeModelWithDictionary(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static ModelWithDictionary DeserializeModelWithDictionary(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + IDictionary metadata = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var child in element.Elements()) + { + string localName = child.Name.LocalName; + if (localName == "metadata") + { + Dictionary dictionary = new Dictionary(); + foreach (var e in child.Elements()) + { + dictionary.Add(e.Name.LocalName, (string)e); + } + metadata = dictionary; + continue; + } + } + return new ModelWithDictionary(metadata, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithDictionary.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithDictionary.cs new file mode 100644 index 00000000000..e9d8f116f60 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithDictionary.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Payload.Xml +{ + /// Contains a dictionary of key value pairs. + public partial class ModelWithDictionary + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// is null. + public ModelWithDictionary(IDictionary metadata) + { + Argument.AssertNotNull(metadata, nameof(metadata)); + + Metadata = metadata; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal ModelWithDictionary(IDictionary metadata, IDictionary additionalBinaryDataProperties) + { + Metadata = metadata; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Metadata. + public IDictionary Metadata { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithEmptyArray.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithEmptyArray.Serialization.cs new file mode 100644 index 00000000000..b581ad07fe5 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithEmptyArray.Serialization.cs @@ -0,0 +1,81 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace Payload.Xml +{ + /// Contains an array of models that's supposed to be sent/received as an empty XML element. + public partial class ModelWithEmptyArray + { + /// Initializes a new instance of for deserialization. + internal ModelWithEmptyArray() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithEmptyArray PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeModelWithEmptyArray(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(ModelWithEmptyArray)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ModelWithEmptyArray(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeModelWithEmptyArray(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static ModelWithEmptyArray DeserializeModelWithEmptyArray(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + IList items = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var child in element.Elements()) + { + string localName = child.Name.LocalName; + if (localName == "items") + { + List array = new List(); + foreach (var e in child.Elements("SimpleModel")) + { + array.Add(SimpleModel.DeserializeSimpleModel(e, options)); + } + items = array; + continue; + } + } + return new ModelWithEmptyArray(items, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithEmptyArray.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithEmptyArray.cs new file mode 100644 index 00000000000..5aa8e315ac2 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithEmptyArray.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Payload.Xml +{ + /// Contains an array of models that's supposed to be sent/received as an empty XML element. + public partial class ModelWithEmptyArray + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// is null. + public ModelWithEmptyArray(IEnumerable items) + { + Argument.AssertNotNull(items, nameof(items)); + + Items = items.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal ModelWithEmptyArray(IList items, IDictionary additionalBinaryDataProperties) + { + Items = items; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Items. + public IList Items { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithEncodedNames.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithEncodedNames.Serialization.cs new file mode 100644 index 00000000000..e84c2755683 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithEncodedNames.Serialization.cs @@ -0,0 +1,87 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace Payload.Xml +{ + /// Uses encodedName instead of Xml.Name which is functionally equivalent. + public partial class ModelWithEncodedNames + { + /// Initializes a new instance of for deserialization. + internal ModelWithEncodedNames() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithEncodedNames PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeModelWithEncodedNames(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(ModelWithEncodedNames)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ModelWithEncodedNames(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeModelWithEncodedNames(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static ModelWithEncodedNames DeserializeModelWithEncodedNames(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + SimpleModel modelData = default; + IList colors = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var child in element.Elements()) + { + string localName = child.Name.LocalName; + if (localName == "SimpleModelData") + { + modelData = SimpleModel.DeserializeSimpleModel(child, options); + continue; + } + if (localName == "PossibleColors") + { + List array = new List(); + foreach (var e in child.Elements("string")) + { + array.Add((string)e); + } + colors = array; + continue; + } + } + return new ModelWithEncodedNames(modelData, colors, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithEncodedNames.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithEncodedNames.cs new file mode 100644 index 00000000000..89449a1d716 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithEncodedNames.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Payload.Xml +{ + /// Uses encodedName instead of Xml.Name which is functionally equivalent. + public partial class ModelWithEncodedNames + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// or is null. + public ModelWithEncodedNames(SimpleModel modelData, IEnumerable colors) + { + Argument.AssertNotNull(modelData, nameof(modelData)); + Argument.AssertNotNull(colors, nameof(colors)); + + ModelData = modelData; + Colors = colors.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// Keeps track of any properties unknown to the library. + internal ModelWithEncodedNames(SimpleModel modelData, IList colors, IDictionary additionalBinaryDataProperties) + { + ModelData = modelData; + Colors = colors; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the ModelData. + public SimpleModel ModelData { get; set; } + + /// Gets the Colors. + public IList Colors { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithOptionalField.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithOptionalField.Serialization.cs new file mode 100644 index 00000000000..31106981bfb --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithOptionalField.Serialization.cs @@ -0,0 +1,82 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace Payload.Xml +{ + /// Contains an optional field. + public partial class ModelWithOptionalField + { + /// Initializes a new instance of for deserialization. + internal ModelWithOptionalField() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithOptionalField PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeModelWithOptionalField(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(ModelWithOptionalField)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ModelWithOptionalField(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeModelWithOptionalField(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static ModelWithOptionalField DeserializeModelWithOptionalField(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + string item = default; + int? value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var child in element.Elements()) + { + string localName = child.Name.LocalName; + if (localName == "item") + { + item = (string)child; + continue; + } + if (localName == "value") + { + value = (int?)child; + continue; + } + } + return new ModelWithOptionalField(item, value, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithOptionalField.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithOptionalField.cs new file mode 100644 index 00000000000..31d2d668327 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithOptionalField.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Payload.Xml +{ + /// Contains an optional field. + public partial class ModelWithOptionalField + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// is null. + public ModelWithOptionalField(string item) + { + Argument.AssertNotNull(item, nameof(item)); + + Item = item; + } + + /// Initializes a new instance of . + /// + /// + /// Keeps track of any properties unknown to the library. + internal ModelWithOptionalField(string item, int? value, IDictionary additionalBinaryDataProperties) + { + Item = item; + Value = value; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Item. + public string Item { get; set; } + + /// Gets or sets the Value. + public int? Value { get; set; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithRenamedArrays.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithRenamedArrays.Serialization.cs new file mode 100644 index 00000000000..df88345e6d4 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithRenamedArrays.Serialization.cs @@ -0,0 +1,91 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace Payload.Xml +{ + /// Contains fields of wrapped and unwrapped arrays of primitive types that have different XML representations. + public partial class ModelWithRenamedArrays + { + /// Initializes a new instance of for deserialization. + internal ModelWithRenamedArrays() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithRenamedArrays PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeModelWithRenamedArrays(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(ModelWithRenamedArrays)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ModelWithRenamedArrays(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeModelWithRenamedArrays(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static ModelWithRenamedArrays DeserializeModelWithRenamedArrays(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + IList colors = default; + IList counts = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var child in element.Elements()) + { + string localName = child.Name.LocalName; + if (localName == "Colors") + { + if (colors == null) + { + colors = new ChangeTrackingList(); + } + colors.Add((string)child); + continue; + } + if (localName == "Counts") + { + List array = new List(); + foreach (var e in child.Elements("int32")) + { + array.Add((int)e); + } + counts = array; + continue; + } + } + return new ModelWithRenamedArrays(colors, counts, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithRenamedArrays.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithRenamedArrays.cs new file mode 100644 index 00000000000..b6cc9f37955 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithRenamedArrays.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Payload.Xml +{ + /// Contains fields of wrapped and unwrapped arrays of primitive types that have different XML representations. + public partial class ModelWithRenamedArrays + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// or is null. + public ModelWithRenamedArrays(IEnumerable colors, IEnumerable counts) + { + Argument.AssertNotNull(colors, nameof(colors)); + Argument.AssertNotNull(counts, nameof(counts)); + + Colors = colors.ToList(); + Counts = counts.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// Keeps track of any properties unknown to the library. + internal ModelWithRenamedArrays(IList colors, IList counts, IDictionary additionalBinaryDataProperties) + { + Colors = colors; + Counts = counts; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Colors. + public IList Colors { get; } + + /// Gets the Counts. + public IList Counts { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithRenamedFields.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithRenamedFields.Serialization.cs new file mode 100644 index 00000000000..36b8fecf0c6 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithRenamedFields.Serialization.cs @@ -0,0 +1,82 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace Payload.Xml +{ + /// Contains fields of the same type that have different XML representation. + public partial class ModelWithRenamedFields + { + /// Initializes a new instance of for deserialization. + internal ModelWithRenamedFields() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithRenamedFields PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeModelWithRenamedFields(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(ModelWithRenamedFields)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ModelWithRenamedFields(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeModelWithRenamedFields(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static ModelWithRenamedFields DeserializeModelWithRenamedFields(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + SimpleModel inputData = default; + SimpleModel outputData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var child in element.Elements()) + { + string localName = child.Name.LocalName; + if (localName == "InputData") + { + inputData = SimpleModel.DeserializeSimpleModel(child, options); + continue; + } + if (localName == "OutputData") + { + outputData = SimpleModel.DeserializeSimpleModel(child, options); + continue; + } + } + return new ModelWithRenamedFields(inputData, outputData, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithRenamedFields.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithRenamedFields.cs new file mode 100644 index 00000000000..c8059954a7a --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithRenamedFields.cs @@ -0,0 +1,46 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Payload.Xml +{ + /// Contains fields of the same type that have different XML representation. + public partial class ModelWithRenamedFields + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// or is null. + public ModelWithRenamedFields(SimpleModel inputData, SimpleModel outputData) + { + Argument.AssertNotNull(inputData, nameof(inputData)); + Argument.AssertNotNull(outputData, nameof(outputData)); + + InputData = inputData; + OutputData = outputData; + } + + /// Initializes a new instance of . + /// + /// + /// Keeps track of any properties unknown to the library. + internal ModelWithRenamedFields(SimpleModel inputData, SimpleModel outputData, IDictionary additionalBinaryDataProperties) + { + InputData = inputData; + OutputData = outputData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the InputData. + public SimpleModel InputData { get; set; } + + /// Gets or sets the OutputData. + public SimpleModel OutputData { get; set; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithSimpleArrays.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithSimpleArrays.Serialization.cs new file mode 100644 index 00000000000..fdd56d80843 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithSimpleArrays.Serialization.cs @@ -0,0 +1,92 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace Payload.Xml +{ + /// Contains fields of arrays of primitive types. + public partial class ModelWithSimpleArrays + { + /// Initializes a new instance of for deserialization. + internal ModelWithSimpleArrays() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithSimpleArrays PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeModelWithSimpleArrays(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(ModelWithSimpleArrays)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ModelWithSimpleArrays(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeModelWithSimpleArrays(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static ModelWithSimpleArrays DeserializeModelWithSimpleArrays(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + IList colors = default; + IList counts = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var child in element.Elements()) + { + string localName = child.Name.LocalName; + if (localName == "colors") + { + List array = new List(); + foreach (var e in child.Elements("string")) + { + array.Add((string)e); + } + colors = array; + continue; + } + if (localName == "counts") + { + List array = new List(); + foreach (var e in child.Elements("int32")) + { + array.Add((int)e); + } + counts = array; + continue; + } + } + return new ModelWithSimpleArrays(colors, counts, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithSimpleArrays.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithSimpleArrays.cs new file mode 100644 index 00000000000..60548e8f50e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithSimpleArrays.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Payload.Xml +{ + /// Contains fields of arrays of primitive types. + public partial class ModelWithSimpleArrays + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// or is null. + public ModelWithSimpleArrays(IEnumerable colors, IEnumerable counts) + { + Argument.AssertNotNull(colors, nameof(colors)); + Argument.AssertNotNull(counts, nameof(counts)); + + Colors = colors.ToList(); + Counts = counts.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// Keeps track of any properties unknown to the library. + internal ModelWithSimpleArrays(IList colors, IList counts, IDictionary additionalBinaryDataProperties) + { + Colors = colors; + Counts = counts; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Colors. + public IList Colors { get; } + + /// Gets the Counts. + public IList Counts { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithText.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithText.Serialization.cs new file mode 100644 index 00000000000..1e7503ed083 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithText.Serialization.cs @@ -0,0 +1,80 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace Payload.Xml +{ + /// Contains an attribute and text. + public partial class ModelWithText + { + /// Initializes a new instance of for deserialization. + internal ModelWithText() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithText PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeModelWithText(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(ModelWithText)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ModelWithText(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeModelWithText(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static ModelWithText DeserializeModelWithText(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + string language = default; + string content = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var attr in element.Attributes()) + { + string localName = attr.Name.LocalName; + if (localName == "language") + { + language = (string)attr; + continue; + } + } + + content = element.Value; + + return new ModelWithText(language, content, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithText.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithText.cs new file mode 100644 index 00000000000..2b9c0ce1b1e --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithText.cs @@ -0,0 +1,46 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Payload.Xml +{ + /// Contains an attribute and text. + public partial class ModelWithText + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// or is null. + public ModelWithText(string language, string content) + { + Argument.AssertNotNull(language, nameof(language)); + Argument.AssertNotNull(content, nameof(content)); + + Language = language; + Content = content; + } + + /// Initializes a new instance of . + /// + /// + /// Keeps track of any properties unknown to the library. + internal ModelWithText(string language, string content, IDictionary additionalBinaryDataProperties) + { + Language = language; + Content = content; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Language. + public string Language { get; set; } + + /// Gets or sets the Content. + public string Content { get; set; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithUnwrappedArray.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithUnwrappedArray.Serialization.cs new file mode 100644 index 00000000000..2bc0cfdca31 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithUnwrappedArray.Serialization.cs @@ -0,0 +1,91 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace Payload.Xml +{ + /// Contains fields of wrapped and unwrapped arrays of primitive types. + public partial class ModelWithUnwrappedArray + { + /// Initializes a new instance of for deserialization. + internal ModelWithUnwrappedArray() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelWithUnwrappedArray PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeModelWithUnwrappedArray(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(ModelWithUnwrappedArray)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator ModelWithUnwrappedArray(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeModelWithUnwrappedArray(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static ModelWithUnwrappedArray DeserializeModelWithUnwrappedArray(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + IList colors = default; + IList counts = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var child in element.Elements()) + { + string localName = child.Name.LocalName; + if (localName == "colors") + { + if (colors == null) + { + colors = new ChangeTrackingList(); + } + colors.Add((string)child); + continue; + } + if (localName == "counts") + { + List array = new List(); + foreach (var e in child.Elements("int32")) + { + array.Add((int)e); + } + counts = array; + continue; + } + } + return new ModelWithUnwrappedArray(colors, counts, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithUnwrappedArray.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithUnwrappedArray.cs new file mode 100644 index 00000000000..03adefe5c6a --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/ModelWithUnwrappedArray.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Payload.Xml +{ + /// Contains fields of wrapped and unwrapped arrays of primitive types. + public partial class ModelWithUnwrappedArray + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// or is null. + public ModelWithUnwrappedArray(IEnumerable colors, IEnumerable counts) + { + Argument.AssertNotNull(colors, nameof(colors)); + Argument.AssertNotNull(counts, nameof(counts)); + + Colors = colors.ToList(); + Counts = counts.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// Keeps track of any properties unknown to the library. + internal ModelWithUnwrappedArray(IList colors, IList counts, IDictionary additionalBinaryDataProperties) + { + Colors = colors; + Counts = counts; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Colors. + public IList Colors { get; } + + /// Gets the Counts. + public IList Counts { get; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/PayloadXmlContext.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/PayloadXmlContext.cs new file mode 100644 index 00000000000..d7ba8c4114c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/PayloadXmlContext.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(ModelWithArrayOfModel))] + [ModelReaderWriterBuildable(typeof(ModelWithAttributes))] + [ModelReaderWriterBuildable(typeof(ModelWithDictionary))] + [ModelReaderWriterBuildable(typeof(ModelWithEmptyArray))] + [ModelReaderWriterBuildable(typeof(ModelWithEncodedNames))] + [ModelReaderWriterBuildable(typeof(ModelWithOptionalField))] + [ModelReaderWriterBuildable(typeof(ModelWithRenamedArrays))] + [ModelReaderWriterBuildable(typeof(ModelWithRenamedFields))] + [ModelReaderWriterBuildable(typeof(ModelWithSimpleArrays))] + [ModelReaderWriterBuildable(typeof(ModelWithText))] + [ModelReaderWriterBuildable(typeof(ModelWithUnwrappedArray))] + [ModelReaderWriterBuildable(typeof(SimpleModel))] + public partial class PayloadXmlContext : ModelReaderWriterContext + { + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/SimpleModel.Serialization.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/SimpleModel.Serialization.cs new file mode 100644 index 00000000000..a61e4ff8f7f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/SimpleModel.Serialization.cs @@ -0,0 +1,82 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; + +namespace Payload.Xml +{ + /// Contains fields of primitive types. + public partial class SimpleModel + { + /// Initializes a new instance of for deserialization. + internal SimpleModel() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SimpleModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "X": + using (Stream dataStream = data.ToStream()) + { + return DeserializeSimpleModel(XElement.Load(dataStream, LoadOptions.PreserveWhitespace), options); + } + default: + throw new FormatException($"The model {nameof(SimpleModel)} does not support reading '{options.Format}' format."); + } + } + + /// The to deserialize the from. + public static explicit operator SimpleModel(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using Stream stream = response.ContentStream; + if (stream == null) + { + return default; + } + + return DeserializeSimpleModel(XElement.Load(stream, LoadOptions.PreserveWhitespace), ModelSerializationExtensions.WireOptions); + } + + /// The xml element to deserialize. + /// The client options for reading and writing models. + internal static SimpleModel DeserializeSimpleModel(XElement element, ModelReaderWriterOptions options) + { + if (element == null) + { + return null; + } + + string name = default; + int age = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + + foreach (var child in element.Elements()) + { + string localName = child.Name.LocalName; + if (localName == "name") + { + name = (string)child; + continue; + } + if (localName == "age") + { + age = (int)child; + continue; + } + } + return new SimpleModel(name, age, additionalBinaryDataProperties); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/SimpleModel.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/SimpleModel.cs new file mode 100644 index 00000000000..16c236d6627 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/Models/SimpleModel.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Payload.Xml +{ + /// Contains fields of primitive types. + public partial class SimpleModel + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// is null. + public SimpleModel(string name, int age) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + Age = age; + } + + /// Initializes a new instance of . + /// + /// + /// Keeps track of any properties unknown to the library. + internal SimpleModel(string name, int age, IDictionary additionalBinaryDataProperties) + { + Name = name; + Age = age; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Name. + public string Name { get; set; } + + /// Gets or sets the Age. + public int Age { get; set; } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/PayloadXmlModelFactory.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/PayloadXmlModelFactory.cs new file mode 100644 index 00000000000..88d390cbaaf --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/PayloadXmlModelFactory.cs @@ -0,0 +1,136 @@ +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; + +namespace Payload.Xml +{ + /// A factory class for creating instances of the models for mocking. + public static partial class PayloadXmlModelFactory + { + /// Contains fields of primitive types. + /// + /// + /// A new instance for mocking. + public static SimpleModel SimpleModel(string name = default, int age = default) + { + return new SimpleModel(name, age, additionalBinaryDataProperties: null); + } + + /// Contains fields of arrays of primitive types. + /// + /// + /// A new instance for mocking. + public static ModelWithSimpleArrays ModelWithSimpleArrays(IEnumerable colors = default, IEnumerable counts = default) + { + colors ??= new ChangeTrackingList(); + counts ??= new ChangeTrackingList(); + + return new ModelWithSimpleArrays(colors.ToList(), counts.ToList(), additionalBinaryDataProperties: null); + } + + /// Contains an array of models. + /// + /// A new instance for mocking. + public static ModelWithArrayOfModel ModelWithArrayOfModel(IEnumerable items = default) + { + items ??= new ChangeTrackingList(); + + return new ModelWithArrayOfModel(items.ToList(), additionalBinaryDataProperties: null); + } + + /// Contains an optional field. + /// + /// + /// A new instance for mocking. + public static ModelWithOptionalField ModelWithOptionalField(string item = default, int? value = default) + { + return new ModelWithOptionalField(item, value, additionalBinaryDataProperties: null); + } + + /// Contains fields that are XML attributes. + /// + /// + /// + /// A new instance for mocking. + public static ModelWithAttributes ModelWithAttributes(int id1 = default, string id2 = default, bool enabled = default) + { + return new ModelWithAttributes(id1, id2, enabled, additionalBinaryDataProperties: null); + } + + /// Contains fields of wrapped and unwrapped arrays of primitive types. + /// + /// + /// A new instance for mocking. + public static ModelWithUnwrappedArray ModelWithUnwrappedArray(IEnumerable colors = default, IEnumerable counts = default) + { + colors ??= new ChangeTrackingList(); + counts ??= new ChangeTrackingList(); + + return new ModelWithUnwrappedArray(colors.ToList(), counts.ToList(), additionalBinaryDataProperties: null); + } + + /// Contains fields of wrapped and unwrapped arrays of primitive types that have different XML representations. + /// + /// + /// A new instance for mocking. + public static ModelWithRenamedArrays ModelWithRenamedArrays(IEnumerable colors = default, IEnumerable counts = default) + { + colors ??= new ChangeTrackingList(); + counts ??= new ChangeTrackingList(); + + return new ModelWithRenamedArrays(colors.ToList(), counts.ToList(), additionalBinaryDataProperties: null); + } + + /// Contains fields of the same type that have different XML representation. + /// + /// + /// A new instance for mocking. + public static ModelWithRenamedFields ModelWithRenamedFields(SimpleModel inputData = default, SimpleModel outputData = default) + { + return new ModelWithRenamedFields(inputData, outputData, additionalBinaryDataProperties: null); + } + + /// Contains an array of models that's supposed to be sent/received as an empty XML element. + /// + /// A new instance for mocking. + public static ModelWithEmptyArray ModelWithEmptyArray(IEnumerable items = default) + { + items ??= new ChangeTrackingList(); + + return new ModelWithEmptyArray(items.ToList(), additionalBinaryDataProperties: null); + } + + /// Contains an attribute and text. + /// + /// + /// A new instance for mocking. + public static ModelWithText ModelWithText(string language = default, string content = default) + { + return new ModelWithText(language, content, additionalBinaryDataProperties: null); + } + + /// Contains a dictionary of key value pairs. + /// + /// A new instance for mocking. + public static ModelWithDictionary ModelWithDictionary(IDictionary metadata = default) + { + metadata ??= new ChangeTrackingDictionary(); + + return new ModelWithDictionary(metadata, additionalBinaryDataProperties: null); + } + + /// Uses encodedName instead of Xml.Name which is functionally equivalent. + /// + /// + /// A new instance for mocking. + public static ModelWithEncodedNames ModelWithEncodedNames(SimpleModel modelData = default, IEnumerable colors = default) + { + colors ??= new ChangeTrackingList(); + + return new ModelWithEncodedNames(modelData, colors.ToList(), additionalBinaryDataProperties: null); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/SimpleModelValue.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/SimpleModelValue.RestClient.cs new file mode 100644 index 00000000000..3f4c37f9f6c --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/SimpleModelValue.RestClient.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// + public partial class SimpleModelValue + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/simpleModel", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/xml"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreatePutRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/payload/xml/simpleModel", false); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/xml"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/SimpleModelValue.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/SimpleModelValue.cs new file mode 100644 index 00000000000..fd5783064d1 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/SimpleModelValue.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Payload.Xml +{ + /// Operations for the SimpleModel type. + public partial class SimpleModelValue + { + private readonly Uri _endpoint; + + /// Initializes a new instance of SimpleModelValue for mocking. + protected SimpleModelValue() + { + } + + /// Initializes a new instance of SimpleModelValue. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + internal SimpleModelValue(ClientPipeline pipeline, Uri endpoint) + { + _endpoint = endpoint; + Pipeline = pipeline; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(RequestOptions options) + { + using PipelineMessage message = CreateGetRequest(options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual ClientResult Get(CancellationToken cancellationToken = default) + { + ClientResult result = Get(cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((SimpleModel)result, result.GetRawResponse()); + } + + /// Get. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + ClientResult result = await GetAsync(cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((SimpleModel)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Put(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Put + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task PutAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreatePutRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Put(SimpleModel input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return this.Put(input, cancellationToken.ToRequestOptions()); + } + + /// Put. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task PutAsync(SimpleModel input, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(input, nameof(input)); + + return await this.PutAsync(input, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/XmlClient.RestClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/XmlClient.RestClient.cs new file mode 100644 index 00000000000..751cca6fc07 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/XmlClient.RestClient.cs @@ -0,0 +1,11 @@ +// + +#nullable disable + +namespace Payload.Xml +{ + /// + public partial class XmlClient + { + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/XmlClient.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/XmlClient.cs new file mode 100644 index 00000000000..2c105e76a1b --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/XmlClient.cs @@ -0,0 +1,122 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Threading; + +namespace Payload.Xml +{ + /// Sends and receives bodies in XML format. + public partial class XmlClient + { + private readonly Uri _endpoint; + private SimpleModelValue _cachedSimpleModelValue; + private ModelWithSimpleArraysValue _cachedModelWithSimpleArraysValue; + private ModelWithArrayOfModelValue _cachedModelWithArrayOfModelValue; + private ModelWithOptionalFieldValue _cachedModelWithOptionalFieldValue; + private ModelWithAttributesValue _cachedModelWithAttributesValue; + private ModelWithUnwrappedArrayValue _cachedModelWithUnwrappedArrayValue; + private ModelWithRenamedArraysValue _cachedModelWithRenamedArraysValue; + private ModelWithRenamedFieldsValue _cachedModelWithRenamedFieldsValue; + private ModelWithEmptyArrayValue _cachedModelWithEmptyArrayValue; + private ModelWithTextValue _cachedModelWithTextValue; + private ModelWithDictionaryValue _cachedModelWithDictionaryValue; + private ModelWithEncodedNamesValue _cachedModelWithEncodedNamesValue; + + /// Initializes a new instance of XmlClient. + public XmlClient() : this(new Uri("http://localhost:3000"), new XmlClientOptions()) + { + } + + /// Initializes a new instance of XmlClient. + /// Service endpoint. + /// The options for configuring the client. + /// is null. + public XmlClient(Uri endpoint, XmlClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + + options ??= new XmlClientOptions(); + + _endpoint = endpoint; + Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new UserAgentPolicy(typeof(XmlClient).Assembly) }, Array.Empty()); + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// Initializes a new instance of SimpleModelValue. + public virtual SimpleModelValue GetSimpleModelValueClient() + { + return Volatile.Read(ref _cachedSimpleModelValue) ?? Interlocked.CompareExchange(ref _cachedSimpleModelValue, new SimpleModelValue(Pipeline, _endpoint), null) ?? _cachedSimpleModelValue; + } + + /// Initializes a new instance of ModelWithSimpleArraysValue. + public virtual ModelWithSimpleArraysValue GetModelWithSimpleArraysValueClient() + { + return Volatile.Read(ref _cachedModelWithSimpleArraysValue) ?? Interlocked.CompareExchange(ref _cachedModelWithSimpleArraysValue, new ModelWithSimpleArraysValue(Pipeline, _endpoint), null) ?? _cachedModelWithSimpleArraysValue; + } + + /// Initializes a new instance of ModelWithArrayOfModelValue. + public virtual ModelWithArrayOfModelValue GetModelWithArrayOfModelValueClient() + { + return Volatile.Read(ref _cachedModelWithArrayOfModelValue) ?? Interlocked.CompareExchange(ref _cachedModelWithArrayOfModelValue, new ModelWithArrayOfModelValue(Pipeline, _endpoint), null) ?? _cachedModelWithArrayOfModelValue; + } + + /// Initializes a new instance of ModelWithOptionalFieldValue. + public virtual ModelWithOptionalFieldValue GetModelWithOptionalFieldValueClient() + { + return Volatile.Read(ref _cachedModelWithOptionalFieldValue) ?? Interlocked.CompareExchange(ref _cachedModelWithOptionalFieldValue, new ModelWithOptionalFieldValue(Pipeline, _endpoint), null) ?? _cachedModelWithOptionalFieldValue; + } + + /// Initializes a new instance of ModelWithAttributesValue. + public virtual ModelWithAttributesValue GetModelWithAttributesValueClient() + { + return Volatile.Read(ref _cachedModelWithAttributesValue) ?? Interlocked.CompareExchange(ref _cachedModelWithAttributesValue, new ModelWithAttributesValue(Pipeline, _endpoint), null) ?? _cachedModelWithAttributesValue; + } + + /// Initializes a new instance of ModelWithUnwrappedArrayValue. + public virtual ModelWithUnwrappedArrayValue GetModelWithUnwrappedArrayValueClient() + { + return Volatile.Read(ref _cachedModelWithUnwrappedArrayValue) ?? Interlocked.CompareExchange(ref _cachedModelWithUnwrappedArrayValue, new ModelWithUnwrappedArrayValue(Pipeline, _endpoint), null) ?? _cachedModelWithUnwrappedArrayValue; + } + + /// Initializes a new instance of ModelWithRenamedArraysValue. + public virtual ModelWithRenamedArraysValue GetModelWithRenamedArraysValueClient() + { + return Volatile.Read(ref _cachedModelWithRenamedArraysValue) ?? Interlocked.CompareExchange(ref _cachedModelWithRenamedArraysValue, new ModelWithRenamedArraysValue(Pipeline, _endpoint), null) ?? _cachedModelWithRenamedArraysValue; + } + + /// Initializes a new instance of ModelWithRenamedFieldsValue. + public virtual ModelWithRenamedFieldsValue GetModelWithRenamedFieldsValueClient() + { + return Volatile.Read(ref _cachedModelWithRenamedFieldsValue) ?? Interlocked.CompareExchange(ref _cachedModelWithRenamedFieldsValue, new ModelWithRenamedFieldsValue(Pipeline, _endpoint), null) ?? _cachedModelWithRenamedFieldsValue; + } + + /// Initializes a new instance of ModelWithEmptyArrayValue. + public virtual ModelWithEmptyArrayValue GetModelWithEmptyArrayValueClient() + { + return Volatile.Read(ref _cachedModelWithEmptyArrayValue) ?? Interlocked.CompareExchange(ref _cachedModelWithEmptyArrayValue, new ModelWithEmptyArrayValue(Pipeline, _endpoint), null) ?? _cachedModelWithEmptyArrayValue; + } + + /// Initializes a new instance of ModelWithTextValue. + public virtual ModelWithTextValue GetModelWithTextValueClient() + { + return Volatile.Read(ref _cachedModelWithTextValue) ?? Interlocked.CompareExchange(ref _cachedModelWithTextValue, new ModelWithTextValue(Pipeline, _endpoint), null) ?? _cachedModelWithTextValue; + } + + /// Initializes a new instance of ModelWithDictionaryValue. + public virtual ModelWithDictionaryValue GetModelWithDictionaryValueClient() + { + return Volatile.Read(ref _cachedModelWithDictionaryValue) ?? Interlocked.CompareExchange(ref _cachedModelWithDictionaryValue, new ModelWithDictionaryValue(Pipeline, _endpoint), null) ?? _cachedModelWithDictionaryValue; + } + + /// Initializes a new instance of ModelWithEncodedNamesValue. + public virtual ModelWithEncodedNamesValue GetModelWithEncodedNamesValueClient() + { + return Volatile.Read(ref _cachedModelWithEncodedNamesValue) ?? Interlocked.CompareExchange(ref _cachedModelWithEncodedNamesValue, new ModelWithEncodedNamesValue(Pipeline, _endpoint), null) ?? _cachedModelWithEncodedNamesValue; + } + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/XmlClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/XmlClientOptions.cs new file mode 100644 index 00000000000..0cf2c1eba39 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Generated/XmlClientOptions.cs @@ -0,0 +1,13 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Payload.Xml +{ + /// Client options for . + public partial class XmlClientOptions : ClientPipelineOptions + { + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Payload.Xml.csproj b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Payload.Xml.csproj new file mode 100644 index 00000000000..b0c5ee7edcd --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/src/Payload.Xml.csproj @@ -0,0 +1,15 @@ + + + This is the Payload.Xml client library for developing .NET applications with rich experience. + SDK Code Generation Payload.Xml + 1.0.0-beta.1 + Payload.Xml + netstandard2.0;net8.0 + latest + true + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/tspCodeModel.json new file mode 100644 index 00000000000..e237db86d8b --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/Spector/http/payload/xml/tspCodeModel.json @@ -0,0 +1,4738 @@ +{ + "name": "Payload.Xml", + "apiVersions": [], + "enums": [], + "constants": [ + { + "$id": "1", + "kind": "constant", + "name": "getContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "2", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "3", + "kind": "constant", + "name": "GetResponseContentType", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "4", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "5", + "kind": "constant", + "name": "GetResponseContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "6", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "7", + "kind": "constant", + "name": "GetResponseContentType2", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "8", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "9", + "kind": "constant", + "name": "getContentType1", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "10", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "11", + "kind": "constant", + "name": "GetResponseContentType3", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "12", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "13", + "kind": "constant", + "name": "GetResponseContentType4", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "14", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "15", + "kind": "constant", + "name": "GetResponseContentType5", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "16", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "17", + "kind": "constant", + "name": "getContentType2", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "18", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "19", + "kind": "constant", + "name": "GetResponseContentType6", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "20", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "21", + "kind": "constant", + "name": "GetResponseContentType7", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "22", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "23", + "kind": "constant", + "name": "GetResponseContentType8", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "24", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "25", + "kind": "constant", + "name": "getContentType3", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "26", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "27", + "kind": "constant", + "name": "GetResponseContentType9", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "28", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "29", + "kind": "constant", + "name": "GetResponseContentType10", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "30", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "31", + "kind": "constant", + "name": "GetResponseContentType11", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "32", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "33", + "kind": "constant", + "name": "getContentType4", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "34", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "35", + "kind": "constant", + "name": "GetResponseContentType12", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "36", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "37", + "kind": "constant", + "name": "GetResponseContentType13", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "38", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "39", + "kind": "constant", + "name": "GetResponseContentType14", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "40", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "41", + "kind": "constant", + "name": "getContentType5", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "42", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "43", + "kind": "constant", + "name": "GetResponseContentType15", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "44", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "45", + "kind": "constant", + "name": "GetResponseContentType16", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "46", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "47", + "kind": "constant", + "name": "GetResponseContentType17", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "48", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "49", + "kind": "constant", + "name": "getContentType6", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "50", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "51", + "kind": "constant", + "name": "GetResponseContentType18", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "52", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "53", + "kind": "constant", + "name": "GetResponseContentType19", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "54", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "55", + "kind": "constant", + "name": "GetResponseContentType20", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "56", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "57", + "kind": "constant", + "name": "getContentType7", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "58", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "59", + "kind": "constant", + "name": "GetResponseContentType21", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "60", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "61", + "kind": "constant", + "name": "GetResponseContentType22", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "62", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "63", + "kind": "constant", + "name": "GetResponseContentType23", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "64", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "65", + "kind": "constant", + "name": "getContentType8", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "66", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "67", + "kind": "constant", + "name": "GetResponseContentType24", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "68", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "69", + "kind": "constant", + "name": "GetResponseContentType25", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "70", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "71", + "kind": "constant", + "name": "GetResponseContentType26", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "72", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "73", + "kind": "constant", + "name": "getContentType9", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "74", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "75", + "kind": "constant", + "name": "GetResponseContentType27", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "76", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "77", + "kind": "constant", + "name": "GetResponseContentType28", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "78", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "79", + "kind": "constant", + "name": "GetResponseContentType29", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "80", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "81", + "kind": "constant", + "name": "getContentType10", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "82", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "83", + "kind": "constant", + "name": "GetResponseContentType30", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "84", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "85", + "kind": "constant", + "name": "GetResponseContentType31", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "86", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "87", + "kind": "constant", + "name": "GetResponseContentType32", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "88", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "89", + "kind": "constant", + "name": "getContentType11", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "90", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "91", + "kind": "constant", + "name": "GetResponseContentType33", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "92", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "93", + "kind": "constant", + "name": "GetResponseContentType34", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "94", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + }, + { + "$id": "95", + "kind": "constant", + "name": "GetResponseContentType35", + "namespace": "", + "usage": "None", + "valueType": { + "$id": "96", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/xml", + "decorators": [] + } + ], + "models": [ + { + "$id": "97", + "kind": "model", + "name": "SimpleModel", + "namespace": "Payload.Xml", + "crossLanguageDefinitionId": "Payload.Xml.SimpleModel", + "usage": "Input,Output,Xml", + "doc": "Contains fields of primitive types.", + "decorators": [], + "serializationOptions": { + "xml": { + "name": "SimpleModel", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "98", + "kind": "property", + "name": "name", + "serializedName": "name", + "type": { + "$id": "99", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.SimpleModel.name", + "serializationOptions": { + "xml": { + "name": "name", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "100", + "kind": "property", + "name": "age", + "serializedName": "age", + "type": { + "$id": "101", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.SimpleModel.age", + "serializationOptions": { + "xml": { + "name": "age", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "102", + "kind": "model", + "name": "ModelWithSimpleArrays", + "namespace": "Payload.Xml", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArrays", + "usage": "Input,Output,Xml", + "doc": "Contains fields of arrays of primitive types.", + "decorators": [], + "serializationOptions": { + "xml": { + "name": "ModelWithSimpleArrays", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "103", + "kind": "property", + "name": "colors", + "serializedName": "colors", + "type": { + "$id": "104", + "kind": "array", + "name": "Array", + "valueType": { + "$id": "105", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArrays.colors", + "serializationOptions": { + "xml": { + "name": "colors", + "attribute": false, + "unwrapped": false, + "itemsName": "string" + } + }, + "isHttpMetadata": false + }, + { + "$id": "106", + "kind": "property", + "name": "counts", + "serializedName": "counts", + "type": { + "$id": "107", + "kind": "array", + "name": "Array1", + "valueType": { + "$id": "108", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArrays.counts", + "serializationOptions": { + "xml": { + "name": "counts", + "attribute": false, + "unwrapped": false, + "itemsName": "int32" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "109", + "kind": "model", + "name": "ModelWithArrayOfModel", + "namespace": "Payload.Xml", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModel", + "usage": "Input,Output,Xml", + "doc": "Contains an array of models.", + "decorators": [], + "serializationOptions": { + "xml": { + "name": "ModelWithArrayOfModel", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "110", + "kind": "property", + "name": "items", + "serializedName": "items", + "type": { + "$id": "111", + "kind": "array", + "name": "ArraySimpleModel", + "valueType": { + "$ref": "97" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModel.items", + "serializationOptions": { + "xml": { + "name": "items", + "attribute": false, + "unwrapped": false, + "itemsName": "SimpleModel" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "112", + "kind": "model", + "name": "ModelWithOptionalField", + "namespace": "Payload.Xml", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalField", + "usage": "Input,Output,Xml", + "doc": "Contains an optional field.", + "decorators": [], + "serializationOptions": { + "xml": { + "name": "ModelWithOptionalField", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "113", + "kind": "property", + "name": "item", + "serializedName": "item", + "type": { + "$id": "114", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalField.item", + "serializationOptions": { + "xml": { + "name": "item", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "115", + "kind": "property", + "name": "value", + "serializedName": "value", + "type": { + "$id": "116", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalField.value", + "serializationOptions": { + "xml": { + "name": "value", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "117", + "kind": "model", + "name": "ModelWithAttributes", + "namespace": "Payload.Xml", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributes", + "usage": "Input,Output,Xml", + "doc": "Contains fields that are XML attributes.", + "decorators": [], + "serializationOptions": { + "xml": { + "name": "ModelWithAttributes", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "118", + "kind": "property", + "name": "id1", + "serializedName": "id1", + "type": { + "$id": "119", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@attribute", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributes.id1", + "serializationOptions": { + "xml": { + "name": "id1", + "attribute": true, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "120", + "kind": "property", + "name": "id2", + "serializedName": "id2", + "type": { + "$id": "121", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@attribute", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributes.id2", + "serializationOptions": { + "xml": { + "name": "id2", + "attribute": true, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "122", + "kind": "property", + "name": "enabled", + "serializedName": "enabled", + "type": { + "$id": "123", + "kind": "boolean", + "name": "boolean", + "crossLanguageDefinitionId": "TypeSpec.boolean", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributes.enabled", + "serializationOptions": { + "xml": { + "name": "enabled", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "124", + "kind": "model", + "name": "ModelWithUnwrappedArray", + "namespace": "Payload.Xml", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArray", + "usage": "Input,Output,Xml", + "doc": "Contains fields of wrapped and unwrapped arrays of primitive types.", + "decorators": [], + "serializationOptions": { + "xml": { + "name": "ModelWithUnwrappedArray", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "125", + "kind": "property", + "name": "colors", + "serializedName": "colors", + "type": { + "$ref": "104" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@unwrapped", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArray.colors", + "serializationOptions": { + "xml": { + "name": "colors", + "attribute": false, + "unwrapped": true, + "itemsName": "colors" + } + }, + "isHttpMetadata": false + }, + { + "$id": "126", + "kind": "property", + "name": "counts", + "serializedName": "counts", + "type": { + "$ref": "107" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArray.counts", + "serializationOptions": { + "xml": { + "name": "counts", + "attribute": false, + "unwrapped": false, + "itemsName": "int32" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "127", + "kind": "model", + "name": "ModelWithRenamedArrays", + "namespace": "Payload.Xml", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArrays", + "usage": "Input,Output,Xml", + "doc": "Contains fields of wrapped and unwrapped arrays of primitive types that have different XML representations.", + "decorators": [], + "serializationOptions": { + "xml": { + "name": "ModelWithRenamedArrays", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "128", + "kind": "property", + "name": "colors", + "serializedName": "Colors", + "type": { + "$ref": "104" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@unwrapped", + "arguments": {} + }, + { + "name": "TypeSpec.Xml.@name", + "arguments": { + "name": "Colors" + } + } + ], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArrays.colors", + "serializationOptions": { + "xml": { + "name": "Colors", + "attribute": false, + "unwrapped": true, + "itemsName": "Colors" + } + }, + "isHttpMetadata": false + }, + { + "$id": "129", + "kind": "property", + "name": "counts", + "serializedName": "Counts", + "type": { + "$ref": "107" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@name", + "arguments": { + "name": "Counts" + } + } + ], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArrays.counts", + "serializationOptions": { + "xml": { + "name": "Counts", + "attribute": false, + "unwrapped": false, + "itemsName": "int32" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "130", + "kind": "model", + "name": "ModelWithRenamedFields", + "namespace": "Payload.Xml", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFields", + "usage": "Input,Output,Xml", + "doc": "Contains fields of the same type that have different XML representation.", + "decorators": [ + { + "name": "TypeSpec.Xml.@name", + "arguments": { + "name": "ModelWithRenamedFieldsSrc" + } + } + ], + "serializationOptions": { + "xml": { + "name": "ModelWithRenamedFieldsSrc", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "131", + "kind": "property", + "name": "inputData", + "serializedName": "InputData", + "type": { + "$ref": "97" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@name", + "arguments": { + "name": "InputData" + } + } + ], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFields.inputData", + "serializationOptions": { + "xml": { + "name": "InputData", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "132", + "kind": "property", + "name": "outputData", + "serializedName": "OutputData", + "type": { + "$ref": "97" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@name", + "arguments": { + "name": "OutputData" + } + } + ], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFields.outputData", + "serializationOptions": { + "xml": { + "name": "OutputData", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "133", + "kind": "model", + "name": "ModelWithEmptyArray", + "namespace": "Payload.Xml", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArray", + "usage": "Input,Output,Xml", + "doc": "Contains an array of models that's supposed to be sent/received as an empty XML element.", + "decorators": [], + "serializationOptions": { + "xml": { + "name": "ModelWithEmptyArray", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "134", + "kind": "property", + "name": "items", + "serializedName": "items", + "type": { + "$ref": "111" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArray.items", + "serializationOptions": { + "xml": { + "name": "items", + "attribute": false, + "unwrapped": false, + "itemsName": "SimpleModel" + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "135", + "kind": "model", + "name": "ModelWithText", + "namespace": "Payload.Xml", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithText", + "usage": "Input,Output,Xml", + "doc": "Contains an attribute and text.", + "decorators": [], + "serializationOptions": { + "xml": { + "name": "ModelWithText", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "136", + "kind": "property", + "name": "language", + "serializedName": "language", + "type": { + "$id": "137", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@attribute", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithText.language", + "serializationOptions": { + "xml": { + "name": "language", + "attribute": true, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "138", + "kind": "property", + "name": "content", + "serializedName": "content", + "type": { + "$id": "139", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [ + { + "name": "TypeSpec.Xml.@unwrapped", + "arguments": {} + } + ], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithText.content", + "serializationOptions": { + "xml": { + "name": "content", + "attribute": false, + "unwrapped": true + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "140", + "kind": "model", + "name": "ModelWithDictionary", + "namespace": "Payload.Xml", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionary", + "usage": "Input,Output,Xml", + "doc": "Contains a dictionary of key value pairs.", + "decorators": [], + "serializationOptions": { + "xml": { + "name": "ModelWithDictionary", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "141", + "kind": "property", + "name": "metadata", + "serializedName": "metadata", + "type": { + "$id": "142", + "kind": "dict", + "keyType": { + "$id": "143", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "valueType": { + "$id": "144", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionary.metadata", + "serializationOptions": { + "xml": { + "name": "metadata", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + } + ] + }, + { + "$id": "145", + "kind": "model", + "name": "ModelWithEncodedNames", + "namespace": "Payload.Xml", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNames", + "usage": "Input,Output,Xml", + "doc": "Uses encodedName instead of Xml.Name which is functionally equivalent.", + "decorators": [], + "serializationOptions": { + "xml": { + "name": "ModelWithEncodedNamesSrc", + "attribute": false, + "unwrapped": false + } + }, + "properties": [ + { + "$id": "146", + "kind": "property", + "name": "modelData", + "serializedName": "SimpleModelData", + "type": { + "$ref": "97" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNames.modelData", + "serializationOptions": { + "xml": { + "name": "SimpleModelData", + "attribute": false, + "unwrapped": false + } + }, + "isHttpMetadata": false + }, + { + "$id": "147", + "kind": "property", + "name": "colors", + "serializedName": "PossibleColors", + "type": { + "$ref": "104" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNames.colors", + "serializationOptions": { + "xml": { + "name": "PossibleColors", + "attribute": false, + "unwrapped": false, + "itemsName": "string" + } + }, + "isHttpMetadata": false + } + ] + } + ], + "clients": [ + { + "$id": "148", + "kind": "client", + "name": "XmlClient", + "namespace": "Payload.Xml", + "doc": "Sends and receives bodies in XML format.", + "methods": [], + "parameters": [ + { + "$id": "149", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "150", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "151", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.endpoint" + } + ], + "initializedBy": 1, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml", + "apiVersions": [], + "children": [ + { + "$id": "152", + "kind": "client", + "name": "SimpleModelValue", + "namespace": "Payload.Xml", + "doc": "Operations for the SimpleModel type.", + "methods": [ + { + "$id": "153", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "154", + "name": "get", + "resourceName": "SimpleModelValue", + "accessibility": "public", + "parameters": [ + { + "$id": "155", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "1" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "97" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "3" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/payload/xml/simpleModel", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.get", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "156", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "1" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "97" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.get" + }, + { + "$id": "157", + "kind": "basic", + "name": "put", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "158", + "name": "put", + "resourceName": "SimpleModelValue", + "accessibility": "public", + "parameters": [ + { + "$id": "159", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "5" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.put.contentType" + }, + { + "$id": "160", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "97" + }, + "isApiVersion": false, + "contentTypes": [ + "application/xml" + ], + "defaultContentType": "application/xml", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.put.input" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/payload/xml/simpleModel", + "requestMediaTypes": [ + "application/xml" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.put", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "161", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "7" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.put.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "162", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "97" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.put.input", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.put" + } + ], + "parameters": [ + { + "$id": "163", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "164", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "165", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.SimpleModelValue.endpoint" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.SimpleModelValue", + "apiVersions": [], + "parent": { + "$ref": "148" + }, + "isMultiServiceClient": false + }, + { + "$id": "166", + "kind": "client", + "name": "ModelWithSimpleArraysValue", + "namespace": "Payload.Xml", + "doc": "Operations for the ModelWithSimpleArrays type.", + "methods": [ + { + "$id": "167", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "168", + "name": "get", + "resourceName": "ModelWithSimpleArraysValue", + "accessibility": "public", + "parameters": [ + { + "$id": "169", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "9" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "102" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "11" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithSimpleArrays", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.get", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "170", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "9" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "102" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.get" + }, + { + "$id": "171", + "kind": "basic", + "name": "put", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "172", + "name": "put", + "resourceName": "ModelWithSimpleArraysValue", + "accessibility": "public", + "parameters": [ + { + "$id": "173", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "13" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.put.contentType" + }, + { + "$id": "174", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "102" + }, + "isApiVersion": false, + "contentTypes": [ + "application/xml" + ], + "defaultContentType": "application/xml", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.put.input" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithSimpleArrays", + "requestMediaTypes": [ + "application/xml" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.put", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "175", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "15" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.put.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "176", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "102" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.put.input", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.put" + } + ], + "parameters": [ + { + "$id": "177", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "178", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "179", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue.endpoint" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArraysValue", + "apiVersions": [], + "parent": { + "$ref": "148" + }, + "isMultiServiceClient": false + }, + { + "$id": "180", + "kind": "client", + "name": "ModelWithArrayOfModelValue", + "namespace": "Payload.Xml", + "doc": "Operations for the ModelWithArrayOfModel type.", + "methods": [ + { + "$id": "181", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "182", + "name": "get", + "resourceName": "ModelWithArrayOfModelValue", + "accessibility": "public", + "parameters": [ + { + "$id": "183", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "17" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "109" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "19" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithArrayOfModel", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.get", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "184", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "17" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "109" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.get" + }, + { + "$id": "185", + "kind": "basic", + "name": "put", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "186", + "name": "put", + "resourceName": "ModelWithArrayOfModelValue", + "accessibility": "public", + "parameters": [ + { + "$id": "187", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "21" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.put.contentType" + }, + { + "$id": "188", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "109" + }, + "isApiVersion": false, + "contentTypes": [ + "application/xml" + ], + "defaultContentType": "application/xml", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.put.input" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithArrayOfModel", + "requestMediaTypes": [ + "application/xml" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.put", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "189", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "23" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.put.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "190", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "109" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.put.input", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.put" + } + ], + "parameters": [ + { + "$id": "191", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "192", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "193", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue.endpoint" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModelValue", + "apiVersions": [], + "parent": { + "$ref": "148" + }, + "isMultiServiceClient": false + }, + { + "$id": "194", + "kind": "client", + "name": "ModelWithOptionalFieldValue", + "namespace": "Payload.Xml", + "doc": "Operations for the ModelWithOptionalField type.", + "methods": [ + { + "$id": "195", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "196", + "name": "get", + "resourceName": "ModelWithOptionalFieldValue", + "accessibility": "public", + "parameters": [ + { + "$id": "197", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "25" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "112" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "27" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithOptionalField", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.get", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "198", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "25" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "112" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.get" + }, + { + "$id": "199", + "kind": "basic", + "name": "put", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "200", + "name": "put", + "resourceName": "ModelWithOptionalFieldValue", + "accessibility": "public", + "parameters": [ + { + "$id": "201", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "29" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.put.contentType" + }, + { + "$id": "202", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "112" + }, + "isApiVersion": false, + "contentTypes": [ + "application/xml" + ], + "defaultContentType": "application/xml", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.put.input" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithOptionalField", + "requestMediaTypes": [ + "application/xml" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.put", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "203", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "31" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.put.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "204", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "112" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.put.input", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.put" + } + ], + "parameters": [ + { + "$id": "205", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "206", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "207", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue.endpoint" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalFieldValue", + "apiVersions": [], + "parent": { + "$ref": "148" + }, + "isMultiServiceClient": false + }, + { + "$id": "208", + "kind": "client", + "name": "ModelWithAttributesValue", + "namespace": "Payload.Xml", + "doc": "Operations for the ModelWithAttributes type.", + "methods": [ + { + "$id": "209", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "210", + "name": "get", + "resourceName": "ModelWithAttributesValue", + "accessibility": "public", + "parameters": [ + { + "$id": "211", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "33" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "117" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "35" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithAttributes", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.get", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "212", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "33" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "117" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.get" + }, + { + "$id": "213", + "kind": "basic", + "name": "put", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "214", + "name": "put", + "resourceName": "ModelWithAttributesValue", + "accessibility": "public", + "parameters": [ + { + "$id": "215", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "37" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.put.contentType" + }, + { + "$id": "216", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "117" + }, + "isApiVersion": false, + "contentTypes": [ + "application/xml" + ], + "defaultContentType": "application/xml", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.put.input" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithAttributes", + "requestMediaTypes": [ + "application/xml" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.put", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "217", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "39" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.put.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "218", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "117" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.put.input", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.put" + } + ], + "parameters": [ + { + "$id": "219", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "220", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "221", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue.endpoint" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributesValue", + "apiVersions": [], + "parent": { + "$ref": "148" + }, + "isMultiServiceClient": false + }, + { + "$id": "222", + "kind": "client", + "name": "ModelWithUnwrappedArrayValue", + "namespace": "Payload.Xml", + "doc": "Operations for the ModelWithUnwrappedArray type.", + "methods": [ + { + "$id": "223", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "224", + "name": "get", + "resourceName": "ModelWithUnwrappedArrayValue", + "accessibility": "public", + "parameters": [ + { + "$id": "225", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "41" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "124" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "43" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithUnwrappedArray", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.get", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "226", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "41" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "124" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.get" + }, + { + "$id": "227", + "kind": "basic", + "name": "put", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "228", + "name": "put", + "resourceName": "ModelWithUnwrappedArrayValue", + "accessibility": "public", + "parameters": [ + { + "$id": "229", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "45" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.put.contentType" + }, + { + "$id": "230", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "124" + }, + "isApiVersion": false, + "contentTypes": [ + "application/xml" + ], + "defaultContentType": "application/xml", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.put.input" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithUnwrappedArray", + "requestMediaTypes": [ + "application/xml" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.put", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "231", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "47" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.put.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "232", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "124" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.put.input", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.put" + } + ], + "parameters": [ + { + "$id": "233", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "234", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "235", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue.endpoint" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArrayValue", + "apiVersions": [], + "parent": { + "$ref": "148" + }, + "isMultiServiceClient": false + }, + { + "$id": "236", + "kind": "client", + "name": "ModelWithRenamedArraysValue", + "namespace": "Payload.Xml", + "doc": "Operations for the ModelWithRenamedArrays type.", + "methods": [ + { + "$id": "237", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "238", + "name": "get", + "resourceName": "ModelWithRenamedArraysValue", + "accessibility": "public", + "parameters": [ + { + "$id": "239", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "49" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "127" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "51" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithRenamedArrays", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.get", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "240", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "49" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "127" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.get" + }, + { + "$id": "241", + "kind": "basic", + "name": "put", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "242", + "name": "put", + "resourceName": "ModelWithRenamedArraysValue", + "accessibility": "public", + "parameters": [ + { + "$id": "243", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "53" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.put.contentType" + }, + { + "$id": "244", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "127" + }, + "isApiVersion": false, + "contentTypes": [ + "application/xml" + ], + "defaultContentType": "application/xml", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.put.input" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithRenamedArrays", + "requestMediaTypes": [ + "application/xml" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.put", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "245", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "55" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.put.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "246", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "127" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.put.input", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.put" + } + ], + "parameters": [ + { + "$id": "247", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "248", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "249", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue.endpoint" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedArraysValue", + "apiVersions": [], + "parent": { + "$ref": "148" + }, + "isMultiServiceClient": false + }, + { + "$id": "250", + "kind": "client", + "name": "ModelWithRenamedFieldsValue", + "namespace": "Payload.Xml", + "doc": "Operations for the ModelWithRenamedFields type.", + "methods": [ + { + "$id": "251", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "252", + "name": "get", + "resourceName": "ModelWithRenamedFieldsValue", + "accessibility": "public", + "parameters": [ + { + "$id": "253", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "57" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "130" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "59" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithRenamedFields", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.get", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "254", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "57" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "130" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.get" + }, + { + "$id": "255", + "kind": "basic", + "name": "put", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "256", + "name": "put", + "resourceName": "ModelWithRenamedFieldsValue", + "accessibility": "public", + "parameters": [ + { + "$id": "257", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "61" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.put.contentType" + }, + { + "$id": "258", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "130" + }, + "isApiVersion": false, + "contentTypes": [ + "application/xml" + ], + "defaultContentType": "application/xml", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.put.input" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithRenamedFields", + "requestMediaTypes": [ + "application/xml" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.put", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "259", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "63" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.put.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "260", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "130" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.put.input", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.put" + } + ], + "parameters": [ + { + "$id": "261", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "262", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "263", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue.endpoint" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithRenamedFieldsValue", + "apiVersions": [], + "parent": { + "$ref": "148" + }, + "isMultiServiceClient": false + }, + { + "$id": "264", + "kind": "client", + "name": "ModelWithEmptyArrayValue", + "namespace": "Payload.Xml", + "doc": "Operations for the ModelWithEmptyArray type.", + "methods": [ + { + "$id": "265", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "266", + "name": "get", + "resourceName": "ModelWithEmptyArrayValue", + "accessibility": "public", + "parameters": [ + { + "$id": "267", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "65" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "133" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "67" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithEmptyArray", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.get", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "268", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "65" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "133" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.get" + }, + { + "$id": "269", + "kind": "basic", + "name": "put", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "270", + "name": "put", + "resourceName": "ModelWithEmptyArrayValue", + "accessibility": "public", + "parameters": [ + { + "$id": "271", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "69" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.put.contentType" + }, + { + "$id": "272", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "133" + }, + "isApiVersion": false, + "contentTypes": [ + "application/xml" + ], + "defaultContentType": "application/xml", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.put.input" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithEmptyArray", + "requestMediaTypes": [ + "application/xml" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.put", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "273", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "71" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.put.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "274", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "133" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.put.input", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.put" + } + ], + "parameters": [ + { + "$id": "275", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "276", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "277", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue.endpoint" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArrayValue", + "apiVersions": [], + "parent": { + "$ref": "148" + }, + "isMultiServiceClient": false + }, + { + "$id": "278", + "kind": "client", + "name": "ModelWithTextValue", + "namespace": "Payload.Xml", + "doc": "Operations for the ModelWithText type.", + "methods": [ + { + "$id": "279", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "280", + "name": "get", + "resourceName": "ModelWithTextValue", + "accessibility": "public", + "parameters": [ + { + "$id": "281", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "73" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "135" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "75" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithText", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.get", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "282", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "73" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "135" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.get" + }, + { + "$id": "283", + "kind": "basic", + "name": "put", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "284", + "name": "put", + "resourceName": "ModelWithTextValue", + "accessibility": "public", + "parameters": [ + { + "$id": "285", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "77" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.put.contentType" + }, + { + "$id": "286", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "135" + }, + "isApiVersion": false, + "contentTypes": [ + "application/xml" + ], + "defaultContentType": "application/xml", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.put.input" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithText", + "requestMediaTypes": [ + "application/xml" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.put", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "287", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "79" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.put.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "288", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "135" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.put.input", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.put" + } + ], + "parameters": [ + { + "$id": "289", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "290", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "291", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue.endpoint" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithTextValue", + "apiVersions": [], + "parent": { + "$ref": "148" + }, + "isMultiServiceClient": false + }, + { + "$id": "292", + "kind": "client", + "name": "ModelWithDictionaryValue", + "namespace": "Payload.Xml", + "doc": "Operations for the ModelWithDictionary type.", + "methods": [ + { + "$id": "293", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "294", + "name": "get", + "resourceName": "ModelWithDictionaryValue", + "accessibility": "public", + "parameters": [ + { + "$id": "295", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "81" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "140" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "83" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithDictionary", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.get", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "296", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "81" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "140" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.get" + }, + { + "$id": "297", + "kind": "basic", + "name": "put", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "298", + "name": "put", + "resourceName": "ModelWithDictionaryValue", + "accessibility": "public", + "parameters": [ + { + "$id": "299", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "85" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.put.contentType" + }, + { + "$id": "300", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "140" + }, + "isApiVersion": false, + "contentTypes": [ + "application/xml" + ], + "defaultContentType": "application/xml", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.put.input" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithDictionary", + "requestMediaTypes": [ + "application/xml" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.put", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "301", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "87" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.put.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "302", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "140" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.put.input", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.put" + } + ], + "parameters": [ + { + "$id": "303", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "304", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "305", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue.endpoint" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionaryValue", + "apiVersions": [], + "parent": { + "$ref": "148" + }, + "isMultiServiceClient": false + }, + { + "$id": "306", + "kind": "client", + "name": "ModelWithEncodedNamesValue", + "namespace": "Payload.Xml", + "doc": "Operations for the ModelWithEncodedNames type.", + "methods": [ + { + "$id": "307", + "kind": "basic", + "name": "get", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "308", + "name": "get", + "resourceName": "ModelWithEncodedNamesValue", + "accessibility": "public", + "parameters": [ + { + "$id": "309", + "kind": "header", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "89" + }, + "isApiVersion": false, + "optional": false, + "isContentType": false, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.get.accept" + } + ], + "responses": [ + { + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "145" + }, + "headers": [ + { + "name": "contentType", + "nameInResponse": "content-type", + "type": { + "$ref": "91" + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/xml" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithEncodedNames", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.get", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "310", + "kind": "method", + "name": "accept", + "serializedName": "Accept", + "type": { + "$ref": "89" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.get.accept", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": { + "type": { + "$ref": "145" + } + }, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.get" + }, + { + "$id": "311", + "kind": "basic", + "name": "put", + "accessibility": "public", + "apiVersions": [], + "operation": { + "$id": "312", + "name": "put", + "resourceName": "ModelWithEncodedNamesValue", + "accessibility": "public", + "parameters": [ + { + "$id": "313", + "kind": "header", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "93" + }, + "isApiVersion": false, + "optional": false, + "isContentType": true, + "scope": "Constant", + "readOnly": false, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.put.contentType" + }, + { + "$id": "314", + "kind": "body", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "145" + }, + "isApiVersion": false, + "contentTypes": [ + "application/xml" + ], + "defaultContentType": "application/xml", + "optional": false, + "scope": "Method", + "decorators": [], + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.put.input" + } + ], + "responses": [ + { + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/payload/xml/modelWithEncodedNames", + "requestMediaTypes": [ + "application/xml" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.put", + "decorators": [], + "namespace": "Payload.Xml" + }, + "parameters": [ + { + "$id": "315", + "kind": "method", + "name": "contentType", + "serializedName": "Content-Type", + "type": { + "$ref": "95" + }, + "location": "Header", + "isApiVersion": false, + "optional": false, + "scope": "Constant", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.put.contentType", + "readOnly": false, + "access": "public", + "decorators": [] + }, + { + "$id": "316", + "kind": "method", + "name": "input", + "serializedName": "input", + "type": { + "$ref": "145" + }, + "location": "Body", + "isApiVersion": false, + "optional": false, + "scope": "Method", + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.put.input", + "readOnly": false, + "access": "public", + "decorators": [] + } + ], + "response": {}, + "isOverride": false, + "generateConvenient": true, + "generateProtocol": true, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.put" + } + ], + "parameters": [ + { + "$id": "317", + "kind": "endpoint", + "name": "endpoint", + "serializedName": "endpoint", + "doc": "Service host", + "type": { + "$id": "318", + "kind": "url", + "name": "endpoint", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "isApiVersion": false, + "optional": false, + "scope": "Client", + "isEndpoint": true, + "defaultValue": { + "type": { + "$id": "319", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "http://localhost:3000" + }, + "serverUrlTemplate": "{endpoint}", + "skipUrlEncoding": false, + "readOnly": false, + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue.endpoint" + } + ], + "initializedBy": 0, + "decorators": [], + "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNamesValue", + "apiVersions": [], + "parent": { + "$ref": "148" + }, + "isMultiServiceClient": false + } + ], + "isMultiServiceClient": false + } + ] +}