In progress of creating the paging logic.
This commit is contained in:
Родитель
c25bcd294a
Коммит
d252776945
|
@ -80,7 +80,7 @@ $testNames =
|
|||
#'httpInfrastructure.quirks',
|
||||
#'lro',
|
||||
#'model-flattening',
|
||||
#'paging',
|
||||
'paging',
|
||||
#'parameter-flattening',
|
||||
#'report',
|
||||
#'required-optional',
|
||||
|
|
|
@ -16,12 +16,12 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
{
|
||||
internal class ClientBuilder
|
||||
{
|
||||
public static ServiceClient BuildClient(OperationGroup arg)
|
||||
public static ServiceClient BuildClient(OperationGroup operationGroup)
|
||||
{
|
||||
List<ClientMethod> methods = new List<ClientMethod>();
|
||||
Dictionary<string, ServiceClientParameter> clientParameters = new Dictionary<string, ServiceClientParameter>();
|
||||
|
||||
var allClientParameters = arg.Operations
|
||||
var allClientParameters = operationGroup.Operations
|
||||
.SelectMany(op => op.Request.Parameters)
|
||||
.Where(p => p.Implementation == ImplementationLocation.Client)
|
||||
.Distinct();
|
||||
|
@ -32,19 +32,27 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
clientParameters[clientParameter.Language.Default.Name] = BuildParameter(clientParameter);
|
||||
}
|
||||
|
||||
string clientName = arg.CSharpName();
|
||||
string clientName = operationGroup.CSharpName();
|
||||
|
||||
foreach (Operation operation in arg.Operations)
|
||||
foreach (Operation operation in operationGroup.Operations)
|
||||
{
|
||||
var method = BuildMethod(operation, clientName, clientParameters);
|
||||
if (method != null)
|
||||
{
|
||||
methods.Add(method);
|
||||
|
||||
//if ((operation.Extensions?.ContainsKey("x-ms-pageable") ?? false) && operation.Extensions["x-ms-pageable"] is IDictionary<string, object> pageable)
|
||||
//{
|
||||
// if (pageable.ContainsKey("nextLinkName") && operation.Extensions["x-ms-pageable"] is string nextLinkName)
|
||||
// {
|
||||
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
return new ServiceClient(clientName,
|
||||
arg.Language.Default.Description,
|
||||
operationGroup.Language.Default.Description,
|
||||
OrderParameters(clientParameters.Values),
|
||||
methods.ToArray());
|
||||
}
|
||||
|
@ -66,7 +74,7 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
return null;
|
||||
}
|
||||
|
||||
private static ClientMethod? BuildMethod(Operation operation, string clientName, Dictionary<string, ServiceClientParameter> clientParameters)
|
||||
private static ClientMethod? BuildMethod(Operation operation, string clientName, IReadOnlyDictionary<string, ServiceClientParameter> clientParameters)
|
||||
{
|
||||
var httpRequest = operation.Request.Protocol.Http as HttpRequest;
|
||||
var httpRequestWithBody = httpRequest as HttpWithBodyRequest;
|
||||
|
@ -184,6 +192,14 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
BuildResponseHeaderModel(operation, httpResponse)
|
||||
);
|
||||
|
||||
if ((operation.Extensions?.ContainsKey("x-ms-pageable") ?? false) && operation.Extensions["x-ms-pageable"] is IDictionary<string, object> pageable)
|
||||
{
|
||||
if (pageable.ContainsKey("nextLinkName") && operation.Extensions["x-ms-pageable"] is string nextLinkName)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
string operationName = operation.CSharpName();
|
||||
return new ClientMethod(
|
||||
operationName,
|
||||
|
@ -195,6 +211,136 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
);
|
||||
}
|
||||
|
||||
//private static ClientMethod? BuildNextPageMethod(Operation operation, string clientName, string nextLinkName, IReadOnlyDictionary<string, ServiceClientParameter> clientParameters)
|
||||
//{
|
||||
// var httpRequest = operation.Request.Protocol.Http as HttpRequest;
|
||||
// var httpRequestWithBody = httpRequest as HttpWithBodyRequest;
|
||||
|
||||
// //TODO: Handle multiple responses
|
||||
// var response = operation.Responses.FirstOrDefault();
|
||||
// var httpResponse = response?.Protocol.Http as HttpResponse;
|
||||
|
||||
// if (httpRequest == null || httpResponse == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// Dictionary<string, ConstantOrParameter> uriParameters = new Dictionary<string, ConstantOrParameter>();
|
||||
// Dictionary<string, PathSegment> pathParameters = new Dictionary<string, PathSegment>();
|
||||
// List<QueryParameter> query = new List<QueryParameter>();
|
||||
// List<RequestHeader> headers = new List<RequestHeader>();
|
||||
// List<ServiceClientParameter> methodParameters = new List<ServiceClientParameter>();
|
||||
|
||||
// ObjectRequestBody? body = null;
|
||||
// foreach (Parameter requestParameter in operation.Request.Parameters ?? Array.Empty<Parameter>())
|
||||
// {
|
||||
// string defaultName = requestParameter.Language.Default.Name;
|
||||
// string serializedName = requestParameter.Language.Default.SerializedName ?? defaultName;
|
||||
// ConstantOrParameter constantOrParameter;
|
||||
// Schema valueSchema = requestParameter.Schema;
|
||||
|
||||
// if (requestParameter.Implementation == ImplementationLocation.Method)
|
||||
// {
|
||||
// switch (requestParameter.Schema)
|
||||
// {
|
||||
// case ConstantSchema constant:
|
||||
// constantOrParameter = ClientModelBuilderHelpers.ParseClientConstant(constant);
|
||||
// valueSchema = constant.ValueType;
|
||||
// break;
|
||||
// case BinarySchema _:
|
||||
// // skip
|
||||
// continue;
|
||||
// default:
|
||||
// constantOrParameter = BuildParameter(requestParameter);
|
||||
// break;
|
||||
// }
|
||||
|
||||
// if (!constantOrParameter.IsConstant)
|
||||
// {
|
||||
// methodParameters.Add(constantOrParameter.Parameter);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// constantOrParameter = clientParameters[defaultName];
|
||||
// }
|
||||
|
||||
|
||||
// if (requestParameter.Protocol.Http is HttpParameter httpParameter)
|
||||
// {
|
||||
// SerializationFormat serializationFormat = ClientModelBuilderHelpers.GetSerializationFormat(valueSchema);
|
||||
// switch (httpParameter.In)
|
||||
// {
|
||||
// case ParameterLocation.Header:
|
||||
// headers.Add(new RequestHeader(serializedName, constantOrParameter, serializationFormat));
|
||||
// break;
|
||||
// case ParameterLocation.Query:
|
||||
// query.Add(new QueryParameter(serializedName, constantOrParameter, GetSerializationStyle(httpParameter, valueSchema), true, serializationFormat));
|
||||
// break;
|
||||
// //case ParameterLocation.Path:
|
||||
// // pathParameters.Add(serializedName, new PathSegment(constantOrParameter, true, serializationFormat));
|
||||
// // break;
|
||||
// //case ParameterLocation.Body:
|
||||
// // Debug.Assert(httpRequestWithBody != null);
|
||||
// // var serialization = SerializationBuilder.Build(httpRequestWithBody.KnownMediaType, requestParameter.Schema, requestParameter.IsNullable());
|
||||
|
||||
// // body = new ObjectRequestBody(constantOrParameter, serialization);
|
||||
// // break;
|
||||
// //case ParameterLocation.Uri:
|
||||
// // uriParameters[defaultName] = constantOrParameter;
|
||||
// // break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// if (httpRequestWithBody != null)
|
||||
// {
|
||||
// headers.AddRange(httpRequestWithBody.MediaTypes.Select(mediaType => new RequestHeader("Content-Type", ClientModelBuilderHelpers.StringConstant(mediaType))));
|
||||
// }
|
||||
|
||||
// var request = new ClientMethodRequest(
|
||||
// ToCoreRequestMethod(httpRequest.Method) ?? RequestMethod.Get,
|
||||
// ToParts(httpRequest.Uri, uriParameters),
|
||||
// ToPathParts(httpRequest.Path, pathParameters),
|
||||
// query.ToArray(),
|
||||
// headers.ToArray(),
|
||||
// body
|
||||
// );
|
||||
|
||||
// ResponseBody? responseBody = null;
|
||||
// if (response is SchemaResponse schemaResponse)
|
||||
// {
|
||||
// var schema = schemaResponse.Schema is ConstantSchema constantSchema ? constantSchema.ValueType : schemaResponse.Schema;
|
||||
// var responseType = ClientModelBuilderHelpers.CreateType(schema, isNullable: false);
|
||||
|
||||
// ObjectSerialization serialization = SerializationBuilder.Build(httpResponse.KnownMediaType, schema, isNullable: false);
|
||||
|
||||
// responseBody = new ObjectResponseBody(responseType, serialization);
|
||||
// }
|
||||
// else if (response is BinaryResponse)
|
||||
// {
|
||||
// responseBody = new StreamResponseBody();
|
||||
// }
|
||||
|
||||
// ClientMethodResponse clientResponse = new ClientMethodResponse(
|
||||
// responseBody,
|
||||
// httpResponse.StatusCodes.Select(ToStatusCode).ToArray(),
|
||||
// BuildResponseHeaderModel(operation, httpResponse)
|
||||
// );
|
||||
|
||||
// string operationName = operation.CSharpName();
|
||||
// return new ClientMethod(
|
||||
// operationName,
|
||||
// ClientModelBuilderHelpers.EscapeXmlDescription(operation.Language.Default.Description),
|
||||
// request,
|
||||
// OrderParameters(methodParameters),
|
||||
// clientResponse,
|
||||
// new ClientMethodDiagnostics($"{clientName}.{operationName}", Array.Empty<DiagnosticScopeAttributes>())
|
||||
// );
|
||||
//}
|
||||
|
||||
|
||||
private static ServiceClientParameter BuildParameter(Parameter requestParameter)
|
||||
{
|
||||
ClientConstant? defaultValue = null;
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
{
|
||||
internal class ClientMethod
|
||||
{
|
||||
public ClientMethod(string name, string? description, ClientMethodRequest request, ServiceClientParameter[] parameters, ClientMethodResponse responseType, ClientMethodDiagnostics diagnostics)
|
||||
public ClientMethod(string name, string? description, ClientMethodRequest request, ServiceClientParameter[] parameters, ClientMethodResponse responseType, ClientMethodDiagnostics diagnostics, bool includesPaging)
|
||||
{
|
||||
Name = name;
|
||||
Request = request;
|
||||
|
@ -13,14 +13,15 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
Response = responseType;
|
||||
Description = description;
|
||||
Diagnostics = diagnostics;
|
||||
IncludesPaging = includesPaging;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public string? Description { get; }
|
||||
public ClientMethodRequest Request { get; }
|
||||
public ServiceClientParameter[] Parameters { get; }
|
||||
public ClientMethodResponse Response { get; }
|
||||
public ClientMethodDiagnostics Diagnostics { get; }
|
||||
public bool IncludesPaging { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
namespace AutoRest.CSharp.V3.ClientModels
|
||||
{
|
||||
internal class ClientMethodPaging
|
||||
{
|
||||
public ClientMethodPaging(string name, string? description, ClientMethodRequest request, ServiceClientParameter[] parameters, ClientMethodResponse responseType, ClientMethodDiagnostics diagnostics, bool includesPaging)
|
||||
{
|
||||
IncludesPaging = includesPaging;
|
||||
}
|
||||
|
||||
public bool IncludesPaging { get; }
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ namespace AutoRest.CSharp.V3.ClientModels
|
|||
public string Description { get; }
|
||||
|
||||
public ClientMethod[] Methods { get; }
|
||||
//public ClientPagingMethod[] PagingMethods { get; }
|
||||
|
||||
public ServiceClientParameter[] Parameters { get; }
|
||||
}
|
||||
|
|
|
@ -101,12 +101,15 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
|
||||
private void WriteRequestCreation(CodeWriter writer, ClientMethod operation)
|
||||
{
|
||||
|
||||
writer.Append($"internal {typeof(HttpMessage)} {CreateRequestMethodName(operation)}(");
|
||||
foreach (ServiceClientParameter clientParameter in operation.Parameters)
|
||||
{
|
||||
writer.Append($"{_typeFactory.CreateInputType(clientParameter.Type)} {clientParameter.Name},");
|
||||
}
|
||||
if (operation.IncludesPaging)
|
||||
{
|
||||
writer.Append($"{writer.Type(typeof(string), true)} nextLinkUrl = default");
|
||||
}
|
||||
writer.RemoveTrailingComma();
|
||||
writer.Line($")");
|
||||
using (writer.Scope())
|
||||
|
@ -114,17 +117,24 @@ namespace AutoRest.CSharp.V3.CodeGen
|
|||
writer.Line($"var message = pipeline.CreateMessage();");
|
||||
writer.Line($"var request = message.Request;");
|
||||
var method = operation.Request.Method;
|
||||
writer.Line($"request.Method = {writer.Type(typeof(RequestMethod))}.{method.ToRequestMethodName()};");
|
||||
writer.Line($"request.Method = {typeof(RequestMethod)}.{method.ToRequestMethodName()};");
|
||||
|
||||
//TODO: Add logic to escape the strings when specified, using Uri.EscapeDataString(value);
|
||||
//TODO: Need proper logic to convert the values to strings. Right now, everything is just using default ToString().
|
||||
//TODO: Need logic to trim duplicate slashes (/) so when combined, you don't end up with multiple // together
|
||||
var urlText = String.Join(String.Empty, operation.Request.HostSegments.Select(s => s.IsConstant ? s.Constant.Value : "{" + s.Parameter.Name + "}"));
|
||||
writer.Line($"request.Uri.Reset(new {writer.Type(typeof(Uri))}($\"{urlText}\"));");
|
||||
|
||||
foreach (var segment in operation.Request.PathSegments)
|
||||
using (operation.IncludesPaging ? writer.If("nextLinkUrl != null") : default)
|
||||
{
|
||||
WritePathSegment(writer, segment);
|
||||
writer.Line($"request.Uri.Reset(new {typeof(Uri)}(nextLinkUrl));");
|
||||
}
|
||||
using (operation.IncludesPaging ? writer.Else() : default)
|
||||
{
|
||||
//TODO: Add logic to escape the strings when specified, using Uri.EscapeDataString(value);
|
||||
//TODO: Need proper logic to convert the values to strings. Right now, everything is just using default ToString().
|
||||
//TODO: Need logic to trim duplicate slashes (/) so when combined, you don't end up with multiple // together
|
||||
var urlText = String.Join(String.Empty, operation.Request.HostSegments.Select(s => s.IsConstant ? s.Constant.Value : "{" + s.Parameter.Name + "}"));
|
||||
writer.Line($"request.Uri.Reset(new {typeof(Uri)}($\"{urlText}\"));");
|
||||
|
||||
foreach (var segment in operation.Request.PathSegments)
|
||||
{
|
||||
WritePathSegment(writer, segment);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var header in operation.Request.Headers)
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
{
|
||||
public class PagingTests : TestServerTestBase
|
||||
{
|
||||
public PagingTests(TestServerVersion version) : base(version, "paging") { }
|
||||
|
||||
[Test]
|
||||
public Task PagingCustomUrlPartialNextLink() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingCustomUrlPartialOperationNextLink() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingFragment() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingMultiple() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingMultipleFailure() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingMultipleFailureUri() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingMultipleLRO() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingMultiplePath() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingMultipleRetryFirst() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingMultipleRetrySecond() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingNextLinkNameNull() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingNoItemName() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingOdataMultiple() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingSingle() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
[Test]
|
||||
public Task PagingSingleFailure() => TestStatus(async (host, pipeline) => { await Task.FromException(new Exception()); return null; });
|
||||
|
||||
}
|
||||
}
|
63
test/TestServerProjects/paging/Generated/Models/OdataProductResult.Serialization.cs
сгенерированный
Normal file
63
test/TestServerProjects/paging/Generated/Models/OdataProductResult.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,63 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
public partial class OdataProductResult : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (Values != null)
|
||||
{
|
||||
writer.WritePropertyName("values");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in Values)
|
||||
{
|
||||
writer.WriteObjectValue(item);
|
||||
}
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
if (OdataNextLink != null)
|
||||
{
|
||||
writer.WritePropertyName("odata.nextLink");
|
||||
writer.WriteStringValue(OdataNextLink);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static OdataProductResult DeserializeOdataProductResult(JsonElement element)
|
||||
{
|
||||
OdataProductResult result = new OdataProductResult();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("values"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Values = new List<Product>();
|
||||
foreach (var item in property.Value.EnumerateArray())
|
||||
{
|
||||
result.Values.Add(Product.DeserializeProduct(item));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("odata.nextLink"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.OdataNextLink = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
16
test/TestServerProjects/paging/Generated/Models/OdataProductResult.cs
сгенерированный
Normal file
16
test/TestServerProjects/paging/Generated/Models/OdataProductResult.cs
сгенерированный
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-OBJECTSCHEMA. </summary>
|
||||
public partial class OdataProductResult
|
||||
{
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-ARRAYSCHEMA. </summary>
|
||||
public ICollection<Product>? Values { get; set; }
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-STRING. </summary>
|
||||
public string? OdataNextLink { get; set; }
|
||||
}
|
||||
}
|
39
test/TestServerProjects/paging/Generated/Models/OperationResult.Serialization.cs
сгенерированный
Normal file
39
test/TestServerProjects/paging/Generated/Models/OperationResult.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
public partial class OperationResult : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (Status != null)
|
||||
{
|
||||
writer.WritePropertyName("status");
|
||||
writer.WriteStringValue(Status.Value.ToString());
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static OperationResult DeserializeOperationResult(JsonElement element)
|
||||
{
|
||||
OperationResult result = new OperationResult();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("status"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Status = new OperationResultStatus(property.Value.GetString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-OBJECTSCHEMA. </summary>
|
||||
public partial class OperationResult
|
||||
{
|
||||
/// <summary> The status of the request. </summary>
|
||||
public OperationResultStatus? Status { get; set; }
|
||||
}
|
||||
}
|
73
test/TestServerProjects/paging/Generated/Models/OperationResultStatus.cs
сгенерированный
Normal file
73
test/TestServerProjects/paging/Generated/Models/OperationResultStatus.cs
сгенерированный
Normal file
|
@ -0,0 +1,73 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
/// <summary> The status of the request. </summary>
|
||||
public readonly partial struct OperationResultStatus : IEquatable<OperationResultStatus>
|
||||
{
|
||||
private readonly string? _value;
|
||||
|
||||
/// <summary> Determines if two <see cref="OperationResultStatus"/> values are the same. </summary>
|
||||
public OperationResultStatus(string value)
|
||||
{
|
||||
_value = value ?? throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
private const string SucceededValue = "Succeeded";
|
||||
private const string FailedValue = "Failed";
|
||||
private const string CanceledValue = "canceled";
|
||||
private const string AcceptedValue = "Accepted";
|
||||
private const string CreatingValue = "Creating";
|
||||
private const string CreatedValue = "Created";
|
||||
private const string UpdatingValue = "Updating";
|
||||
private const string UpdatedValue = "Updated";
|
||||
private const string DeletingValue = "Deleting";
|
||||
private const string DeletedValue = "Deleted";
|
||||
private const string OKValue = "OK";
|
||||
|
||||
/// <summary> Succeeded. </summary>
|
||||
public static OperationResultStatus Succeeded { get; } = new OperationResultStatus(SucceededValue);
|
||||
/// <summary> Failed. </summary>
|
||||
public static OperationResultStatus Failed { get; } = new OperationResultStatus(FailedValue);
|
||||
/// <summary> canceled. </summary>
|
||||
public static OperationResultStatus Canceled { get; } = new OperationResultStatus(CanceledValue);
|
||||
/// <summary> Accepted. </summary>
|
||||
public static OperationResultStatus Accepted { get; } = new OperationResultStatus(AcceptedValue);
|
||||
/// <summary> Creating. </summary>
|
||||
public static OperationResultStatus Creating { get; } = new OperationResultStatus(CreatingValue);
|
||||
/// <summary> Created. </summary>
|
||||
public static OperationResultStatus Created { get; } = new OperationResultStatus(CreatedValue);
|
||||
/// <summary> Updating. </summary>
|
||||
public static OperationResultStatus Updating { get; } = new OperationResultStatus(UpdatingValue);
|
||||
/// <summary> Updated. </summary>
|
||||
public static OperationResultStatus Updated { get; } = new OperationResultStatus(UpdatedValue);
|
||||
/// <summary> Deleting. </summary>
|
||||
public static OperationResultStatus Deleting { get; } = new OperationResultStatus(DeletingValue);
|
||||
/// <summary> Deleted. </summary>
|
||||
public static OperationResultStatus Deleted { get; } = new OperationResultStatus(DeletedValue);
|
||||
/// <summary> OK. </summary>
|
||||
public static OperationResultStatus OK { get; } = new OperationResultStatus(OKValue);
|
||||
/// <summary> Determines if two <see cref="OperationResultStatus"/> values are the same. </summary>
|
||||
public static bool operator ==(OperationResultStatus left, OperationResultStatus right) => left.Equals(right);
|
||||
/// <summary> Determines if two <see cref="OperationResultStatus"/> values are not the same. </summary>
|
||||
public static bool operator !=(OperationResultStatus left, OperationResultStatus right) => !left.Equals(right);
|
||||
/// <summary> Converts a string to a <see cref="OperationResultStatus"/>. </summary>
|
||||
public static implicit operator OperationResultStatus(string value) => new OperationResultStatus(value);
|
||||
|
||||
/// <inheritdoc />
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override bool Equals(object? obj) => obj is OperationResultStatus other && Equals(other);
|
||||
/// <inheritdoc />
|
||||
public bool Equals(OperationResultStatus other) => string.Equals(_value, other._value, StringComparison.Ordinal);
|
||||
|
||||
/// <inheritdoc />
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
|
||||
/// <inheritdoc />
|
||||
public override string? ToString() => _value;
|
||||
}
|
||||
}
|
39
test/TestServerProjects/paging/Generated/Models/Product.Serialization.cs
сгенерированный
Normal file
39
test/TestServerProjects/paging/Generated/Models/Product.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
public partial class Product : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (Properties != null)
|
||||
{
|
||||
writer.WritePropertyName("properties");
|
||||
writer.WriteObjectValue(Properties);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static Product DeserializeProduct(JsonElement element)
|
||||
{
|
||||
Product result = new Product();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("properties"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Properties = ProductProperties.DeserializeProductProperties(property.Value);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-OBJECTSCHEMA. </summary>
|
||||
public partial class Product
|
||||
{
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-OBJECTSCHEMA. </summary>
|
||||
public ProductProperties? Properties { get; set; }
|
||||
}
|
||||
}
|
53
test/TestServerProjects/paging/Generated/Models/ProductProperties.Serialization.cs
сгенерированный
Normal file
53
test/TestServerProjects/paging/Generated/Models/ProductProperties.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
public partial class ProductProperties : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (Id != null)
|
||||
{
|
||||
writer.WritePropertyName("id");
|
||||
writer.WriteNumberValue(Id.Value);
|
||||
}
|
||||
if (Name != null)
|
||||
{
|
||||
writer.WritePropertyName("name");
|
||||
writer.WriteStringValue(Name);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static ProductProperties DeserializeProductProperties(JsonElement element)
|
||||
{
|
||||
ProductProperties result = new ProductProperties();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("id"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Id = property.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("name"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Name = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-OBJECTSCHEMA. </summary>
|
||||
public partial class ProductProperties
|
||||
{
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-INTEGER. </summary>
|
||||
public int? Id { get; set; }
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-STRING. </summary>
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
63
test/TestServerProjects/paging/Generated/Models/ProductResult.Serialization.cs
сгенерированный
Normal file
63
test/TestServerProjects/paging/Generated/Models/ProductResult.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,63 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
public partial class ProductResult : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (Values != null)
|
||||
{
|
||||
writer.WritePropertyName("values");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in Values)
|
||||
{
|
||||
writer.WriteObjectValue(item);
|
||||
}
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
if (NextLink != null)
|
||||
{
|
||||
writer.WritePropertyName("nextLink");
|
||||
writer.WriteStringValue(NextLink);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static ProductResult DeserializeProductResult(JsonElement element)
|
||||
{
|
||||
ProductResult result = new ProductResult();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("values"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Values = new List<Product>();
|
||||
foreach (var item in property.Value.EnumerateArray())
|
||||
{
|
||||
result.Values.Add(Product.DeserializeProduct(item));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("nextLink"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.NextLink = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-OBJECTSCHEMA. </summary>
|
||||
public partial class ProductResult
|
||||
{
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-ARRAYSCHEMA. </summary>
|
||||
public ICollection<Product>? Values { get; set; }
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-STRING. </summary>
|
||||
public string? NextLink { get; set; }
|
||||
}
|
||||
}
|
63
test/TestServerProjects/paging/Generated/Models/ProductResultValue.Serialization.cs
сгенерированный
Normal file
63
test/TestServerProjects/paging/Generated/Models/ProductResultValue.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,63 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
public partial class ProductResultValue : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (Value != null)
|
||||
{
|
||||
writer.WritePropertyName("value");
|
||||
writer.WriteStartArray();
|
||||
foreach (var item in Value)
|
||||
{
|
||||
writer.WriteObjectValue(item);
|
||||
}
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
if (NextLink != null)
|
||||
{
|
||||
writer.WritePropertyName("nextLink");
|
||||
writer.WriteStringValue(NextLink);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static ProductResultValue DeserializeProductResultValue(JsonElement element)
|
||||
{
|
||||
ProductResultValue result = new ProductResultValue();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("value"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.Value = new List<Product>();
|
||||
foreach (var item in property.Value.EnumerateArray())
|
||||
{
|
||||
result.Value.Add(Product.DeserializeProduct(item));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("nextLink"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
result.NextLink = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
16
test/TestServerProjects/paging/Generated/Models/ProductResultValue.cs
сгенерированный
Normal file
16
test/TestServerProjects/paging/Generated/Models/ProductResultValue.cs
сгенерированный
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace paging.Models.V100
|
||||
{
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-OBJECTSCHEMA. </summary>
|
||||
public partial class ProductResultValue
|
||||
{
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-ARRAYSCHEMA. </summary>
|
||||
public ICollection<Product>? Value { get; set; }
|
||||
/// <summary> MISSING·SCHEMA-DESCRIPTION-STRING. </summary>
|
||||
public string? NextLink { get; set; }
|
||||
}
|
||||
}
|
1292
test/TestServerProjects/paging/Generated/Operations/PagingOperations.cs
сгенерированный
Normal file
1292
test/TestServerProjects/paging/Generated/Operations/PagingOperations.cs
сгенерированный
Normal file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,15 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Nullable>annotations</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Azure.Core" Version="1.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Загрузка…
Ссылка в новой задаче