diff --git a/src/AutoRest.CSharp/Common/Generation/Writers/JsonCodeWriterExtensions.cs b/src/AutoRest.CSharp/Common/Generation/Writers/JsonCodeWriterExtensions.cs index 436a67ea195..de32b09680b 100644 --- a/src/AutoRest.CSharp/Common/Generation/Writers/JsonCodeWriterExtensions.cs +++ b/src/AutoRest.CSharp/Common/Generation/Writers/JsonCodeWriterExtensions.cs @@ -286,7 +286,7 @@ private static void ToSerializeCall(this CodeWriter writer, FormattableString wr private static void DeserializeIntoObjectProperties(this CodeWriter writer, IEnumerable propertySerializations, FormattableString itemVariable, Dictionary propertyVariables) { - foreach (JsonPropertySerialization property in propertySerializations) + foreach (JsonPropertySerialization property in propertySerializations.Where(p => !p.ShouldSkipDeserialization)) { writer.Append($"if({itemVariable}.NameEquals({property.SerializedName:L}u8))"); using (writer.Scope()) @@ -379,9 +379,9 @@ private static FormattableString GetOptionalFormattable(JsonPropertySerializatio } /// Collects a list of properties being read from all level of object hierarchy - private static void CollectProperties(Dictionary propertyVariables, IEnumerable jsonProperties) + private static void CollectPropertiesForDeserialization(Dictionary propertyVariables, IEnumerable jsonProperties) { - foreach (JsonPropertySerialization jsonProperty in jsonProperties) + foreach (JsonPropertySerialization jsonProperty in jsonProperties.Where(p => !p.ShouldSkipDeserialization)) { if (jsonProperty.ValueType != null) { @@ -399,7 +399,7 @@ private static void CollectProperties(Dictionary(); - CollectProperties(propertyVariables, serialization.Properties); + CollectPropertiesForDeserialization(propertyVariables, serialization.Properties); var additionalProperties = serialization.AdditionalProperties; if (additionalProperties != null) diff --git a/src/AutoRest.CSharp/Common/Generation/Writers/ModelWriter.cs b/src/AutoRest.CSharp/Common/Generation/Writers/ModelWriter.cs index 0dbb34867bd..0dea35edaea 100644 --- a/src/AutoRest.CSharp/Common/Generation/Writers/ModelWriter.cs +++ b/src/AutoRest.CSharp/Common/Generation/Writers/ModelWriter.cs @@ -309,7 +309,7 @@ protected virtual void AddCtorAttribute(CodeWriter writer, ObjectType schema, Ob { } - public void WriteConstructor(CodeWriter writer, ObjectType schema) + private void WriteConstructor(CodeWriter writer, ObjectType schema) { foreach (var constructor in schema.Constructors) { diff --git a/src/AutoRest.CSharp/Common/Input/CadlInputLiteralTypeConverter.cs b/src/AutoRest.CSharp/Common/Input/CadlInputLiteralTypeConverter.cs index 04d1ddb78d4..f57a2271f45 100644 --- a/src/AutoRest.CSharp/Common/Input/CadlInputLiteralTypeConverter.cs +++ b/src/AutoRest.CSharp/Common/Input/CadlInputLiteralTypeConverter.cs @@ -85,8 +85,8 @@ public static object ReadLiteralValue(ref Utf8JsonReader reader, string property Object? value = null; switch (type) { - case InputPrimitiveType primitype: - switch (primitype.Kind) + case InputPrimitiveType primitiveType: + switch (primitiveType.Kind) { case InputTypeKind.String: value = reader.GetString() ?? throw new JsonException(); @@ -94,19 +94,19 @@ public static object ReadLiteralValue(ref Utf8JsonReader reader, string property case InputTypeKind.Int32: value = reader.GetInt32(); break; - case InputTypeKind.Int64: - value = reader.GetInt64(); + case InputTypeKind.Float64: + value = reader.GetDouble(); break; case InputTypeKind.Boolean: value = reader.GetBoolean(); break; default: - throw new JsonException($"Not supported litreal type {primitype.Kind}."); + throw new JsonException($"Not supported literal type {primitiveType.Kind}."); } break; default: - throw new JsonException($"Not supported litreal type {type.Name}."); + throw new JsonException($"Not supported literal type {type.Name}."); } reader.Read(); return value; diff --git a/src/AutoRest.CSharp/Common/Input/CadlInputModelPropertyConverter.cs b/src/AutoRest.CSharp/Common/Input/CadlInputModelPropertyConverter.cs index 8916bf402a6..c2c81590fd4 100644 --- a/src/AutoRest.CSharp/Common/Input/CadlInputModelPropertyConverter.cs +++ b/src/AutoRest.CSharp/Common/Input/CadlInputModelPropertyConverter.cs @@ -55,7 +55,7 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read description = BuilderHelpers.EscapeXmlDocDescription(description); propertyType = propertyType ?? throw new JsonException($"{nameof(InputModelProperty)} must have a property type."); - var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, isRequired, isReadOnly, isDiscriminator); + var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, isRequired, isReadOnly, isDiscriminator, GetDefaultValue(propertyType)); if (id != null) { resolver.AddReference(id, property); @@ -63,5 +63,27 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read return property; } + + private static FormattableString? GetDefaultValue(InputType propertyType) + { + if (propertyType is not InputLiteralType literalType) + { + return null; + } + + return literalType.LiteralValueType switch + { + InputPrimitiveType primitiveType => primitiveType.Kind switch + { + InputTypeKind.Boolean => $"{literalType.Value.ToString()!.ToLower()}", + InputTypeKind.Float32 or InputTypeKind.Float64 or InputTypeKind.Float128 + or InputTypeKind.Int32 or InputTypeKind.Int64 => $"{literalType.Value.ToString()}", + InputTypeKind.String => $"\"{(literalType.Value).ToString()}\"", + _ => throw new Exception($"Unsupported literal value type: {primitiveType}"), + + }, + _ => throw new Exception($"Unsupported literal value type: {literalType.LiteralValueType}"), + }; + } } } diff --git a/src/AutoRest.CSharp/Common/Output/Builders/SerializationBuilder.cs b/src/AutoRest.CSharp/Common/Output/Builders/SerializationBuilder.cs index 4eb523fef7b..fd9417a8027 100644 --- a/src/AutoRest.CSharp/Common/Output/Builders/SerializationBuilder.cs +++ b/src/AutoRest.CSharp/Common/Output/Builders/SerializationBuilder.cs @@ -267,6 +267,7 @@ private IEnumerable GetPropertySerializationsFromBag( BuildSerialization(property.Schema, objectProperty.ValueType), property.IsRequired, property.IsReadOnly, + false, objectProperty.OptionalViaNullability); } diff --git a/src/AutoRest.CSharp/Common/Output/Models/RestClientBuilder.cs b/src/AutoRest.CSharp/Common/Output/Models/RestClientBuilder.cs index 3da12984b1f..c9e7700428c 100644 --- a/src/AutoRest.CSharp/Common/Output/Models/RestClientBuilder.cs +++ b/src/AutoRest.CSharp/Common/Output/Models/RestClientBuilder.cs @@ -351,7 +351,7 @@ private ReferenceOrConstant CreateReference(InputParameter operationParameter, P return (ReferenceOrConstant)_parameters[operationParameter.Name]; } - if (operationParameter.Kind == InputOperationParameterKind.Constant && parameter.DefaultValue != null) + if (operationParameter is { Kind:InputOperationParameterKind.Constant } && parameter.DefaultValue is not null) { return (ReferenceOrConstant)parameter.DefaultValue; } diff --git a/src/AutoRest.CSharp/Common/Output/Models/Serialization/Json/JsonAdditionalPropertiesSerialization.cs b/src/AutoRest.CSharp/Common/Output/Models/Serialization/Json/JsonAdditionalPropertiesSerialization.cs index 67d4a9bac9a..d52a40c24fc 100644 --- a/src/AutoRest.CSharp/Common/Output/Models/Serialization/Json/JsonAdditionalPropertiesSerialization.cs +++ b/src/AutoRest.CSharp/Common/Output/Models/Serialization/Json/JsonAdditionalPropertiesSerialization.cs @@ -12,7 +12,7 @@ internal class JsonAdditionalPropertiesSerialization : JsonPropertySerialization public CSharpType Type { get; } public JsonAdditionalPropertiesSerialization(ObjectTypeProperty property, JsonSerialization valueSerialization, CSharpType type) - : base(property.Declaration.Name.ToVariableName(), property.Declaration.Name, property.Declaration.Name, property.Declaration.Type, property.ValueType, valueSerialization, true, property.IsReadOnly, property.OptionalViaNullability) + : base(property.Declaration.Name.ToVariableName(), property.Declaration.Name, property.Declaration.Name, property.Declaration.Type, property.ValueType, valueSerialization, true, property.IsReadOnly, false, property.OptionalViaNullability) { Type = type; } diff --git a/src/AutoRest.CSharp/Common/Output/Models/Serialization/Json/JsonPropertySerialization.cs b/src/AutoRest.CSharp/Common/Output/Models/Serialization/Json/JsonPropertySerialization.cs index d24ce41db18..d988f2bf943 100644 --- a/src/AutoRest.CSharp/Common/Output/Models/Serialization/Json/JsonPropertySerialization.cs +++ b/src/AutoRest.CSharp/Common/Output/Models/Serialization/Json/JsonPropertySerialization.cs @@ -8,8 +8,8 @@ namespace AutoRest.CSharp.Output.Models.Serialization.Json { internal class JsonPropertySerialization : PropertySerialization { - public JsonPropertySerialization(string parameterName, string propertyName, string serializedName, CSharpType propertyType, CSharpType? valueType, JsonSerialization valueSerialization, bool isRequired, bool shouldSkipSerialization, bool optionalViaNullability) - : base(propertyName, serializedName, propertyType, valueType, isRequired, shouldSkipSerialization) + public JsonPropertySerialization(string parameterName, string propertyName, string serializedName, CSharpType propertyType, CSharpType? valueType, JsonSerialization valueSerialization, bool isRequired, bool shouldSkipSerialization, bool shouldSkipDeserialization, bool optionalViaNullability) + : base(propertyName, serializedName, propertyType, valueType, isRequired, shouldSkipSerialization, shouldSkipDeserialization) { ParameterName = parameterName; OptionalViaNullability = optionalViaNullability; diff --git a/src/AutoRest.CSharp/Common/Output/Models/Serialization/PropertySerialization.cs b/src/AutoRest.CSharp/Common/Output/Models/Serialization/PropertySerialization.cs index 2e821833eaa..6bb5a4e6ac3 100644 --- a/src/AutoRest.CSharp/Common/Output/Models/Serialization/PropertySerialization.cs +++ b/src/AutoRest.CSharp/Common/Output/Models/Serialization/PropertySerialization.cs @@ -13,8 +13,14 @@ internal abstract class PropertySerialization public CSharpType? ValueType { get; } public bool IsRequired { get; } public bool ShouldSkipSerialization { get; } + public bool ShouldSkipDeserialization { get; } - protected PropertySerialization(string propertyName, string serializedName, CSharpType propertyType, CSharpType? valueType, bool isRequired, bool shouldSkipSerialization) + protected PropertySerialization(string propertyName, string serializedName, CSharpType propertyType, CSharpType? valueType, bool isRequired, bool shouldSkipSerialization) : + this(propertyName, serializedName, propertyType, valueType, isRequired, shouldSkipSerialization, false) + { + } + + protected PropertySerialization(string propertyName, string serializedName, CSharpType propertyType, CSharpType? valueType, bool isRequired, bool shouldSkipSerialization, bool shouldSkipDeserialization) { PropertyName = propertyName; SerializedName = serializedName; @@ -22,6 +28,7 @@ protected PropertySerialization(string propertyName, string serializedName, CSha ValueType = valueType; IsRequired = isRequired; ShouldSkipSerialization = shouldSkipSerialization; + ShouldSkipDeserialization = shouldSkipDeserialization; } } } diff --git a/src/AutoRest.CSharp/Common/Output/Models/Types/ModelTypeProvider.cs b/src/AutoRest.CSharp/Common/Output/Models/Types/ModelTypeProvider.cs index fc64bf3616b..d3adf957618 100644 --- a/src/AutoRest.CSharp/Common/Output/Models/Types/ModelTypeProvider.cs +++ b/src/AutoRest.CSharp/Common/Output/Models/Types/ModelTypeProvider.cs @@ -147,6 +147,7 @@ private IEnumerable CreatePropertySerializations() valueSerialization, property.IsRequired, shouldSkipSerialization, + ShouldSkipDeserialization(property), optionalViaNullability)); } } @@ -160,6 +161,11 @@ private bool ShouldSkipSerialization(ObjectTypeProperty property) return false; } + if (property.InputModelProperty.Type is InputLiteralType) + { + return false; + } + if (property.InputModelProperty!.IsReadOnly) { return true; @@ -173,6 +179,8 @@ private bool ShouldSkipSerialization(ObjectTypeProperty property) return property.IsReadOnly && _inputModel.Usage is not InputModelTypeUsage.Input; } + private bool ShouldSkipDeserialization(ObjectTypeProperty property) => property.InputModelProperty?.Type is InputLiteralType; + private ConstructorSignature? CreateSerializationConstructorSignature(string name, IReadOnlyList publicParameters, IReadOnlyList serializationParameters) { if (!serializationParameters.Any(p => TypeFactory.IsList(p.Type)) && publicParameters.SequenceEqual(serializationParameters)) diff --git a/src/AutoRest.CSharp/Common/Output/Models/Types/ModelTypeProviderFields.cs b/src/AutoRest.CSharp/Common/Output/Models/Types/ModelTypeProviderFields.cs index 1bd9dba5125..ec80dde7375 100644 --- a/src/AutoRest.CSharp/Common/Output/Models/Types/ModelTypeProviderFields.cs +++ b/src/AutoRest.CSharp/Common/Output/Models/Types/ModelTypeProviderFields.cs @@ -64,6 +64,10 @@ public ModelTypeProviderFields(InputModelType inputModel, TypeFactory typeFactor fields.Add(field); fieldsToInputs[field] = inputModelProperty; + if (inputModelProperty.Type is InputLiteralType) + { + continue; // literal property does not show up in the constructor parameter list + } var parameter = Parameter.FromModelProperty(inputModelProperty, existingMember is IFieldSymbol ? inputModelProperty.Name.ToVariableName() : field.Name.FirstCharToLowerCase(), field.Type); parametersToFields[parameter.Name] = field; serializationParameters.Add(parameter); @@ -95,9 +99,10 @@ private static FieldDeclaration CreateField(string fieldName, CSharpType fieldTy inputModelProperty.Type is CodeModelType type && (type.Schema is ArraySchema or DictionarySchema); var propertyIsRequiredInNonRoundTripModel = inputModel.Usage is InputModelTypeUsage.Input or InputModelTypeUsage.Output && inputModelProperty.IsRequired; var propertyIsOptionalInOutputModel = inputModel.Usage is InputModelTypeUsage.Output && !inputModelProperty.IsRequired; - var propertyIsReadOnly = inputModelProperty.IsReadOnly || propertyIsCollection || propertyIsRequiredInNonRoundTripModel || propertyIsOptionalInOutputModel; + var propertyIsLiteralType = inputModelProperty.Type is InputLiteralType; + var propertyIsReadOnly = inputModelProperty.IsReadOnly || propertyIsLiteralType || propertyIsCollection || propertyIsRequiredInNonRoundTripModel || propertyIsOptionalInOutputModel; - var fieldModifiers = propertyIsReadOnly ? Public | ReadOnly : Public; + var fieldModifiers = propertyIsReadOnly ? (propertyIsLiteralType ? Internal : Public ) | ReadOnly : Public; CodeWriterDeclaration declaration = new CodeWriterDeclaration(fieldName); declaration.SetActualName(fieldName); diff --git a/src/AutoRest.CSharp/Common/Output/Models/Types/ObjectTypeProperty.cs b/src/AutoRest.CSharp/Common/Output/Models/Types/ObjectTypeProperty.cs index 0aab3f3dd91..3949aef6c4d 100644 --- a/src/AutoRest.CSharp/Common/Output/Models/Types/ObjectTypeProperty.cs +++ b/src/AutoRest.CSharp/Common/Output/Models/Types/ObjectTypeProperty.cs @@ -20,7 +20,8 @@ public ObjectTypeProperty(FieldDeclaration field, InputModelProperty inputModelP : this(new MemberDeclarationOptions(field.Accessibility, field.Name, field.Type), field.Description?.ToString() ?? String.Empty, field.Modifiers.HasFlag(FieldModifiers.ReadOnly), null, field.IsRequired, inputModelProperty: inputModelProperty) { // now the default value will be set only when the model is generated from property bag - if (enclosingType is ModelTypeProvider model && model.IsPropertyBag) + if ((enclosingType is ModelTypeProvider model && model.IsPropertyBag) || + (inputModelProperty.Type is InputLiteralType)) // or the property is a literal type { DefaultValue = field.DefaultValue; } diff --git a/src/AutoRest.CSharp/LowLevel/Output/OperationMethodChainBuilder.cs b/src/AutoRest.CSharp/LowLevel/Output/OperationMethodChainBuilder.cs index 1be2794ee11..10a0f5aa0f5 100644 --- a/src/AutoRest.CSharp/LowLevel/Output/OperationMethodChainBuilder.cs +++ b/src/AutoRest.CSharp/LowLevel/Output/OperationMethodChainBuilder.cs @@ -436,9 +436,9 @@ private void AddReference(string nameInRequest, InputParameter? operationParamet _requestParts.Add(new RequestPartSource(nameInRequest, operationParameter, reference, serializationFormat)); } - private ReferenceOrConstant CreateReference(InputParameter? operationParameter, Parameter parameter) + private ReferenceOrConstant CreateReference(InputParameter operationParameter, Parameter parameter) { - if (operationParameter?.Kind == InputOperationParameterKind.Client) + if (operationParameter.Kind == InputOperationParameterKind.Client) { var field = operationParameter.IsEndpoint ? _fields.EndpointField : _fields.GetFieldByParameter(parameter); if (field == null) @@ -449,7 +449,7 @@ private ReferenceOrConstant CreateReference(InputParameter? operationParameter, return new Reference(field.Name, field.Type); } - if (operationParameter?.Kind == InputOperationParameterKind.Constant && parameter.DefaultValue != null) + if (operationParameter.Kind is InputOperationParameterKind.Constant && parameter.DefaultValue is not null) { return (ReferenceOrConstant)parameter.DefaultValue; } diff --git a/src/CADL.Extension/Emitter.Csharp/src/emitter.ts b/src/CADL.Extension/Emitter.Csharp/src/emitter.ts index 79ef28d759c..89d038cbae7 100644 --- a/src/CADL.Extension/Emitter.Csharp/src/emitter.ts +++ b/src/CADL.Extension/Emitter.Csharp/src/emitter.ts @@ -846,13 +846,14 @@ function loadOperation( const isContentType: boolean = requestLocation === RequestLocation.Header && name.toLowerCase() === "content-type"; - const kind: InputOperationParameterKind = isContentType - ? InputOperationParameterKind.Constant - : isApiVer - ? defaultValue + const kind: InputOperationParameterKind = + isContentType || inputType.Name === "Literal" ? InputOperationParameterKind.Constant - : InputOperationParameterKind.Client - : InputOperationParameterKind.Method; + : isApiVer + ? defaultValue + ? InputOperationParameterKind.Constant + : InputOperationParameterKind.Client + : InputOperationParameterKind.Method; return { Name: param.name, NameInRequest: name, diff --git a/src/CADL.Extension/Emitter.Csharp/src/lib/model.ts b/src/CADL.Extension/Emitter.Csharp/src/lib/model.ts index ec4be252ea6..3b0663d00a4 100644 --- a/src/CADL.Extension/Emitter.Csharp/src/lib/model.ts +++ b/src/CADL.Extension/Emitter.Csharp/src/lib/model.ts @@ -70,7 +70,13 @@ export function mapCadlTypeToCSharpInputTypeKind( case "Enum": return InputTypeKind.Enum; case "Number": - return InputTypeKind.Int32; + let nubmerValue = cadlType.value; + if (nubmerValue % 1 === 0) { + return InputTypeKind.Int32; + } + return InputTypeKind.Float64; + case "Boolean": + return InputTypeKind.Boolean; case "String": if (format === "date") return InputTypeKind.DateTime; if (format === "uri") return InputTypeKind.Uri; diff --git a/test/CadlRanchMockApis/src/FirstTest-Cadl.ts b/test/CadlRanchMockApis/src/FirstTest-Cadl.ts new file mode 100644 index 00000000000..9d7a4bf9d30 --- /dev/null +++ b/test/CadlRanchMockApis/src/FirstTest-Cadl.ts @@ -0,0 +1,41 @@ +import { passOnSuccess, ScenarioMockApi, mockapi, json } from "@azure-tools/cadl-ranch-api"; + +/** + * Test mock server for `FirstTest-cadl` test project. + */ +export const Scenarios: Record = {}; + +Scenarios.FirstTestCadl_CreateLiteral = passOnSuccess([ + mockapi.post("/literal", (req) => { + req.expect.bodyEquals({ + name: "test", + requiredUnion: "test", + requiredBadDescription: "abc", + requiredLiteralString: "accept", + requiredLiteralInt: 123, + requiredLiteralDouble: 1.23, + requiredLiteralBool: false, + optionalLiteralString: "reject", + optionalLiteralInt: 456, + optionalLiteralDouble: 4.56, + optionalLiteralBool: true, + }); + return { + status: 200, + body: json({ + name: "literal", + requiredUnion: "union", + requiredBadDescription: "def", + // below are useless + requiredLiteralString: "reject", + requiredLiteralInt: 12345, + requiredLiteralDouble: 123.45, + requiredLiteralBool: true, + optionalLiteralString: "accept", + optionalLiteralInt: 12345, + optionalLiteralDouble: 123.45, + optionalLiteralBool: false, + }) + }; + }), +]); diff --git a/test/CadlRanchProjects.Tests/LiteralValueTypeTests.cs b/test/CadlRanchProjects.Tests/LiteralValueTypeTests.cs new file mode 100644 index 00000000000..92d24bb2018 --- /dev/null +++ b/test/CadlRanchProjects.Tests/LiteralValueTypeTests.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using AutoRest.TestServer.Tests.Infrastructure; +using NUnit.Framework; +using CadlFirstTest.Models; +using CadlFirstTest; +using System.Threading.Tasks; + +namespace CadlRanchProjects.Tests +{ + /// + /// E2E tests for literal value types. + /// + public class LiteralValueTypeTests : CadlRanchMockApiTestBase + { + [Test] + public async Task LiteralModelProperties() => await Test(async (host) => + { + Thing result = await new CadlFirstTestClient(host).CreateLiteralAsync(new Thing("test", "test", "abc")); + Assert.AreEqual(result.Name, "literal"); + Assert.AreEqual(result.RequiredUnion, "union"); + Assert.AreEqual(result.RequiredBadDescription, "def"); + // the following are stick to literal value, despite the mock server returns different value + Assert.AreEqual(result.RequiredLiteralString, "accept"); + Assert.AreEqual(result.RequiredLiteralInt, 123); + Assert.AreEqual(result.RequiredLiteralDouble, 1.23); + Assert.AreEqual(result.RequiredLiteralBool, false); + Assert.AreEqual(result.OptionalLiteralString, "reject"); + Assert.AreEqual(result.OptionalLiteralInt, 456); + Assert.AreEqual(result.OptionalLiteralDouble, 4.56); + Assert.AreEqual(result.OptionalLiteralBool, true); + }); + + } + +} diff --git a/test/TestProjects/FirstTest-Cadl/Customization/CadlFirstTestClient.cs b/test/TestProjects/FirstTest-Cadl/Customization/CadlFirstTestClient.cs new file mode 100644 index 00000000000..fbe1c465bea --- /dev/null +++ b/test/TestProjects/FirstTest-Cadl/Customization/CadlFirstTestClient.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace CadlFirstTest +{ + + public partial class CadlFirstTestClient + { + /// + /// Constructor for testing purpose. Bearer token check policy is removed. + /// + /// + public CadlFirstTestClient(Uri endpoint) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + var options = new CadlFirstTestClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + } +} diff --git a/test/TestProjects/FirstTest-Cadl/FirstTest-Cadl.cadl b/test/TestProjects/FirstTest-Cadl/FirstTest-Cadl.cadl index 22e763aada9..1466e669aea 100644 --- a/test/TestProjects/FirstTest-Cadl/FirstTest-Cadl.cadl +++ b/test/TestProjects/FirstTest-Cadl/FirstTest-Cadl.cadl @@ -3,10 +3,20 @@ import "@cadl-lang/openapi"; import "@azure-tools/cadl-dpg"; import "@azure-tools/cadl-azure-core"; -@serviceTitle("Hello world") -@serviceVersion("0.1.0") +@service( + { + title: "hello world", + version: "0.1.0" + } +) @doc("This is a sample cadl project.") -@server("http://localhost:300","Endpoint Service") +@server( + "{firstTestCadlUrl}", + "Endpoint Service", + { + firstTestCadlUrl: string, + } +) @useAuth(OAuth2Auth<[AuthFlow]> | ApiKeyAuth) @Cadl.Rest.produces("application/json") @Cadl.Rest.consumes("application/json") @@ -43,10 +53,34 @@ enum ExtensibleEnum { model Thing { @doc("name of the Thing") name: string; + @doc("required Union") requiredUnion: string | string[]|int32; - @doc("required literal type") - requiredLiteral: "accept"; + + @doc("required literal string") + requiredLiteralString: "accept"; + + @doc("required literal int") + requiredLiteralInt: 123; + + @doc("required literal double") + requiredLiteralDouble: 1.23; + + @doc("required literal bool") + requiredLiteralBool: false; + + @doc("optional literal string") + optionalLiteralString?: "reject"; + + @doc("optional literal int") + optionalLiteralInt?: 456; + + @doc("optional literal double") + optionalLiteralDouble?: 4.56; + + @doc("optional literal bool") + optionalLiteralBool?: true; + @doc("description with xml <|endoftext|>") requiredBadDescription: string } @@ -109,6 +143,18 @@ namespace Hello.Demo2 { @doc("Return hi in demo2") @get op helloDemo2(): Thing; + + @route("/literal") + @convenienceAPI + @doc("Create with literal value") + @post + op createLiteral(@body body: Thing): Thing; + + @route("/helloLiteral") + @convenienceAPI + @doc("Send literal parameters") + @get + op helloLiteral(@header p1: "test", @path p2: 123, @query p3: true): Thing; } @route("/top") diff --git a/test/TestProjects/FirstTest-Cadl/Generated/CadlFirstTestClient.cs b/test/TestProjects/FirstTest-Cadl/Generated/CadlFirstTestClient.cs index 9710a1e28f7..4db0af25651 100644 --- a/test/TestProjects/FirstTest-Cadl/Generated/CadlFirstTestClient.cs +++ b/test/TestProjects/FirstTest-Cadl/Generated/CadlFirstTestClient.cs @@ -39,28 +39,30 @@ protected CadlFirstTestClient() } /// Initializes a new instance of CadlFirstTestClient. + /// The Uri to use. /// A credential used to authenticate to an Azure Service. - /// is null. - public CadlFirstTestClient(AzureKeyCredential credential) : this(credential, new Uri("http://localhost:300"), new CadlFirstTestClientOptions()) + /// or is null. + public CadlFirstTestClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new CadlFirstTestClientOptions()) { } /// Initializes a new instance of CadlFirstTestClient. + /// The Uri to use. /// A credential used to authenticate to an Azure Service. - /// is null. - public CadlFirstTestClient(TokenCredential credential) : this(credential, new Uri("http://localhost:300"), new CadlFirstTestClientOptions()) + /// or is null. + public CadlFirstTestClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new CadlFirstTestClientOptions()) { } /// Initializes a new instance of CadlFirstTestClient. + /// The Uri to use. /// A credential used to authenticate to an Azure Service. - /// Endpoint Service. /// The options for configuring the client. - /// or is null. - public CadlFirstTestClient(AzureKeyCredential credential, Uri endpoint, CadlFirstTestClientOptions options) + /// or is null. + public CadlFirstTestClient(Uri endpoint, AzureKeyCredential credential, CadlFirstTestClientOptions options) { - Argument.AssertNotNull(credential, nameof(credential)); Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); options ??= new CadlFirstTestClientOptions(); ClientDiagnostics = new ClientDiagnostics(options, true); @@ -71,14 +73,14 @@ public CadlFirstTestClient(AzureKeyCredential credential, Uri endpoint, CadlFirs } /// Initializes a new instance of CadlFirstTestClient. + /// The Uri to use. /// A credential used to authenticate to an Azure Service. - /// Endpoint Service. /// The options for configuring the client. - /// or is null. - public CadlFirstTestClient(TokenCredential credential, Uri endpoint, CadlFirstTestClientOptions options) + /// or is null. + public CadlFirstTestClient(Uri endpoint, TokenCredential credential, CadlFirstTestClientOptions options) { - Argument.AssertNotNull(credential, nameof(credential)); Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); options ??= new CadlFirstTestClientOptions(); ClientDiagnostics = new ClientDiagnostics(options, true); @@ -766,6 +768,162 @@ public virtual Response HelloDemo2(RequestContext context = null) } } + /// Create with literal value. + /// The Thing to use. + /// The cancellation token to use. + /// is null. + public virtual async Task> CreateLiteralAsync(Thing body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateLiteralAsync(body.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(Thing.FromResponse(response), response); + } + + /// Create with literal value. + /// The Thing to use. + /// The cancellation token to use. + /// is null. + public virtual Response CreateLiteral(Thing body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateLiteral(body.ToRequestContent(), context); + return Response.FromValue(Thing.FromResponse(response), response); + } + + /// Create with literal value. + /// The content to send as the body of the request. Details of the request body schema are in the Remarks section below. + /// The request context, 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. Details of the response body schema are in the Remarks section below. + /// + public virtual async Task CreateLiteralAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("CadlFirstTestClient.CreateLiteral"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateLiteralRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create with literal value. + /// The content to send as the body of the request. Details of the request body schema are in the Remarks section below. + /// The request context, 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. Details of the response body schema are in the Remarks section below. + /// + public virtual Response CreateLiteral(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("CadlFirstTestClient.CreateLiteral"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateLiteralRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Send literal parameters. + /// The cancellation token to use. + public virtual async Task> HelloLiteralValueAsync(CancellationToken cancellationToken = default) + { + using var scope = ClientDiagnostics.CreateScope("CadlFirstTestClient.HelloLiteralValue"); + scope.Start(); + try + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await HelloLiteralAsync(context).ConfigureAwait(false); + return Response.FromValue(Thing.FromResponse(response), response); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Send literal parameters. + /// The cancellation token to use. + public virtual Response HelloLiteralValue(CancellationToken cancellationToken = default) + { + using var scope = ClientDiagnostics.CreateScope("CadlFirstTestClient.HelloLiteralValue"); + scope.Start(); + try + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = HelloLiteral(context); + return Response.FromValue(Thing.FromResponse(response), response); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Send literal parameters. + /// The request context, 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. Details of the response body schema are in the Remarks section below. + /// + public virtual async Task HelloLiteralAsync(RequestContext context = null) + { + using var scope = ClientDiagnostics.CreateScope("CadlFirstTestClient.HelloLiteral"); + scope.Start(); + try + { + using HttpMessage message = CreateHelloLiteralRequest(context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Send literal parameters. + /// The request context, 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. Details of the response body schema are in the Remarks section below. + /// + public virtual Response HelloLiteral(RequestContext context = null) + { + using var scope = ClientDiagnostics.CreateScope("CadlFirstTestClient.HelloLiteral"); + scope.Start(); + try + { + using HttpMessage message = CreateHelloLiteralRequest(context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + /// get extensible enum. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// Service returned a non-success status code. @@ -1129,6 +1287,39 @@ internal HttpMessage CreateHelloDemo2Request(RequestContext context) return message; } + internal HttpMessage CreateCreateLiteralRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/literal", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateHelloLiteralRequest(RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/helloLiteral/", false); + uri.AppendPath(123, true); + uri.AppendQuery("p3", true, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("p1", "test"); + request.Headers.Add("Accept", "application/json"); + return message; + } + internal HttpMessage CreateGetUnknownValueRequest(RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); diff --git a/test/TestProjects/FirstTest-Cadl/Generated/Docs/CadlFirstTestClient.xml b/test/TestProjects/FirstTest-Cadl/Generated/Docs/CadlFirstTestClient.xml index 31eb68d102a..e10bf630118 100644 --- a/test/TestProjects/FirstTest-Cadl/Generated/Docs/CadlFirstTestClient.xml +++ b/test/TestProjects/FirstTest-Cadl/Generated/Docs/CadlFirstTestClient.xml @@ -6,14 +6,22 @@ This sample shows how to call TopActionAsync with required parameters and parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = await client.TopActionAsync(""); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -26,7 +34,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -38,14 +53,22 @@ Schema for Thing: This sample shows how to call TopAction with required parameters and parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = client.TopAction(""); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -58,7 +81,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -70,14 +100,22 @@ Schema for Thing: This sample shows how to call TopAction2Async and parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = await client.TopAction2Async(); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -90,7 +128,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -102,14 +147,22 @@ Schema for Thing: This sample shows how to call TopAction2 and parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = client.TopAction2(); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -122,7 +175,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -131,15 +191,19 @@ Schema for Thing: -This sample shows how to call PatchActionAsync with required request content and parse the result. +This sample shows how to call PatchActionAsync with required request content, and how to parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); var data = new { name = "", requiredUnion = new {}, - requiredLiteral = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, requiredBadDescription = "", }; @@ -148,7 +212,45 @@ Response response = await client.PatchActionAsync(RequestContent.Create(data)); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> +This sample shows how to call PatchActionAsync with all request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + optionalLiteralString = new {}, + optionalLiteralInt = new {}, + optionalLiteralDouble = new {}, + optionalLiteralBool = new {}, + requiredBadDescription = "", +}; + +Response response = await client.PatchActionAsync(RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -161,7 +263,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -172,7 +281,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -181,15 +297,50 @@ Schema for Thing: -This sample shows how to call PatchAction with required request content and parse the result. +This sample shows how to call PatchAction with required request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + requiredBadDescription = "", +}; + +Response response = client.PatchAction(RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> +This sample shows how to call PatchAction with all request content, and how to parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); var data = new { name = "", requiredUnion = new {}, - requiredLiteral = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + optionalLiteralString = new {}, + optionalLiteralInt = new {}, + optionalLiteralDouble = new {}, + optionalLiteralBool = new {}, requiredBadDescription = "", }; @@ -198,7 +349,14 @@ Response response = client.PatchAction(RequestContent.Create(data)); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -211,7 +369,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -222,7 +387,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -231,15 +403,50 @@ Schema for Thing: -This sample shows how to call AnonymousBodyAsync with required request content and parse the result. +This sample shows how to call AnonymousBodyAsync with required request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + requiredBadDescription = "", +}; + +Response response = await client.AnonymousBodyAsync(RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> +This sample shows how to call AnonymousBodyAsync with all request content, and how to parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); var data = new { name = "", requiredUnion = new {}, - requiredLiteral = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + optionalLiteralString = new {}, + optionalLiteralInt = new {}, + optionalLiteralDouble = new {}, + optionalLiteralBool = new {}, requiredBadDescription = "", }; @@ -248,7 +455,14 @@ Response response = await client.AnonymousBodyAsync(RequestContent.Create(data)) JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -261,7 +475,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -272,7 +493,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -281,15 +509,19 @@ Schema for Thing: -This sample shows how to call AnonymousBody with required request content and parse the result. +This sample shows how to call AnonymousBody with required request content, and how to parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); var data = new { name = "", requiredUnion = new {}, - requiredLiteral = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, requiredBadDescription = "", }; @@ -298,7 +530,45 @@ Response response = client.AnonymousBody(RequestContent.Create(data)); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> +This sample shows how to call AnonymousBody with all request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + optionalLiteralString = new {}, + optionalLiteralInt = new {}, + optionalLiteralDouble = new {}, + optionalLiteralBool = new {}, + requiredBadDescription = "", +}; + +Response response = client.AnonymousBody(RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -311,7 +581,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -322,7 +599,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -334,7 +618,8 @@ Schema for Thing: This sample shows how to call FriendlyModelAsync with required request content and parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); var data = new { name = "", @@ -372,7 +657,8 @@ Schema for Friend: This sample shows how to call FriendlyModel with required request content and parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); var data = new { name = "", @@ -410,7 +696,8 @@ Schema for Friend: This sample shows how to call AddTimeHeaderAsync. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = await client.AddTimeHeaderAsync(); Console.WriteLine(response.Status); @@ -418,7 +705,8 @@ Console.WriteLine(response.Status); This sample shows how to call AddTimeHeaderAsync with all parameters. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = await client.AddTimeHeaderAsync(DateTimeOffset.UtcNow); Console.WriteLine(response.Status); @@ -430,7 +718,8 @@ Console.WriteLine(response.Status); This sample shows how to call AddTimeHeader. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = client.AddTimeHeader(); Console.WriteLine(response.Status); @@ -438,7 +727,8 @@ Console.WriteLine(response.Status); This sample shows how to call AddTimeHeader with all parameters. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = client.AddTimeHeader(DateTimeOffset.UtcNow); Console.WriteLine(response.Status); @@ -450,27 +740,39 @@ Console.WriteLine(response.Status); This sample shows how to call SayHiAsync with required parameters and parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = await client.SayHiAsync("", ""); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> This sample shows how to call SayHiAsync with all parameters, and how to parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = await client.SayHiAsync("", "", ""); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -483,7 +785,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -495,27 +804,39 @@ Schema for Thing: This sample shows how to call SayHi with required parameters and parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = client.SayHi("", ""); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> This sample shows how to call SayHi with all parameters, and how to parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = client.SayHi("", "", ""); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -528,7 +849,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -537,10 +865,48 @@ Schema for Thing: -This sample shows how to call HelloAgainAsync with required parameters and request content and parse the result. +This sample shows how to call HelloAgainAsync with required parameters and request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + requiredString = "", + requiredInt = 1234, + requiredCollection = new[] { + "1" + }, + requiredDictionary = new { + key = "1", + }, + requiredModel = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + requiredBadDescription = "", + }, +}; + +Response response = await client.HelloAgainAsync("", "", RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> +This sample shows how to call HelloAgainAsync with all parameters and request content, and how to parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); var data = new { requiredString = "", @@ -554,7 +920,14 @@ var data = new { requiredModel = new { name = "", requiredUnion = new {}, - requiredLiteral = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + optionalLiteralString = new {}, + optionalLiteralInt = new {}, + optionalLiteralDouble = new {}, + optionalLiteralBool = new {}, requiredBadDescription = "", }, }; @@ -564,7 +937,14 @@ Response response = await client.HelloAgainAsync("", "", RequestContent. JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -582,7 +962,14 @@ Schema for RoundTripModel: requiredModel: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; }, # Required. Required model } @@ -594,7 +981,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -603,10 +997,11 @@ Schema for Thing: -This sample shows how to call HelloAgain with required parameters and request content and parse the result. +This sample shows how to call HelloAgain with required parameters and request content, and how to parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); var data = new { requiredString = "", @@ -620,7 +1015,10 @@ var data = new { requiredModel = new { name = "", requiredUnion = new {}, - requiredLiteral = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, requiredBadDescription = "", }, }; @@ -630,7 +1028,55 @@ Response response = client.HelloAgain("", "", RequestContent.Create(data JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> +This sample shows how to call HelloAgain with all parameters and request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + requiredString = "", + requiredInt = 1234, + requiredCollection = new[] { + "1" + }, + requiredDictionary = new { + key = "1", + }, + requiredModel = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + optionalLiteralString = new {}, + optionalLiteralInt = new {}, + optionalLiteralDouble = new {}, + optionalLiteralBool = new {}, + requiredBadDescription = "", + }, +}; + +Response response = client.HelloAgain("", "", RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -648,7 +1094,14 @@ Schema for RoundTripModel: requiredModel: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; }, # Required. Required model } @@ -660,7 +1113,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -669,10 +1129,11 @@ Schema for Thing: -This sample shows how to call NoContentTypeAsync with required parameters and request content and parse the result. +This sample shows how to call NoContentTypeAsync with required parameters and request content, and how to parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); var data = new { requiredString = "", @@ -686,7 +1147,10 @@ var data = new { requiredModel = new { name = "", requiredUnion = new {}, - requiredLiteral = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, requiredBadDescription = "", }, }; @@ -696,7 +1160,55 @@ Response response = await client.NoContentTypeAsync("", "", RequestConte JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> +This sample shows how to call NoContentTypeAsync with all parameters and request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + requiredString = "", + requiredInt = 1234, + requiredCollection = new[] { + "1" + }, + requiredDictionary = new { + key = "1", + }, + requiredModel = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + optionalLiteralString = new {}, + optionalLiteralInt = new {}, + optionalLiteralDouble = new {}, + optionalLiteralBool = new {}, + requiredBadDescription = "", + }, +}; + +Response response = await client.NoContentTypeAsync("", "", RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -714,7 +1226,14 @@ Schema for RoundTripModel: requiredModel: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; }, # Required. Required model } @@ -726,7 +1245,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -735,10 +1261,11 @@ Schema for Thing: -This sample shows how to call NoContentType with required parameters and request content and parse the result. +This sample shows how to call NoContentType with required parameters and request content, and how to parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); var data = new { requiredString = "", @@ -752,7 +1279,10 @@ var data = new { requiredModel = new { name = "", requiredUnion = new {}, - requiredLiteral = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, requiredBadDescription = "", }, }; @@ -762,7 +1292,55 @@ Response response = client.NoContentType("", "", RequestContent.Create(d JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> +This sample shows how to call NoContentType with all parameters and request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + requiredString = "", + requiredInt = 1234, + requiredCollection = new[] { + "1" + }, + requiredDictionary = new { + key = "1", + }, + requiredModel = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + optionalLiteralString = new {}, + optionalLiteralInt = new {}, + optionalLiteralDouble = new {}, + optionalLiteralBool = new {}, + requiredBadDescription = "", + }, +}; + +Response response = client.NoContentType("", "", RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -780,7 +1358,14 @@ Schema for RoundTripModel: requiredModel: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; }, # Required. Required model } @@ -792,7 +1377,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -804,14 +1396,22 @@ Schema for Thing: This sample shows how to call HelloDemo2Async and parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = await client.HelloDemo2Async(); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -824,7 +1424,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -836,14 +1443,281 @@ Schema for Thing: This sample shows how to call HelloDemo2 and parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = client.HelloDemo2(); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> + + +Below is the JSON schema for the response payload. + +Response Body: + +Schema for Thing: +{ + name: string, # Required. name of the Thing + requiredUnion: Union, # Required. required Union + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool + requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; +} + + + + + + +This sample shows how to call CreateLiteralAsync with required request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + requiredBadDescription = "", +}; + +Response response = await client.CreateLiteralAsync(RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> +This sample shows how to call CreateLiteralAsync with all request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + optionalLiteralString = new {}, + optionalLiteralInt = new {}, + optionalLiteralDouble = new {}, + optionalLiteralBool = new {}, + requiredBadDescription = "", +}; + +Response response = await client.CreateLiteralAsync(RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> + + +Below is the JSON schema for the request and response payloads. + +Request Body: + +Schema for Thing: +{ + name: string, # Required. name of the Thing + requiredUnion: Union, # Required. required Union + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool + requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; +} + + +Response Body: + +Schema for Thing: +{ + name: string, # Required. name of the Thing + requiredUnion: Union, # Required. required Union + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool + requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; +} + + + + + + +This sample shows how to call CreateLiteral with required request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + requiredBadDescription = "", +}; + +Response response = client.CreateLiteral(RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> +This sample shows how to call CreateLiteral with all request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + optionalLiteralString = new {}, + optionalLiteralInt = new {}, + optionalLiteralDouble = new {}, + optionalLiteralBool = new {}, + requiredBadDescription = "", +}; + +Response response = client.CreateLiteral(RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> + + +Below is the JSON schema for the request and response payloads. + +Request Body: + +Schema for Thing: +{ + name: string, # Required. name of the Thing + requiredUnion: Union, # Required. required Union + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool + requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; +} + + +Response Body: + +Schema for Thing: +{ + name: string, # Required. name of the Thing + requiredUnion: Union, # Required. required Union + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool + requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; +} + + + + + + +This sample shows how to call HelloLiteralAsync and parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +Response response = await client.HelloLiteralAsync(); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -856,7 +1730,61 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool + requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; +} + + + + + + +This sample shows how to call HelloLiteral and parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +Response response = client.HelloLiteral(); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> + + +Below is the JSON schema for the response payload. + +Response Body: + +Schema for Thing: +{ + name: string, # Required. name of the Thing + requiredUnion: Union, # Required. required Union + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -868,7 +1796,8 @@ Schema for Thing: This sample shows how to call GetUnknownValueAsync and parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = await client.GetUnknownValueAsync(); @@ -882,7 +1811,8 @@ Console.WriteLine(result.ToString()); This sample shows how to call GetUnknownValue and parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = client.GetUnknownValue(); @@ -893,15 +1823,19 @@ Console.WriteLine(result.ToString()); -This sample shows how to call InternalProtocolAsync with required request content and parse the result. +This sample shows how to call InternalProtocolAsync with required request content, and how to parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); var data = new { name = "", requiredUnion = new {}, - requiredLiteral = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, requiredBadDescription = "", }; @@ -910,7 +1844,45 @@ Response response = await client.InternalProtocolAsync(RequestContent.Create(dat JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> +This sample shows how to call InternalProtocolAsync with all request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + optionalLiteralString = new {}, + optionalLiteralInt = new {}, + optionalLiteralDouble = new {}, + optionalLiteralBool = new {}, + requiredBadDescription = "", +}; + +Response response = await client.InternalProtocolAsync(RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -923,7 +1895,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -934,7 +1913,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -943,15 +1929,50 @@ Schema for Thing: -This sample shows how to call InternalProtocol with required request content and parse the result. +This sample shows how to call InternalProtocol with required request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); + +var data = new { + name = "", + requiredUnion = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + requiredBadDescription = "", +}; + +Response response = client.InternalProtocol(RequestContent.Create(data)); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("requiredUnion").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); +]]> +This sample shows how to call InternalProtocol with all request content, and how to parse the result. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); var data = new { name = "", requiredUnion = new {}, - requiredLiteral = new {}, + requiredLiteralString = new {}, + requiredLiteralInt = new {}, + requiredLiteralDouble = new {}, + requiredLiteralBool = new {}, + optionalLiteralString = new {}, + optionalLiteralInt = new {}, + optionalLiteralDouble = new {}, + optionalLiteralBool = new {}, requiredBadDescription = "", }; @@ -960,7 +1981,14 @@ Response response = client.InternalProtocol(RequestContent.Create(data)); JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; Console.WriteLine(result.GetProperty("name").ToString()); Console.WriteLine(result.GetProperty("requiredUnion").ToString()); -Console.WriteLine(result.GetProperty("requiredLiteral").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralString").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("requiredLiteralBool").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralString").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralInt").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralDouble").ToString()); +Console.WriteLine(result.GetProperty("optionalLiteralBool").ToString()); Console.WriteLine(result.GetProperty("requiredBadDescription").ToString()); ]]> @@ -973,7 +2001,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -984,7 +2019,14 @@ Schema for Thing: { name: string, # Required. name of the Thing requiredUnion: Union, # Required. required Union - requiredLiteral: Literal, # Required. required literal type + requiredLiteralString: Literal, # Required. required literal string + requiredLiteralInt: Literal, # Required. required literal int + requiredLiteralDouble: Literal, # Required. required literal double + requiredLiteralBool: Literal, # Required. required literal bool + optionalLiteralString: Literal, # Optional. optional literal string + optionalLiteralInt: Literal, # Optional. optional literal int + optionalLiteralDouble: Literal, # Optional. optional literal double + optionalLiteralBool: Literal, # Optional. optional literal bool requiredBadDescription: string, # Required. description with xml &lt;|endoftext|&gt; } @@ -996,7 +2038,8 @@ Schema for Thing: This sample shows how to call StillConvenientAsync. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = await client.StillConvenientAsync(); Console.WriteLine(response.Status); @@ -1008,7 +2051,8 @@ Console.WriteLine(response.Status); This sample shows how to call StillConvenient. "); -var client = new CadlFirstTestClient(credential); +var endpoint = new Uri(""); +var client = new CadlFirstTestClient(endpoint, credential); Response response = client.StillConvenient(); Console.WriteLine(response.Status); diff --git a/test/TestProjects/FirstTest-Cadl/Generated/Models/Thing.Serialization.cs b/test/TestProjects/FirstTest-Cadl/Generated/Models/Thing.Serialization.cs index e0e45ac8d4c..4f3d9ac4b74 100644 --- a/test/TestProjects/FirstTest-Cadl/Generated/Models/Thing.Serialization.cs +++ b/test/TestProjects/FirstTest-Cadl/Generated/Models/Thing.Serialization.cs @@ -20,8 +20,55 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStringValue(Name); writer.WritePropertyName("requiredUnion"u8); writer.WriteStringValue(RequiredUnion); - writer.WritePropertyName("requiredLiteral"u8); - writer.WriteStringValue(RequiredLiteral); + writer.WritePropertyName("requiredLiteralString"u8); + writer.WriteStringValue(RequiredLiteralString); + writer.WritePropertyName("requiredLiteralInt"u8); + writer.WriteNumberValue(RequiredLiteralInt); + writer.WritePropertyName("requiredLiteralDouble"u8); + writer.WriteNumberValue(RequiredLiteralDouble); + writer.WritePropertyName("requiredLiteralBool"u8); + writer.WriteBooleanValue(RequiredLiteralBool); + if (Optional.IsDefined(OptionalLiteralString)) + { + writer.WritePropertyName("optionalLiteralString"u8); + writer.WriteStringValue(OptionalLiteralString); + } + if (Optional.IsDefined(OptionalLiteralInt)) + { + if (OptionalLiteralInt != null) + { + writer.WritePropertyName("optionalLiteralInt"u8); + writer.WriteNumberValue(OptionalLiteralInt.Value); + } + else + { + writer.WriteNull("optionalLiteralInt"); + } + } + if (Optional.IsDefined(OptionalLiteralDouble)) + { + if (OptionalLiteralDouble != null) + { + writer.WritePropertyName("optionalLiteralDouble"u8); + writer.WriteNumberValue(OptionalLiteralDouble.Value); + } + else + { + writer.WriteNull("optionalLiteralDouble"); + } + } + if (Optional.IsDefined(OptionalLiteralBool)) + { + if (OptionalLiteralBool != null) + { + writer.WritePropertyName("optionalLiteralBool"u8); + writer.WriteBooleanValue(OptionalLiteralBool.Value); + } + else + { + writer.WriteNull("optionalLiteralBool"); + } + } writer.WritePropertyName("requiredBadDescription"u8); writer.WriteStringValue(RequiredBadDescription); writer.WriteEndObject(); @@ -31,7 +78,6 @@ internal static Thing DeserializeThing(JsonElement element) { string name = default; string requiredUnion = default; - string requiredLiteral = default; string requiredBadDescription = default; foreach (var property in element.EnumerateObject()) { @@ -45,18 +91,13 @@ internal static Thing DeserializeThing(JsonElement element) requiredUnion = property.Value.GetString(); continue; } - if (property.NameEquals("requiredLiteral"u8)) - { - requiredLiteral = property.Value.GetString(); - continue; - } if (property.NameEquals("requiredBadDescription"u8)) { requiredBadDescription = property.Value.GetString(); continue; } } - return new Thing(name, requiredUnion, requiredLiteral, requiredBadDescription); + return new Thing(name, requiredUnion, requiredBadDescription); } /// Deserializes the model from a raw response. diff --git a/test/TestProjects/FirstTest-Cadl/Generated/Models/Thing.cs b/test/TestProjects/FirstTest-Cadl/Generated/Models/Thing.cs index cc19ba54af2..e997022c02f 100644 --- a/test/TestProjects/FirstTest-Cadl/Generated/Models/Thing.cs +++ b/test/TestProjects/FirstTest-Cadl/Generated/Models/Thing.cs @@ -16,19 +16,16 @@ public partial class Thing /// Initializes a new instance of Thing. /// name of the Thing. /// required Union. - /// required literal type. /// description with xml <|endoftext|>. - /// , , or is null. - public Thing(string name, string requiredUnion, string requiredLiteral, string requiredBadDescription) + /// , or is null. + public Thing(string name, string requiredUnion, string requiredBadDescription) { Argument.AssertNotNull(name, nameof(name)); Argument.AssertNotNull(requiredUnion, nameof(requiredUnion)); - Argument.AssertNotNull(requiredLiteral, nameof(requiredLiteral)); Argument.AssertNotNull(requiredBadDescription, nameof(requiredBadDescription)); Name = name; RequiredUnion = requiredUnion; - RequiredLiteral = requiredLiteral; RequiredBadDescription = requiredBadDescription; } @@ -36,8 +33,30 @@ public Thing(string name, string requiredUnion, string requiredLiteral, string r public string Name { get; set; } /// required Union. public string RequiredUnion { get; set; } - /// required literal type. - public string RequiredLiteral { get; set; } + /// required literal string. + internal string RequiredLiteralString { get; } = "accept"; + + /// required literal int. + internal int RequiredLiteralInt { get; } = 123; + + /// required literal double. + internal double RequiredLiteralDouble { get; } = 1.23; + + /// required literal bool. + internal bool RequiredLiteralBool { get; } = false; + + /// optional literal string. + internal string OptionalLiteralString { get; } = "reject"; + + /// optional literal int. + internal int? OptionalLiteralInt { get; } = 456; + + /// optional literal double. + internal double? OptionalLiteralDouble { get; } = 4.56; + + /// optional literal bool. + internal bool? OptionalLiteralBool { get; } = true; + /// description with xml <|endoftext|>. public string RequiredBadDescription { get; set; } } diff --git a/test/TestProjects/FirstTest-Cadl/Generated/cadl.json b/test/TestProjects/FirstTest-Cadl/Generated/cadl.json index 51c06509f5a..56ebc7ab9f6 100644 --- a/test/TestProjects/FirstTest-Cadl/Generated/cadl.json +++ b/test/TestProjects/FirstTest-Cadl/Generated/cadl.json @@ -172,9 +172,9 @@ }, { "$id": "27", - "Name": "requiredLiteral", - "SerializedName": "requiredLiteral", - "Description": "required literal type", + "Name": "requiredLiteralString", + "SerializedName": "requiredLiteralString", + "Description": "required literal string", "Type": { "$id": "28", "Name": "Literal", @@ -193,11 +193,158 @@ }, { "$id": "30", + "Name": "requiredLiteralInt", + "SerializedName": "requiredLiteralInt", + "Description": "required literal int", + "Type": { + "$id": "31", + "Name": "Literal", + "LiteralValueType": { + "$id": "32", + "Name": "Number", + "Kind": "Int32", + "IsNullable": false + }, + "Value": 123, + "IsNullable": false + }, + "IsRequired": true, + "IsReadOnly": false, + "IsDiscriminator": false + }, + { + "$id": "33", + "Name": "requiredLiteralDouble", + "SerializedName": "requiredLiteralDouble", + "Description": "required literal double", + "Type": { + "$id": "34", + "Name": "Literal", + "LiteralValueType": { + "$id": "35", + "Name": "Number", + "Kind": "Float64", + "IsNullable": false + }, + "Value": 1.23, + "IsNullable": false + }, + "IsRequired": true, + "IsReadOnly": false, + "IsDiscriminator": false + }, + { + "$id": "36", + "Name": "requiredLiteralBool", + "SerializedName": "requiredLiteralBool", + "Description": "required literal bool", + "Type": { + "$id": "37", + "Name": "Literal", + "LiteralValueType": { + "$id": "38", + "Name": "Boolean", + "Kind": "Boolean", + "IsNullable": false + }, + "Value": false, + "IsNullable": false + }, + "IsRequired": true, + "IsReadOnly": false, + "IsDiscriminator": false + }, + { + "$id": "39", + "Name": "optionalLiteralString", + "SerializedName": "optionalLiteralString", + "Description": "optional literal string", + "Type": { + "$id": "40", + "Name": "Literal", + "LiteralValueType": { + "$id": "41", + "Name": "String", + "Kind": "String", + "IsNullable": false + }, + "Value": "reject", + "IsNullable": false + }, + "IsRequired": false, + "IsReadOnly": false, + "IsDiscriminator": false + }, + { + "$id": "42", + "Name": "optionalLiteralInt", + "SerializedName": "optionalLiteralInt", + "Description": "optional literal int", + "Type": { + "$id": "43", + "Name": "Literal", + "LiteralValueType": { + "$id": "44", + "Name": "Number", + "Kind": "Int32", + "IsNullable": false + }, + "Value": 456, + "IsNullable": false + }, + "IsRequired": false, + "IsReadOnly": false, + "IsDiscriminator": false + }, + { + "$id": "45", + "Name": "optionalLiteralDouble", + "SerializedName": "optionalLiteralDouble", + "Description": "optional literal double", + "Type": { + "$id": "46", + "Name": "Literal", + "LiteralValueType": { + "$id": "47", + "Name": "Number", + "Kind": "Float64", + "IsNullable": false + }, + "Value": 4.56, + "IsNullable": false + }, + "IsRequired": false, + "IsReadOnly": false, + "IsDiscriminator": false + }, + { + "$id": "48", + "Name": "optionalLiteralBool", + "SerializedName": "optionalLiteralBool", + "Description": "optional literal bool", + "Type": { + "$id": "49", + "Name": "Literal", + "LiteralValueType": { + "$id": "50", + "Name": "Boolean", + "Kind": "Boolean", + "IsNullable": false + }, + "Value": true, + "IsNullable": false + }, + "IsRequired": false, + "IsReadOnly": false, + "IsDiscriminator": false + }, + { + "$id": "51", "Name": "requiredBadDescription", "SerializedName": "requiredBadDescription", "Description": "description with xml <|endoftext|>", "Type": { - "$id": "31", + "$id": "52", "Name": "string", "Kind": "String", "IsNullable": false @@ -209,19 +356,19 @@ ] }, { - "$id": "32", + "$id": "53", "Name": "Friend", "Namespace": "CadlFirstTest", "IsNullable": false, "Usage": "RoundTrip", "Properties": [ { - "$id": "33", + "$id": "54", "Name": "name", "SerializedName": "name", "Description": "name of the NotFriend", "Type": { - "$id": "34", + "$id": "55", "Name": "string", "Kind": "String", "IsNullable": false @@ -233,19 +380,19 @@ ] }, { - "$id": "35", + "$id": "56", "Name": "RoundTripModel", "Namespace": "CadlFirstTest", "IsNullable": false, "Usage": "Input", "Properties": [ { - "$id": "36", + "$id": "57", "Name": "requiredString", "SerializedName": "requiredString", "Description": "Required string, illustrating a reference type property.", "Type": { - "$id": "37", + "$id": "58", "Name": "string", "Kind": "String", "IsNullable": false @@ -255,12 +402,12 @@ "IsDiscriminator": false }, { - "$id": "38", + "$id": "59", "Name": "requiredInt", "SerializedName": "requiredInt", "Description": "Required int, illustrating a value type property.", "Type": { - "$id": "39", + "$id": "60", "Name": "int32", "Kind": "Int32", "IsNullable": false @@ -270,12 +417,12 @@ "IsDiscriminator": false }, { - "$id": "40", + "$id": "61", "Name": "requiredCollection", "SerializedName": "requiredCollection", "Description": "Required collection of enums", "Type": { - "$id": "41", + "$id": "62", "Name": "Array", "ElementType": { "$ref": "2" @@ -287,15 +434,15 @@ "IsDiscriminator": false }, { - "$id": "42", + "$id": "63", "Name": "requiredDictionary", "SerializedName": "requiredDictionary", "Description": "Required dictionary of enums", "Type": { - "$id": "43", + "$id": "64", "Name": "Dictionary", "KeyType": { - "$id": "44", + "$id": "65", "Name": "string", "Kind": "String", "IsNullable": false @@ -310,7 +457,7 @@ "IsDiscriminator": false }, { - "$id": "45", + "$id": "66", "Name": "requiredModel", "SerializedName": "requiredModel", "Description": "Required model", @@ -326,25 +473,24 @@ ], "Clients": [ { - "$id": "46", + "$id": "67", "Name": "CadlFirstTestClient", "Description": "This is a sample cadl project.", "Operations": [ { - "$id": "47", + "$id": "68", "Name": "topAction", "ResourceName": "CadlFirstTest", "Description": "top level method", "Parameters": [ { - "$id": "48", - "Name": "host", - "NameInRequest": "host", - "Description": "Endpoint Service", + "$id": "69", + "Name": "firstTestCadlUrl", + "NameInRequest": "firstTestCadlUrl", "Type": { - "$id": "49", - "Name": "String", - "Kind": "String", + "$id": "70", + "Name": "Uri", + "Kind": "Uri", "IsNullable": false }, "Location": "Uri", @@ -355,24 +501,14 @@ "IsEndpoint": true, "SkipUrlEncoding": false, "Explode": false, - "Kind": "Client", - "DefaultValue": { - "$id": "50", - "Type": { - "$id": "51", - "Name": "String", - "Kind": "String", - "IsNullable": false - }, - "Value": "http://localhost:300" - } + "Kind": "Client" }, { - "$id": "52", + "$id": "71", "Name": "action", "NameInRequest": "action", "Type": { - "$id": "53", + "$id": "72", "Name": "string", "Kind": "String", "IsNullable": false @@ -388,11 +524,11 @@ "Kind": "Method" }, { - "$id": "54", + "$id": "73", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "55", + "$id": "74", "Name": "String", "Kind": "String", "IsNullable": false @@ -407,20 +543,20 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "56", + "$id": "75", "Type": { - "$ref": "55" + "$ref": "74" }, "Value": "application/json" } }, { - "$id": "57", + "$id": "76", "Name": "apiVersion", "NameInRequest": "api-version", "Description": "", "Type": { - "$id": "58", + "$id": "77", "Name": "String", "Kind": "String", "IsNullable": false @@ -435,9 +571,9 @@ "Explode": false, "Kind": "Client", "DefaultValue": { - "$id": "59", + "$id": "78", "Type": { - "$id": "60", + "$id": "79", "Name": "String", "Kind": "String", "IsNullable": false @@ -448,7 +584,7 @@ ], "Responses": [ { - "$id": "61", + "$id": "80", "StatusCodes": [ 200 ], @@ -462,27 +598,27 @@ ], "HttpMethod": "GET", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/top/{action}", "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true }, { - "$id": "62", + "$id": "81", "Name": "topAction2", "ResourceName": "CadlFirstTest", "Description": "top level method2", "Parameters": [ { - "$ref": "48" + "$ref": "69" }, { - "$id": "63", + "$id": "82", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "64", + "$id": "83", "Name": "String", "Kind": "String", "IsNullable": false @@ -497,20 +633,20 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "65", + "$id": "84", "Type": { - "$ref": "64" + "$ref": "83" }, "Value": "application/json" } }, { - "$ref": "57" + "$ref": "76" } ], "Responses": [ { - "$id": "66", + "$id": "85", "StatusCodes": [ 200 ], @@ -524,23 +660,23 @@ ], "HttpMethod": "GET", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/top2", "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": false }, { - "$id": "67", + "$id": "86", "Name": "patchAction", "ResourceName": "CadlFirstTest", "Description": "top level patch", "Parameters": [ { - "$ref": "48" + "$ref": "69" }, { - "$id": "68", + "$id": "87", "Name": "body", "NameInRequest": "body", "Type": { @@ -557,11 +693,11 @@ "Kind": "Method" }, { - "$id": "69", + "$id": "88", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "70", + "$id": "89", "Name": "String", "Kind": "String", "IsNullable": false @@ -576,19 +712,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "71", + "$id": "90", "Type": { - "$ref": "70" + "$ref": "89" }, "Value": "application/json" } }, { - "$id": "72", + "$id": "91", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "73", + "$id": "92", "Name": "String", "Kind": "String", "IsNullable": false @@ -603,20 +739,20 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "74", + "$id": "93", "Type": { - "$ref": "73" + "$ref": "92" }, "Value": "application/json" } }, { - "$ref": "57" + "$ref": "76" } ], "Responses": [ { - "$id": "75", + "$id": "94", "StatusCodes": [ 200 ], @@ -630,7 +766,7 @@ ], "HttpMethod": "PATCH", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/patch", "RequestMediaTypes": [ "application/json" @@ -640,16 +776,16 @@ "GenerateConvenienceMethod": false }, { - "$id": "76", + "$id": "95", "Name": "anonymousBody", "ResourceName": "CadlFirstTest", "Description": "body parameter without body decorator", "Parameters": [ { - "$ref": "48" + "$ref": "69" }, { - "$id": "77", + "$id": "96", "Name": "Thing", "NameInRequest": "Thing", "Type": { @@ -666,11 +802,11 @@ "Kind": "Method" }, { - "$id": "78", + "$id": "97", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "79", + "$id": "98", "Name": "String", "Kind": "String", "IsNullable": false @@ -685,19 +821,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "80", + "$id": "99", "Type": { - "$ref": "79" + "$ref": "98" }, "Value": "application/json" } }, { - "$id": "81", + "$id": "100", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "82", + "$id": "101", "Name": "String", "Kind": "String", "IsNullable": false @@ -712,20 +848,20 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "83", + "$id": "102", "Type": { - "$ref": "82" + "$ref": "101" }, "Value": "application/json" } }, { - "$ref": "57" + "$ref": "76" } ], "Responses": [ { - "$id": "84", + "$id": "103", "StatusCodes": [ 200 ], @@ -739,7 +875,7 @@ ], "HttpMethod": "POST", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/anonymousBody", "RequestMediaTypes": [ "application/json" @@ -749,20 +885,20 @@ "GenerateConvenienceMethod": true }, { - "$id": "85", + "$id": "104", "Name": "friendlyModel", "ResourceName": "CadlFirstTest", "Description": "Model can have its friendly name", "Parameters": [ { - "$ref": "48" + "$ref": "69" }, { - "$id": "86", + "$id": "105", "Name": "NotFriend", "NameInRequest": "NotFriend", "Type": { - "$ref": "32" + "$ref": "53" }, "Location": "Body", "IsRequired": true, @@ -775,11 +911,11 @@ "Kind": "Method" }, { - "$id": "87", + "$id": "106", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "88", + "$id": "107", "Name": "String", "Kind": "String", "IsNullable": false @@ -794,19 +930,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "89", + "$id": "108", "Type": { - "$ref": "88" + "$ref": "107" }, "Value": "application/json" } }, { - "$id": "90", + "$id": "109", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "91", + "$id": "110", "Name": "String", "Kind": "String", "IsNullable": false @@ -821,25 +957,25 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "92", + "$id": "111", "Type": { - "$ref": "91" + "$ref": "110" }, "Value": "application/json" } }, { - "$ref": "57" + "$ref": "76" } ], "Responses": [ { - "$id": "93", + "$id": "112", "StatusCodes": [ 200 ], "BodyType": { - "$ref": "32" + "$ref": "53" }, "BodyMediaType": "Json", "Headers": [], @@ -848,7 +984,7 @@ ], "HttpMethod": "POST", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/friendlyName", "RequestMediaTypes": [ "application/json" @@ -858,19 +994,19 @@ "GenerateConvenienceMethod": true }, { - "$id": "94", + "$id": "113", "Name": "addTimeHeader", "ResourceName": "CadlFirstTest", "Parameters": [ { - "$ref": "48" + "$ref": "69" }, { - "$id": "95", + "$id": "114", "Name": "repeatabilityFirstSent", "NameInRequest": "Repeatability-First-Sent", "Type": { - "$id": "96", + "$id": "115", "Name": "zonedDateTime", "Kind": "DateTime", "IsNullable": false @@ -886,11 +1022,11 @@ "Kind": "Method" }, { - "$id": "97", + "$id": "116", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "98", + "$id": "117", "Name": "String", "Kind": "String", "IsNullable": false @@ -905,20 +1041,20 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "99", + "$id": "118", "Type": { - "$ref": "98" + "$ref": "117" }, "Value": "application/json" } }, { - "$ref": "57" + "$ref": "76" } ], "Responses": [ { - "$id": "100", + "$id": "119", "StatusCodes": [ 204 ], @@ -929,27 +1065,27 @@ ], "HttpMethod": "GET", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/", "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": false }, { - "$id": "101", + "$id": "120", "Name": "sayHi", "ResourceName": "Demo", "Description": "Return hi", "Parameters": [ { - "$ref": "48" + "$ref": "69" }, { - "$id": "102", + "$id": "121", "Name": "headParameter", "NameInRequest": "head-parameter", "Type": { - "$id": "103", + "$id": "122", "Name": "string", "Kind": "String", "IsNullable": false @@ -965,11 +1101,11 @@ "Kind": "Method" }, { - "$id": "104", + "$id": "123", "Name": "queryParameter", "NameInRequest": "queryParameter", "Type": { - "$id": "105", + "$id": "124", "Name": "string", "Kind": "String", "IsNullable": false @@ -985,11 +1121,11 @@ "Kind": "Method" }, { - "$id": "106", + "$id": "125", "Name": "optionalQuery", "NameInRequest": "optionalQuery", "Type": { - "$id": "107", + "$id": "126", "Name": "string", "Kind": "String", "IsNullable": false @@ -1005,11 +1141,11 @@ "Kind": "Method" }, { - "$id": "108", + "$id": "127", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "109", + "$id": "128", "Name": "String", "Kind": "String", "IsNullable": false @@ -1024,20 +1160,20 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "110", + "$id": "129", "Type": { - "$ref": "109" + "$ref": "128" }, "Value": "application/json" } }, { - "$ref": "57" + "$ref": "76" } ], "Responses": [ { - "$id": "111", + "$id": "130", "StatusCodes": [ 200 ], @@ -1051,27 +1187,27 @@ ], "HttpMethod": "GET", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/hello", "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": false }, { - "$id": "112", + "$id": "131", "Name": "helloAgain", "ResourceName": "Demo2", "Description": "Return hi again", "Parameters": [ { - "$ref": "48" + "$ref": "69" }, { - "$id": "113", + "$id": "132", "Name": "p1", "NameInRequest": "p1", "Type": { - "$id": "114", + "$id": "133", "Name": "string", "Kind": "String", "IsNullable": false @@ -1087,14 +1223,14 @@ "Kind": "Method" }, { - "$id": "115", + "$id": "134", "Name": "contentType", "NameInRequest": "content-type", "Type": { - "$id": "116", + "$id": "135", "Name": "Literal", "LiteralValueType": { - "$id": "117", + "$id": "136", "Name": "String", "Kind": "String", "IsNullable": false @@ -1104,9 +1240,9 @@ }, "Location": "Header", "DefaultValue": { - "$id": "118", + "$id": "137", "Type": { - "$ref": "116" + "$ref": "135" }, "Value": "text/plain" }, @@ -1120,11 +1256,11 @@ "Kind": "Constant" }, { - "$id": "119", + "$id": "138", "Name": "p2", "NameInRequest": "p2", "Type": { - "$id": "120", + "$id": "139", "Name": "string", "Kind": "String", "IsNullable": false @@ -1140,11 +1276,11 @@ "Kind": "Method" }, { - "$id": "121", + "$id": "140", "Name": "action", "NameInRequest": "action", "Type": { - "$ref": "35" + "$ref": "56" }, "Location": "Body", "IsRequired": true, @@ -1157,11 +1293,11 @@ "Kind": "Method" }, { - "$id": "122", + "$id": "141", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "123", + "$id": "142", "Name": "String", "Kind": "String", "IsNullable": false @@ -1176,20 +1312,20 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "124", + "$id": "143", "Type": { - "$ref": "123" + "$ref": "142" }, "Value": "application/json" } }, { - "$ref": "57" + "$ref": "76" } ], "Responses": [ { - "$id": "125", + "$id": "144", "StatusCodes": [ 200 ], @@ -1203,7 +1339,7 @@ ], "HttpMethod": "GET", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/againHi/{p2}", "RequestMediaTypes": [ "text/plain" @@ -1213,20 +1349,20 @@ "GenerateConvenienceMethod": true }, { - "$id": "126", + "$id": "145", "Name": "noContentType", "ResourceName": "Demo2", "Description": "Return hi again", "Parameters": [ { - "$ref": "48" + "$ref": "69" }, { - "$id": "127", + "$id": "146", "Name": "p1", "NameInRequest": "p1", "Type": { - "$id": "128", + "$id": "147", "Name": "string", "Kind": "String", "IsNullable": false @@ -1242,11 +1378,11 @@ "Kind": "Method" }, { - "$id": "129", + "$id": "148", "Name": "p2", "NameInRequest": "p2", "Type": { - "$id": "130", + "$id": "149", "Name": "string", "Kind": "String", "IsNullable": false @@ -1262,11 +1398,11 @@ "Kind": "Method" }, { - "$id": "131", + "$id": "150", "Name": "action", "NameInRequest": "action", "Type": { - "$ref": "35" + "$ref": "56" }, "Location": "Body", "IsRequired": true, @@ -1279,11 +1415,11 @@ "Kind": "Method" }, { - "$id": "132", + "$id": "151", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "133", + "$id": "152", "Name": "String", "Kind": "String", "IsNullable": false @@ -1298,19 +1434,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "134", + "$id": "153", "Type": { - "$ref": "133" + "$ref": "152" }, "Value": "application/json" } }, { - "$id": "135", + "$id": "154", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "136", + "$id": "155", "Name": "String", "Kind": "String", "IsNullable": false @@ -1325,20 +1461,20 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "137", + "$id": "156", "Type": { - "$ref": "136" + "$ref": "155" }, "Value": "application/json" } }, { - "$ref": "57" + "$ref": "76" } ], "Responses": [ { - "$id": "138", + "$id": "157", "StatusCodes": [ 200 ], @@ -1352,7 +1488,7 @@ ], "HttpMethod": "GET", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/noContentType/{p2}", "RequestMediaTypes": [ "application/json" @@ -1362,20 +1498,20 @@ "GenerateConvenienceMethod": false }, { - "$id": "139", + "$id": "158", "Name": "helloDemo2", "ResourceName": "Demo2", "Description": "Return hi in demo2", "Parameters": [ { - "$ref": "48" + "$ref": "69" }, { - "$id": "140", + "$id": "159", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "141", + "$id": "160", "Name": "String", "Kind": "String", "IsNullable": false @@ -1390,20 +1526,20 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "142", + "$id": "161", "Type": { - "$ref": "141" + "$ref": "160" }, "Value": "application/json" } }, { - "$ref": "57" + "$ref": "76" } ], "Responses": [ { - "$id": "143", + "$id": "162", "StatusCodes": [ 200 ], @@ -1417,27 +1553,297 @@ ], "HttpMethod": "GET", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/demoHi", "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": true }, { - "$id": "144", + "$id": "163", + "Name": "createLiteral", + "ResourceName": "Demo2", + "Description": "Create with literal value", + "Parameters": [ + { + "$ref": "69" + }, + { + "$id": "164", + "Name": "body", + "NameInRequest": "body", + "Type": { + "$ref": "18" + }, + "Location": "Body", + "IsRequired": true, + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Method" + }, + { + "$id": "165", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Type": { + "$id": "166", + "Name": "String", + "Kind": "String", + "IsNullable": false + }, + "Location": "Header", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": true, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Constant", + "DefaultValue": { + "$id": "167", + "Type": { + "$ref": "166" + }, + "Value": "application/json" + } + }, + { + "$id": "168", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "169", + "Name": "String", + "Kind": "String", + "IsNullable": false + }, + "Location": "Header", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Constant", + "DefaultValue": { + "$id": "170", + "Type": { + "$ref": "169" + }, + "Value": "application/json" + } + }, + { + "$ref": "76" + } + ], + "Responses": [ + { + "$id": "171", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "18" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Json", + "Uri": "{firstTestCadlUrl}", + "Path": "/literal", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true + }, + { + "$id": "172", + "Name": "helloLiteral", + "ResourceName": "Demo2", + "Description": "Send literal parameters", + "Parameters": [ + { + "$ref": "69" + }, + { + "$id": "173", + "Name": "p1", + "NameInRequest": "p1", + "Type": { + "$id": "174", + "Name": "Literal", + "LiteralValueType": { + "$id": "175", + "Name": "String", + "Kind": "String", + "IsNullable": false + }, + "Value": "test", + "IsNullable": false + }, + "Location": "Header", + "DefaultValue": { + "$id": "176", + "Type": { + "$ref": "174" + }, + "Value": "test" + }, + "IsRequired": true, + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Constant" + }, + { + "$id": "177", + "Name": "p2", + "NameInRequest": "p2", + "Type": { + "$id": "178", + "Name": "Literal", + "LiteralValueType": { + "$id": "179", + "Name": "Number", + "Kind": "Int32", + "IsNullable": false + }, + "Value": 123, + "IsNullable": false + }, + "Location": "Path", + "DefaultValue": { + "$id": "180", + "Type": { + "$ref": "178" + }, + "Value": 123 + }, + "IsRequired": true, + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Constant" + }, + { + "$id": "181", + "Name": "p3", + "NameInRequest": "p3", + "Type": { + "$id": "182", + "Name": "Literal", + "LiteralValueType": { + "$id": "183", + "Name": "Boolean", + "Kind": "Boolean", + "IsNullable": false + }, + "Value": true, + "IsNullable": false + }, + "Location": "Query", + "DefaultValue": { + "$id": "184", + "Type": { + "$ref": "182" + }, + "Value": true + }, + "IsRequired": true, + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Constant" + }, + { + "$id": "185", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "186", + "Name": "String", + "Kind": "String", + "IsNullable": false + }, + "Location": "Header", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": false, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Constant", + "DefaultValue": { + "$id": "187", + "Type": { + "$ref": "186" + }, + "Value": "application/json" + } + }, + { + "$ref": "76" + } + ], + "Responses": [ + { + "$id": "188", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "18" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false + } + ], + "HttpMethod": "GET", + "RequestBodyMediaType": "Json", + "Uri": "{firstTestCadlUrl}", + "Path": "/helloLiteral/{p2}", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true + }, + { + "$id": "189", "Name": "getUnknownValue", "ResourceName": "EnumTest", "Description": "get extensible enum", "Parameters": [ { - "$ref": "48" + "$ref": "69" }, { - "$id": "145", + "$id": "190", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "146", + "$id": "191", "Name": "String", "Kind": "String", "IsNullable": false @@ -1452,20 +1858,20 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "147", + "$id": "192", "Type": { - "$ref": "146" + "$ref": "191" }, "Value": "application/json" } }, { - "$ref": "57" + "$ref": "76" } ], "Responses": [ { - "$id": "148", + "$id": "193", "StatusCodes": [ 200 ], @@ -1479,23 +1885,23 @@ ], "HttpMethod": "GET", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/unknown-value", "BufferResponse": true, "GenerateProtocolMethod": true, "GenerateConvenienceMethod": false }, { - "$id": "149", + "$id": "194", "Name": "internalProtocol", "ResourceName": "ProtocolAndConvenient", "Description": "When set protocol false and convenient true, then the protocol method should be internal", "Parameters": [ { - "$ref": "48" + "$ref": "69" }, { - "$id": "150", + "$id": "195", "Name": "body", "NameInRequest": "body", "Type": { @@ -1512,11 +1918,11 @@ "Kind": "Method" }, { - "$id": "151", + "$id": "196", "Name": "contentType", "NameInRequest": "Content-Type", "Type": { - "$id": "152", + "$id": "197", "Name": "String", "Kind": "String", "IsNullable": false @@ -1531,19 +1937,19 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "153", + "$id": "198", "Type": { - "$ref": "152" + "$ref": "197" }, "Value": "application/json" } }, { - "$id": "154", + "$id": "199", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "155", + "$id": "200", "Name": "String", "Kind": "String", "IsNullable": false @@ -1558,20 +1964,20 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "156", + "$id": "201", "Type": { - "$ref": "155" + "$ref": "200" }, "Value": "application/json" } }, { - "$ref": "57" + "$ref": "76" } ], "Responses": [ { - "$id": "157", + "$id": "202", "StatusCodes": [ 200 ], @@ -1585,7 +1991,7 @@ ], "HttpMethod": "POST", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/internalProtocol", "RequestMediaTypes": [ "application/json" @@ -1595,20 +2001,20 @@ "GenerateConvenienceMethod": true }, { - "$id": "158", + "$id": "203", "Name": "stillConvenient", "ResourceName": "ProtocolAndConvenient", "Description": "When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one", "Parameters": [ { - "$ref": "48" + "$ref": "69" }, { - "$id": "159", + "$id": "204", "Name": "accept", "NameInRequest": "Accept", "Type": { - "$id": "160", + "$id": "205", "Name": "String", "Kind": "String", "IsNullable": false @@ -1623,20 +2029,20 @@ "Explode": false, "Kind": "Constant", "DefaultValue": { - "$id": "161", + "$id": "206", "Type": { - "$ref": "160" + "$ref": "205" }, "Value": "application/json" } }, { - "$ref": "57" + "$ref": "76" } ], "Responses": [ { - "$id": "162", + "$id": "207", "StatusCodes": [ 204 ], @@ -1647,7 +2053,7 @@ ], "HttpMethod": "GET", "RequestBodyMediaType": "Json", - "Uri": "{host}", + "Uri": "{firstTestCadlUrl}", "Path": "/stillConvenient", "BufferResponse": true, "GenerateProtocolMethod": false, @@ -1655,19 +2061,19 @@ } ], "Protocol": { - "$id": "163" + "$id": "208" }, "Creatable": true } ], "Auth": { - "$id": "164", + "$id": "209", "ApiKey": { - "$id": "165", + "$id": "210", "Name": "x-ms-api-key" }, "OAuth2": { - "$id": "166", + "$id": "211", "Scopes": [ "https://api.example.com/.default" ]