diff --git a/src/Examples/JsonApiDotNetCoreExample/GeneratedSwagger/JsonApiDotNetCoreExample.json b/src/Examples/JsonApiDotNetCoreExample/GeneratedSwagger/JsonApiDotNetCoreExample.json index d9744a9ef0..9d80aba967 100644 --- a/src/Examples/JsonApiDotNetCoreExample/GeneratedSwagger/JsonApiDotNetCoreExample.json +++ b/src/Examples/JsonApiDotNetCoreExample/GeneratedSwagger/JsonApiDotNetCoreExample.json @@ -232,8 +232,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -957,7 +967,7 @@ } }, "404": { - "description": "The person does not exist.", + "description": "The person or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -967,7 +977,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1025,7 +1035,7 @@ } }, "404": { - "description": "The person does not exist.", + "description": "The person or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1035,7 +1045,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1093,7 +1103,7 @@ } }, "404": { - "description": "The person does not exist.", + "description": "The person or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1103,7 +1113,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1509,7 +1519,7 @@ } }, "404": { - "description": "The person does not exist.", + "description": "The person or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1519,7 +1529,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1577,7 +1587,7 @@ } }, "404": { - "description": "The person does not exist.", + "description": "The person or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1587,7 +1597,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1645,7 +1655,7 @@ } }, "404": { - "description": "The person does not exist.", + "description": "The person or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1655,7 +1665,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1889,8 +1899,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2614,7 +2634,7 @@ } }, "404": { - "description": "The tag does not exist.", + "description": "The tag or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2624,7 +2644,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2682,7 +2702,7 @@ } }, "404": { - "description": "The tag does not exist.", + "description": "The tag or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2692,7 +2712,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2750,7 +2770,7 @@ } }, "404": { - "description": "The tag does not exist.", + "description": "The tag or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2760,7 +2780,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2994,8 +3014,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3719,7 +3749,7 @@ } }, "404": { - "description": "The todoItem does not exist.", + "description": "The todoItem or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -3729,7 +3759,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4135,7 +4165,7 @@ } }, "404": { - "description": "The todoItem does not exist.", + "description": "The todoItem or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4145,7 +4175,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4551,7 +4581,7 @@ } }, "404": { - "description": "The todoItem does not exist.", + "description": "The todoItem or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4561,7 +4591,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4619,7 +4649,7 @@ } }, "404": { - "description": "The todoItem does not exist.", + "description": "The todoItem or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4629,7 +4659,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4687,7 +4717,7 @@ } }, "404": { - "description": "The todoItem does not exist.", + "description": "The todoItem or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4697,7 +4727,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -5255,9 +5285,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -5647,9 +5674,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -6157,9 +6181,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/PeopleRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/PeopleRequestBuilder.cs index 7ba6f0a5c0..17bf80acf6 100644 --- a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/PeopleRequestBuilder.cs +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/PeopleRequestBuilder.cs @@ -86,6 +86,7 @@ public async Task PostAsync(PersonPostRequestDocu var errorMapping = new Dictionary> { {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, }; diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/TagsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/TagsRequestBuilder.cs index 9c9d71cde2..1abecbc2ed 100644 --- a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/TagsRequestBuilder.cs +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/TagsRequestBuilder.cs @@ -86,6 +86,7 @@ public async Task PostAsync(TagPostRequestDocument b var errorMapping = new Dictionary> { {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, }; diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/TodoItemsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/TodoItemsRequestBuilder.cs index 08e26f678b..a6608edc20 100644 --- a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/TodoItemsRequestBuilder.cs +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/TodoItemsRequestBuilder.cs @@ -86,6 +86,7 @@ public async Task PostAsync(TodoItemPostRequest var errorMapping = new Dictionary> { {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, }; diff --git a/src/Examples/OpenApiNSwagClientExample/Worker.cs b/src/Examples/OpenApiNSwagClientExample/Worker.cs index f4d8fe1166..14958e7923 100644 --- a/src/Examples/OpenApiNSwagClientExample/Worker.cs +++ b/src/Examples/OpenApiNSwagClientExample/Worker.cs @@ -45,7 +45,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) private static Task> GetPeopleAsync(ExampleApiClient apiClient, IDictionary queryString, string? ifNoneMatch, CancellationToken cancellationToken) { - return ApiResponse.TranslateAsync(() => apiClient.GetPersonCollectionAsync(queryString, ifNoneMatch, cancellationToken)); + return ApiResponse.TranslateAsync(async () => await apiClient.GetPersonCollectionAsync(queryString, ifNoneMatch, cancellationToken)); } private async Task UpdatePersonAsync(CancellationToken cancellationToken) @@ -66,7 +66,7 @@ private async Task UpdatePersonAsync(CancellationToken cancellationToken) using (_apiClient.WithPartialAttributeSerialization(patchRequest, person => person.FirstName)) { - _ = await ApiResponse.TranslateAsync(() => _apiClient.PatchPersonAsync(patchRequest.Data.Id, null, patchRequest, cancellationToken)); + _ = await ApiResponse.TranslateAsync(async () => await _apiClient.PatchPersonAsync(patchRequest.Data.Id, null, patchRequest, cancellationToken)); } } } diff --git a/src/JsonApiDotNetCore.OpenApi/ActionDescriptorExtensions.cs b/src/JsonApiDotNetCore.OpenApi/ActionDescriptorExtensions.cs index 772eed3c1d..0145751ab6 100644 --- a/src/JsonApiDotNetCore.OpenApi/ActionDescriptorExtensions.cs +++ b/src/JsonApiDotNetCore.OpenApi/ActionDescriptorExtensions.cs @@ -20,10 +20,7 @@ public static MethodInfo GetActionMethod(this ActionDescriptor descriptor) { ArgumentGuard.NotNull(descriptor); - IFilterMetadata? filterMetadata = descriptor.FilterDescriptors.Select(filterDescriptor => filterDescriptor.Filter) - .OfType().FirstOrDefault(); - - return (TFilterMetaData?)filterMetadata; + return descriptor.FilterDescriptors.Select(filterDescriptor => filterDescriptor.Filter).OfType().FirstOrDefault(); } public static ControllerParameterDescriptor? GetBodyParameterDescriptor(this ActionDescriptor descriptor) diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiActionDescriptorCollectionProvider.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiActionDescriptorCollectionProvider.cs index 39e2c40f4a..afd2608c84 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiActionDescriptorCollectionProvider.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiActionDescriptorCollectionProvider.cs @@ -1,4 +1,5 @@ using System.Reflection; +using JsonApiDotNetCore.Errors; using JsonApiDotNetCore.Middleware; using JsonApiDotNetCore.OpenApi.JsonApiMetadata; using Microsoft.AspNetCore.Mvc; @@ -39,7 +40,8 @@ private ActionDescriptorCollection GetActionDescriptors() foreach (ActionDescriptor endpoint in endpoints) { - JsonApiEndpointMetadataContainer endpointMetadataContainer = _jsonApiEndpointMetadataProvider.Get(endpoint.GetActionMethod()); + MethodInfo actionMethod = endpoint.GetActionMethod(); + JsonApiEndpointMetadataContainer endpointMetadataContainer = _jsonApiEndpointMetadataProvider.Get(actionMethod); List replacementDescriptorsForEndpoint = [ @@ -149,19 +151,14 @@ private static void UpdateBodyParameterDescriptor(ActionDescriptor endpoint, Typ if (requestBodyDescriptor == null) { - // ASP.NET model binding picks up on [FromBody] in base classes, so even when it is left out in an override, this should not be reachable. - throw new UnreachableCodeException(); - } - - requestBodyDescriptor.ParameterType = documentType; - ParameterInfo replacementParameterInfo = requestBodyDescriptor.ParameterInfo.WithParameterType(documentType); + MethodInfo actionMethod = endpoint.GetActionMethod(); - if (parameterName != null) - { - replacementParameterInfo = replacementParameterInfo.WithName(parameterName); + throw new InvalidConfigurationException( + $"The action method '{actionMethod}' on type '{actionMethod.ReflectedType?.FullName}' contains no parameter with a [FromBody] attribute."); } - requestBodyDescriptor.ParameterInfo = replacementParameterInfo; + requestBodyDescriptor.ParameterType = documentType; + requestBodyDescriptor.ParameterInfo = new ParameterInfoWrapper(requestBodyDescriptor.ParameterInfo, documentType, parameterName); } private static ActionDescriptor Clone(ActionDescriptor descriptor) diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceDataInResponse.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceDataInResponse.cs index c7ed1d02fd..948e3182de 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceDataInResponse.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceDataInResponse.cs @@ -1,4 +1,3 @@ -using System.ComponentModel.DataAnnotations; using System.Text.Json.Serialization; using JetBrains.Annotations; using JsonApiDotNetCore.OpenApi.JsonApiObjects.Links; @@ -16,7 +15,7 @@ internal sealed class ResourceDataInResponse : ResourceData [JsonPropertyName("relationships")] public RelationshipsInResponse Relationships { get; set; } = null!; - [Required] + // This would normally be { "self": "/people/5" } for GET /todoItems/1/assignee, but it is null when PeopleController is unavailable. [JsonPropertyName("links")] public LinksInResourceData Links { get; set; } = null!; diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiOperationIdSelector.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiOperationIdSelector.cs index 17642015ff..cc200014bb 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiOperationIdSelector.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiOperationIdSelector.cs @@ -1,3 +1,4 @@ +using System.Reflection; using System.Text.Json; using Humanizer; using JsonApiDotNetCore.Configuration; @@ -50,7 +51,8 @@ public string GetOperationId(ApiDescription endpoint) { ArgumentGuard.NotNull(endpoint); - ResourceType? primaryResourceType = _controllerResourceMapping.GetResourceTypeForController(endpoint.ActionDescriptor.GetActionMethod().ReflectedType); + MethodInfo actionMethod = endpoint.ActionDescriptor.GetActionMethod(); + ResourceType? primaryResourceType = _controllerResourceMapping.GetResourceTypeForController(actionMethod.ReflectedType); if (primaryResourceType == null) { diff --git a/src/JsonApiDotNetCore.OpenApi/OpenApiEndpointConvention.cs b/src/JsonApiDotNetCore.OpenApi/OpenApiEndpointConvention.cs index 1a9a71a5ba..2c33907f54 100644 --- a/src/JsonApiDotNetCore.OpenApi/OpenApiEndpointConvention.cs +++ b/src/JsonApiDotNetCore.OpenApi/OpenApiEndpointConvention.cs @@ -186,12 +186,14 @@ private IEnumerable GetErrorStatusCodesForEndpoint(JsonApiEndpoi [ HttpStatusCode.BadRequest, HttpStatusCode.Forbidden, + HttpStatusCode.NotFound, HttpStatusCode.Conflict, HttpStatusCode.UnprocessableEntity ], JsonApiEndpoint.Post => [ HttpStatusCode.BadRequest, + HttpStatusCode.NotFound, HttpStatusCode.Conflict, HttpStatusCode.UnprocessableEntity ], diff --git a/src/JsonApiDotNetCore.OpenApi/ParameterInfoExtensions.cs b/src/JsonApiDotNetCore.OpenApi/ParameterInfoExtensions.cs deleted file mode 100644 index 2a0b94f103..0000000000 --- a/src/JsonApiDotNetCore.OpenApi/ParameterInfoExtensions.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Reflection; - -namespace JsonApiDotNetCore.OpenApi; - -internal static class ParameterInfoExtensions -{ - private static readonly Lazy NameField = new(() => typeof(ParameterInfo).GetField("NameImpl", BindingFlags.Instance | BindingFlags.NonPublic)!, - LazyThreadSafetyMode.ExecutionAndPublication); - - private static readonly Lazy ParameterTypeField = - new(() => typeof(ParameterInfo).GetField("ClassImpl", BindingFlags.Instance | BindingFlags.NonPublic)!, LazyThreadSafetyMode.ExecutionAndPublication); - - public static ParameterInfo WithName(this ParameterInfo source, string name) - { - ArgumentGuard.NotNull(source); - ArgumentGuard.NotNullNorEmpty(name); - - var cloned = (ParameterInfo)source.MemberwiseClone(); - NameField.Value.SetValue(cloned, name); - - return cloned; - } - - public static ParameterInfo WithParameterType(this ParameterInfo source, Type parameterType) - { - ArgumentGuard.NotNull(source); - ArgumentGuard.NotNull(parameterType); - - var cloned = (ParameterInfo)source.MemberwiseClone(); - ParameterTypeField.Value.SetValue(cloned, parameterType); - - return cloned; - } -} diff --git a/src/JsonApiDotNetCore.OpenApi/ParameterInfoWrapper.cs b/src/JsonApiDotNetCore.OpenApi/ParameterInfoWrapper.cs new file mode 100644 index 0000000000..cc4e2c1adc --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi/ParameterInfoWrapper.cs @@ -0,0 +1,78 @@ +using System.Reflection; + +namespace JsonApiDotNetCore.OpenApi; + +/// +/// Used for parameters in action method expansion. Changes the parameter name and type, while still using all metadata of the underlying non-expanded +/// parameter. +/// +internal sealed class ParameterInfoWrapper : ParameterInfo +{ + private readonly ParameterInfo _innerParameter; + + public override ParameterAttributes Attributes => _innerParameter.Attributes; + public override IEnumerable CustomAttributes => _innerParameter.CustomAttributes; + public override object? DefaultValue => _innerParameter.DefaultValue; + public override bool HasDefaultValue => _innerParameter.HasDefaultValue; + public override MemberInfo Member => _innerParameter.Member; + public override int MetadataToken => _innerParameter.MetadataToken; + public override string? Name { get; } + public override Type ParameterType { get; } + public override int Position => _innerParameter.Position; + public override object? RawDefaultValue => _innerParameter.RawDefaultValue; + + public ParameterInfoWrapper(ParameterInfo innerParameter, Type overriddenParameterType, string? overriddenName) + { + ArgumentGuard.NotNull(innerParameter); + ArgumentGuard.NotNull(overriddenParameterType); + + _innerParameter = innerParameter; + ParameterType = overriddenParameterType; + Name = overriddenName; + } + + public override object[] GetCustomAttributes(bool inherit) + { + return _innerParameter.GetCustomAttributes(inherit); + } + + public override object[] GetCustomAttributes(Type attributeType, bool inherit) + { + return _innerParameter.GetCustomAttributes(attributeType, inherit); + } + + public override bool IsDefined(Type attributeType, bool inherit) + { + return _innerParameter.IsDefined(attributeType, inherit); + } + + public override bool Equals(object? obj) + { + return _innerParameter.Equals(obj); + } + + public override int GetHashCode() + { + return _innerParameter.GetHashCode(); + } + + public override string ToString() + { + return _innerParameter.ToString(); + } + + public override IList GetCustomAttributesData() + { + return _innerParameter.GetCustomAttributesData(); + } + + public override Type[] GetOptionalCustomModifiers() + { + return _innerParameter.GetOptionalCustomModifiers(); + } + + public override Type[] GetRequiredCustomModifiers() + { + return _innerParameter.GetRequiredCustomModifiers(); + } +} diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiOperationDocumentationFilter.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiOperationDocumentationFilter.cs index 9539e9c666..95319b5945 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiOperationDocumentationFilter.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiOperationDocumentationFilter.cs @@ -1,4 +1,5 @@ using System.Net; +using System.Reflection; using Humanizer; using JetBrains.Annotations; using JsonApiDotNetCore.Configuration; @@ -35,7 +36,7 @@ internal sealed class JsonApiOperationDocumentationFilter : IOperationFilter private const string TextQueryStringBad = "The query string is invalid."; private const string TextRequestBodyBad = "The request body is missing or malformed."; private const string TextQueryStringOrRequestBodyBad = "The query string is invalid or the request body is missing or malformed."; - private const string TextRequestBodyIncompatibleType = "A resource type in the request body is incompatible."; + private const string TextConflict = "The request body contains conflicting information or another resource with the same ID already exists."; private const string TextRequestBodyIncompatibleIdOrType = "A resource type or identifier in the request body is incompatible."; private const string TextRequestBodyValidationFailed = "Validation of the request body failed."; private const string TextRequestBodyClientId = "Client-generated IDs cannot be used at this endpoint."; @@ -79,8 +80,8 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context) operation.Responses.Clear(); } - ResourceType? resourceType = - _controllerResourceMapping.GetResourceTypeForController(context.ApiDescription.ActionDescriptor.GetActionMethod().ReflectedType); + MethodInfo actionMethod = context.ApiDescription.ActionDescriptor.GetActionMethod(); + ResourceType? resourceType = _controllerResourceMapping.GetResourceTypeForController(actionMethod.ReflectedType); if (resourceType != null) { @@ -241,7 +242,8 @@ private void ApplyPostResource(OpenApiOperation operation, ResourceType resource SetResponseDescription(operation.Responses, HttpStatusCode.Forbidden, TextRequestBodyClientId); } - SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextRequestBodyIncompatibleType); + SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, "A related resource does not exist."); + SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict); SetResponseDescription(operation.Responses, HttpStatusCode.UnprocessableEntity, TextRequestBodyValidationFailed); } @@ -373,8 +375,8 @@ private void ApplyPostRelationship(OpenApiOperation operation, RelationshipAttri $"The {rightName} were successfully added, which did not result in additional changes."); SetResponseDescription(operation.Responses, HttpStatusCode.BadRequest, TextRequestBodyBad); - SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} does not exist."); - SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextRequestBodyIncompatibleType); + SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} or a related resource does not exist."); + SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict); } private void ApplyPatchRelationship(OpenApiOperation operation, RelationshipAttribute relationship) @@ -406,8 +408,8 @@ relationship is HasOneAttribute $"The {relationship} relationship was successfully updated, which did not result in additional changes."); SetResponseDescription(operation.Responses, HttpStatusCode.BadRequest, TextRequestBodyBad); - SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} does not exist."); - SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextRequestBodyIncompatibleType); + SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} or a related resource does not exist."); + SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict); } private void ApplyDeleteRelationship(OpenApiOperation operation, RelationshipAttribute relationship) @@ -423,8 +425,8 @@ private void ApplyDeleteRelationship(OpenApiOperation operation, RelationshipAtt $"The {rightName} were successfully removed, which did not result in additional changes."); SetResponseDescription(operation.Responses, HttpStatusCode.BadRequest, TextRequestBodyBad); - SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} does not exist."); - SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextRequestBodyIncompatibleType); + SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} or a related resource does not exist."); + SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict); } private static RelationshipAttribute GetRelationshipFromRoute(ApiDescription apiDescription, ResourceType resourceType) diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs index d935a63e78..8d64640e02 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs @@ -1,6 +1,7 @@ using System.Reflection; using JsonApiDotNetCore.Controllers; using JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; +using JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; @@ -10,6 +11,7 @@ namespace JsonApiDotNetCore.OpenApi.SwaggerComponents; internal sealed class JsonApiSchemaGenerator : ISchemaGenerator { + // List of all the root types we're being called for, that need to be handled by our custom schema generators. private static readonly Type[] JsonApiDocumentTypes = [ typeof(ResourceCollectionResponseDocument<>), @@ -21,7 +23,10 @@ internal sealed class JsonApiSchemaGenerator : ISchemaGenerator typeof(ResourceIdentifierCollectionResponseDocument<>), typeof(ResourceIdentifierResponseDocument<>), typeof(NullableResourceIdentifierResponseDocument<>), - typeof(ErrorResponseDocument) + typeof(ErrorResponseDocument), + typeof(ToManyRelationshipInRequest<>), + typeof(ToOneRelationshipInRequest<>), + typeof(NullableToOneRelationshipInRequest<>) ]; private static readonly OpenApiSchema IdTypeSchema = new() diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs new file mode 100644 index 0000000000..7783c71f0c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs @@ -0,0 +1,269 @@ +using System.Net; +using FluentAssertions; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode; +using OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.ClientIdGenerationModes; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes; + +public sealed class ClientIdGenerationModesTests + : IClassFixture, ClientIdGenerationDbContext>> +{ + private readonly IntegrationTestContext, ClientIdGenerationDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly ClientIdGenerationFakers _fakers = new(); + + public ClientIdGenerationModesTests(IntegrationTestContext, ClientIdGenerationDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + testContext.UseController(); + testContext.UseController(); + } + + [Fact] + public async Task Cannot_create_resource_without_ID_when_supplying_ID_is_required() + { + // Arrange + Player newPlayer = _fakers.Player.Generate(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + ClientIdGenerationModesClient apiClient = new(requestAdapter); + + var requestBody = new PlayerPostRequestDocument + { + Data = new PlayerDataInPostRequest + { + Type = PlayerResourceType.Players, + Attributes = new PlayerAttributesInPostRequest + { + UserName = newPlayer.UserName + } + } + }; + + // Act + Func action = async () => _ = await apiClient.Players.PostAsync(requestBody); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); + error.Detail.Should().BeNull(); + error.Source.ShouldNotBeNull(); + error.Source.Pointer.Should().Be("/data"); + } + + [Fact] + public async Task Can_create_resource_with_ID_when_supplying_ID_is_required() + { + // Arrange + Player newPlayer = _fakers.Player.Generate(); + newPlayer.Id = Guid.NewGuid(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + ClientIdGenerationModesClient apiClient = new(requestAdapter); + + var requestBody = new PlayerPostRequestDocument + { + Data = new PlayerDataInPostRequest + { + Type = PlayerResourceType.Players, + Id = newPlayer.StringId, + Attributes = new PlayerAttributesInPostRequest + { + UserName = newPlayer.UserName + } + } + }; + + // Act + PlayerPrimaryResponseDocument? document = await apiClient.Players.PostAsync(requestBody); + + // Assert + document.Should().BeNull(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + Player playerInDatabase = await dbContext.Players.FirstWithIdAsync(newPlayer.Id); + + playerInDatabase.UserName.Should().Be(newPlayer.UserName); + }); + } + + [Fact] + public async Task Can_create_resource_without_ID_when_supplying_ID_is_allowed() + { + // Arrange + Game newGame = _fakers.Game.Generate(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + ClientIdGenerationModesClient apiClient = new(requestAdapter); + + var requestBody = new GamePostRequestDocument + { + Data = new GameDataInPostRequest + { + Type = GameResourceType.Games, + Attributes = new GameAttributesInPostRequest + { + Title = newGame.Title, + PurchasePrice = (double)newGame.PurchasePrice + } + } + }; + + // Act + GamePrimaryResponseDocument? document = await apiClient.Games.PostAsync(requestBody); + + // Assert + document.ShouldNotBeNull(); + document.Data.ShouldNotBeNull(); + document.Data.Id.ShouldNotBeNullOrEmpty(); + + Guid newGameId = Guid.Parse(document.Data.Id); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + Game gameInDatabase = await dbContext.Games.FirstWithIdAsync(newGameId); + + gameInDatabase.Title.Should().Be(newGame.Title); + gameInDatabase.PurchasePrice.Should().Be(newGame.PurchasePrice); + }); + } + + [Fact] + public async Task Can_create_resource_with_ID_when_supplying_ID_is_allowed() + { + // Arrange + Game newGame = _fakers.Game.Generate(); + newGame.Id = Guid.NewGuid(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + ClientIdGenerationModesClient apiClient = new(requestAdapter); + + var requestBody = new GamePostRequestDocument + { + Data = new GameDataInPostRequest + { + Type = GameResourceType.Games, + Id = newGame.StringId, + Attributes = new GameAttributesInPostRequest + { + Title = newGame.Title, + PurchasePrice = (double)newGame.PurchasePrice + } + } + }; + + // Act + GamePrimaryResponseDocument? document = await apiClient.Games.PostAsync(requestBody); + + // Assert + document.Should().BeNull(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + Game gameInDatabase = await dbContext.Games.FirstWithIdAsync(newGame.Id); + + gameInDatabase.Title.Should().Be(newGame.Title); + gameInDatabase.PurchasePrice.Should().Be(newGame.PurchasePrice); + }); + } + + [Fact] + public async Task Cannot_create_resource_with_existing_ID_when_supplying_ID_is_allowed() + { + // Arrange + Game existingGame = _fakers.Game.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.Games.Add(existingGame); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + ClientIdGenerationModesClient apiClient = new(requestAdapter); + + var requestBody = new GamePostRequestDocument + { + Data = new GameDataInPostRequest + { + Type = GameResourceType.Games, + Id = existingGame.StringId, + Attributes = new GameAttributesInPostRequest + { + Title = existingGame.Title, + PurchasePrice = (double)existingGame.PurchasePrice + } + } + }; + + // Act + Func action = async () => _ = await apiClient.Games.PostAsync(requestBody); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.Conflict); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Errors.ElementAt(0); + error.Status.Should().Be("409"); + error.Title.Should().Be("Another resource with the specified ID already exists."); + error.Detail.Should().Be($"Another resource of type 'games' with ID '{existingGame.StringId}' already exists."); + } + + [Fact] + public async Task Can_create_resource_without_ID_when_supplying_ID_is_forbidden() + { + // Arrange + PlayerGroup newPlayerGroup = _fakers.Group.Generate(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + ClientIdGenerationModesClient apiClient = new(requestAdapter); + + var requestBody = new PlayerGroupPostRequestDocument + { + Data = new PlayerGroupDataInPostRequest + { + Type = PlayerGroupResourceType.PlayerGroups, + Attributes = new PlayerGroupAttributesInPostRequest + { + Name = newPlayerGroup.Name + } + } + }; + + // Act + PlayerGroupPrimaryResponseDocument? document = await apiClient.PlayerGroups.PostAsync(requestBody); + + // Assert + document.ShouldNotBeNull(); + document.Data.ShouldNotBeNull(); + document.Data.Id.ShouldNotBeNullOrEmpty(); + + long newPlayerGroupId = long.Parse(document.Data.Id); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + PlayerGroup playerGroupInDatabase = await dbContext.PlayerGroups.FirstWithIdAsync(newPlayerGroupId); + + playerGroupInDatabase.Name.Should().Be(newPlayerGroup.Name); + }); + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/ClientIdGenerationModesClient.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/ClientIdGenerationModesClient.cs new file mode 100644 index 0000000000..db5524c8a4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/ClientIdGenerationModesClient.cs @@ -0,0 +1,54 @@ +// +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Store; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Serialization.Form; +using Microsoft.Kiota.Serialization.Json; +using Microsoft.Kiota.Serialization.Multipart; +using Microsoft.Kiota.Serialization.Text; +using OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Games; +using OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.PlayerGroups; +using OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Players; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode { + /// + /// The main entry point of the SDK, exposes the configuration and the fluent API. + /// + public class ClientIdGenerationModesClient : BaseRequestBuilder { + /// The games property + public GamesRequestBuilder Games { get => + new GamesRequestBuilder(PathParameters, RequestAdapter); + } + /// The playerGroups property + public PlayerGroupsRequestBuilder PlayerGroups { get => + new PlayerGroupsRequestBuilder(PathParameters, RequestAdapter); + } + /// The players property + public PlayersRequestBuilder Players { get => + new PlayersRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new ClientIdGenerationModesClient and sets the default values. + /// + /// The backing store to use for the models. + /// The request adapter to use to execute the requests. + public ClientIdGenerationModesClient(IRequestAdapter requestAdapter, IBackingStoreFactory backingStore = default) : base(requestAdapter, "{+baseurl}", new Dictionary()) { + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + if (string.IsNullOrEmpty(RequestAdapter.BaseUrl)) { + RequestAdapter.BaseUrl = "http://localhost"; + } + PathParameters.TryAdd("baseurl", RequestAdapter.BaseUrl); + RequestAdapter.EnableBackingStore(backingStore); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Games/GamesRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Games/GamesRequestBuilder.cs new file mode 100644 index 0000000000..fb3b4d0c7f --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Games/GamesRequestBuilder.cs @@ -0,0 +1,95 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Games { + /// + /// Builds and executes requests for operations under \games + /// + public class GamesRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new GamesRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public GamesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/games{?query*}", pathParameters) { + } + /// + /// Instantiates a new GamesRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public GamesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/games{?query*}", rawUrl) { + } + /// + /// Creates a new game. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PostAsync(GamePostRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(GamePostRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, GamePrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Creates a new game. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPostRequestInformation(GamePostRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(GamePostRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public GamesRequestBuilder WithUrl(string rawUrl) { + return new GamesRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Creates a new game. + /// + public class GamesRequestBuilderPostQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/DataInResponse.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/DataInResponse.cs new file mode 100644 index 0000000000..2bed8a801b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/DataInResponse.cs @@ -0,0 +1,79 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class DataInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#nullable restore +#else + public string Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#endif + /// + /// Instantiates a new dataInResponse and sets the default values. + /// + public DataInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("type")?.GetStringValue(); + return mappingValue switch { + "games" => new GameDataInResponse(), + "playerGroups" => new PlayerGroupDataInResponse(), + "players" => new PlayerDataInResponse(), + _ => new DataInResponse(), + }; + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteStringValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorLinks.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorLinks.cs new file mode 100644 index 0000000000..28675aca73 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorLinks.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ErrorLinks : IBackedModel, IParsable { + /// The about property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? About { + get { return BackingStore?.Get("about"); } + set { BackingStore?.Set("about", value); } + } +#nullable restore +#else + public string About { + get { return BackingStore?.Get("about"); } + set { BackingStore?.Set("about", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The type property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#nullable restore +#else + public string Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#endif + /// + /// Instantiates a new errorLinks and sets the default values. + /// + public ErrorLinks() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorLinks CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorLinks(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"about", n => { About = n.GetStringValue(); } }, + {"type", n => { Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("about", About); + writer.WriteStringValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorObject.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorObject.cs new file mode 100644 index 0000000000..bf6ea30e08 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorObject.cs @@ -0,0 +1,169 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ErrorObject : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The code property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Code { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } +#nullable restore +#else + public string Code { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } +#endif + /// The detail property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Detail { + get { return BackingStore?.Get("detail"); } + set { BackingStore?.Set("detail", value); } + } +#nullable restore +#else + public string Detail { + get { return BackingStore?.Get("detail"); } + set { BackingStore?.Set("detail", value); } + } +#endif + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorLinks? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public ErrorLinks Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorObject_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ErrorObject_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The source property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorSource? Source { + get { return BackingStore?.Get("source"); } + set { BackingStore?.Set("source", value); } + } +#nullable restore +#else + public ErrorSource Source { + get { return BackingStore?.Get("source"); } + set { BackingStore?.Set("source", value); } + } +#endif + /// The status property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Status { + get { return BackingStore?.Get("status"); } + set { BackingStore?.Set("status", value); } + } +#nullable restore +#else + public string Status { + get { return BackingStore?.Get("status"); } + set { BackingStore?.Set("status", value); } + } +#endif + /// The title property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#nullable restore +#else + public string Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#endif + /// + /// Instantiates a new errorObject and sets the default values. + /// + public ErrorObject() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorObject CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorObject(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"code", n => { Code = n.GetStringValue(); } }, + {"detail", n => { Detail = n.GetStringValue(); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"links", n => { Links = n.GetObjectValue(ErrorLinks.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ErrorObject_meta.CreateFromDiscriminatorValue); } }, + {"source", n => { Source = n.GetObjectValue(ErrorSource.CreateFromDiscriminatorValue); } }, + {"status", n => { Status = n.GetStringValue(); } }, + {"title", n => { Title = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("code", Code); + writer.WriteStringValue("detail", Detail); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("source", Source); + writer.WriteStringValue("status", Status); + writer.WriteStringValue("title", Title); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorObject_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorObject_meta.cs new file mode 100644 index 0000000000..43612a1c10 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorObject_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ErrorObject_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new errorObject_meta and sets the default values. + /// + public ErrorObject_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorObject_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorObject_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorResponseDocument.cs new file mode 100644 index 0000000000..44d6ad51be --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorResponseDocument.cs @@ -0,0 +1,92 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ErrorResponseDocument : ApiException, IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The errors property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Errors { + get { return BackingStore?.Get?>("errors"); } + set { BackingStore?.Set("errors", value); } + } +#nullable restore +#else + public List Errors { + get { return BackingStore?.Get>("errors"); } + set { BackingStore?.Set("errors", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInErrorDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInErrorDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The primary error message. + public override string Message { get => base.Message; } + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ErrorResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new errorResponseDocument and sets the default values. + /// + public ErrorResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"errors", n => { Errors = n.GetCollectionOfObjectValues(ErrorObject.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInErrorDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ErrorResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("errors", Errors); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorResponseDocument_meta.cs new file mode 100644 index 0000000000..59c3d49517 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ErrorResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new errorResponseDocument_meta and sets the default values. + /// + public ErrorResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorSource.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorSource.cs new file mode 100644 index 0000000000..0f6efd2492 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ErrorSource.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ErrorSource : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The header property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Header { + get { return BackingStore?.Get("header"); } + set { BackingStore?.Set("header", value); } + } +#nullable restore +#else + public string Header { + get { return BackingStore?.Get("header"); } + set { BackingStore?.Set("header", value); } + } +#endif + /// The parameter property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Parameter { + get { return BackingStore?.Get("parameter"); } + set { BackingStore?.Set("parameter", value); } + } +#nullable restore +#else + public string Parameter { + get { return BackingStore?.Get("parameter"); } + set { BackingStore?.Set("parameter", value); } + } +#endif + /// The pointer property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Pointer { + get { return BackingStore?.Get("pointer"); } + set { BackingStore?.Set("pointer", value); } + } +#nullable restore +#else + public string Pointer { + get { return BackingStore?.Get("pointer"); } + set { BackingStore?.Set("pointer", value); } + } +#endif + /// + /// Instantiates a new errorSource and sets the default values. + /// + public ErrorSource() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorSource CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorSource(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"header", n => { Header = n.GetStringValue(); } }, + {"parameter", n => { Parameter = n.GetStringValue(); } }, + {"pointer", n => { Pointer = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("header", Header); + writer.WriteStringValue("parameter", Parameter); + writer.WriteStringValue("pointer", Pointer); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameAttributesInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameAttributesInPostRequest.cs new file mode 100644 index 0000000000..331274d9cc --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameAttributesInPostRequest.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class GameAttributesInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The purchasePrice property + public double? PurchasePrice { + get { return BackingStore?.Get("purchasePrice"); } + set { BackingStore?.Set("purchasePrice", value); } + } + /// The title property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#nullable restore +#else + public string Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#endif + /// + /// Instantiates a new gameAttributesInPostRequest and sets the default values. + /// + public GameAttributesInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static GameAttributesInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new GameAttributesInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"purchasePrice", n => { PurchasePrice = n.GetDoubleValue(); } }, + {"title", n => { Title = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteDoubleValue("purchasePrice", PurchasePrice); + writer.WriteStringValue("title", Title); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameAttributesInResponse.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameAttributesInResponse.cs new file mode 100644 index 0000000000..46bdc2ca7d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameAttributesInResponse.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class GameAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The purchasePrice property + public double? PurchasePrice { + get { return BackingStore?.Get("purchasePrice"); } + set { BackingStore?.Set("purchasePrice", value); } + } + /// The title property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#nullable restore +#else + public string Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#endif + /// + /// Instantiates a new gameAttributesInResponse and sets the default values. + /// + public GameAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static GameAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new GameAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"purchasePrice", n => { PurchasePrice = n.GetDoubleValue(); } }, + {"title", n => { Title = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteDoubleValue("purchasePrice", PurchasePrice); + writer.WriteStringValue("title", Title); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameDataInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameDataInPostRequest.cs new file mode 100644 index 0000000000..08f113a294 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameDataInPostRequest.cs @@ -0,0 +1,80 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class GameDataInPostRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public GameAttributesInPostRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public GameAttributesInPostRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property + public GameResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new gameDataInPostRequest and sets the default values. + /// + public GameDataInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static GameDataInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new GameDataInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(GameAttributesInPostRequest.CreateFromDiscriminatorValue); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteStringValue("id", Id); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameDataInResponse.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameDataInResponse.cs new file mode 100644 index 0000000000..f95436b302 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameDataInResponse.cs @@ -0,0 +1,81 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class GameDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public GameAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public GameAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public GameDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public GameDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new GameDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new GameDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(GameAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(GameDataInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameDataInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameDataInResponse_meta.cs new file mode 100644 index 0000000000..1b4695fc8e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class GameDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new gameDataInResponse_meta and sets the default values. + /// + public GameDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static GameDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new GameDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameIdentifier.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameIdentifier.cs new file mode 100644 index 0000000000..39bc07e313 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameIdentifier.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class GameIdentifier : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property + public GameResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new gameIdentifier and sets the default values. + /// + public GameIdentifier() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static GameIdentifier CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new GameIdentifier(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GamePostRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GamePostRequestDocument.cs new file mode 100644 index 0000000000..c47a2d2e65 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GamePostRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class GamePostRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public GameDataInPostRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public GameDataInPostRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new gamePostRequestDocument and sets the default values. + /// + public GamePostRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static GamePostRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new GamePostRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(GameDataInPostRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GamePrimaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GamePrimaryResponseDocument.cs new file mode 100644 index 0000000000..0e90abce17 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GamePrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class GamePrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Games? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public Games Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public GamePrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public GamePrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new gamePrimaryResponseDocument and sets the default values. + /// + public GamePrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static GamePrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new GamePrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(Games.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(GamePrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GamePrimaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GamePrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..eab9c4020f --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GamePrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class GamePrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new gamePrimaryResponseDocument_meta and sets the default values. + /// + public GamePrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static GamePrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new GamePrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameResourceType.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameResourceType.cs new file mode 100644 index 0000000000..055529d70d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/GameResourceType.cs @@ -0,0 +1,9 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public enum GameResourceType { + [EnumMember(Value = "games")] + Games, + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/Games.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/Games.cs new file mode 100644 index 0000000000..36b228b442 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/Games.cs @@ -0,0 +1,81 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class Games : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public GameAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public GameAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Games_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public Games_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new Games CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Games(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(GameAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(Games_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/Games_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/Games_meta.cs new file mode 100644 index 0000000000..2942c9c1df --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/Games_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class Games_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new games_meta and sets the default values. + /// + public Games_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static Games_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Games_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/LinksInErrorDocument.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/LinksInErrorDocument.cs new file mode 100644 index 0000000000..235eace75f --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/LinksInErrorDocument.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class LinksInErrorDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInErrorDocument and sets the default values. + /// + public LinksInErrorDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInErrorDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInErrorDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/LinksInRelationship.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/LinksInRelationship.cs new file mode 100644 index 0000000000..31d80bed66 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/LinksInRelationship.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class LinksInRelationship : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The related property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#nullable restore +#else + public string Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInRelationship and sets the default values. + /// + public LinksInRelationship() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInRelationship CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInRelationship(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"related", n => { Related = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("related", Related); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/LinksInResourceData.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/LinksInResourceData.cs new file mode 100644 index 0000000000..cee8c101b9 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/LinksInResourceData.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class LinksInResourceData : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceData and sets the default values. + /// + public LinksInResourceData() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceData CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceData(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/LinksInResourceDocument.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/LinksInResourceDocument.cs new file mode 100644 index 0000000000..168a7f98e1 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/LinksInResourceDocument.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class LinksInResourceDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceDocument and sets the default values. + /// + public LinksInResourceDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerAttributesInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerAttributesInPostRequest.cs new file mode 100644 index 0000000000..bafff683fc --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerAttributesInPostRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerAttributesInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The userName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? UserName { + get { return BackingStore?.Get("userName"); } + set { BackingStore?.Set("userName", value); } + } +#nullable restore +#else + public string UserName { + get { return BackingStore?.Get("userName"); } + set { BackingStore?.Set("userName", value); } + } +#endif + /// + /// Instantiates a new playerAttributesInPostRequest and sets the default values. + /// + public PlayerAttributesInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerAttributesInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerAttributesInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"userName", n => { UserName = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("userName", UserName); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerAttributesInResponse.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerAttributesInResponse.cs new file mode 100644 index 0000000000..055d92c78f --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerAttributesInResponse.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The userName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? UserName { + get { return BackingStore?.Get("userName"); } + set { BackingStore?.Set("userName", value); } + } +#nullable restore +#else + public string UserName { + get { return BackingStore?.Get("userName"); } + set { BackingStore?.Set("userName", value); } + } +#endif + /// + /// Instantiates a new playerAttributesInResponse and sets the default values. + /// + public PlayerAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"userName", n => { UserName = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("userName", UserName); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerDataInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerDataInPostRequest.cs new file mode 100644 index 0000000000..ce693cc7e6 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerDataInPostRequest.cs @@ -0,0 +1,96 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerDataInPostRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerAttributesInPostRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public PlayerAttributesInPostRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerRelationshipsInPostRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public PlayerRelationshipsInPostRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public PlayerResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new playerDataInPostRequest and sets the default values. + /// + public PlayerDataInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerDataInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerDataInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(PlayerAttributesInPostRequest.CreateFromDiscriminatorValue); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"relationships", n => { Relationships = n.GetObjectValue(PlayerRelationshipsInPostRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerDataInResponse.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerDataInResponse.cs new file mode 100644 index 0000000000..bee3cc5a2c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerDataInResponse.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public PlayerAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public PlayerDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public PlayerRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new PlayerDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(PlayerAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(PlayerDataInResponse_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(PlayerRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerDataInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerDataInResponse_meta.cs new file mode 100644 index 0000000000..87fcf707d9 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new playerDataInResponse_meta and sets the default values. + /// + public PlayerDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupAttributesInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupAttributesInPostRequest.cs new file mode 100644 index 0000000000..5c2ef8f2aa --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupAttributesInPostRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroupAttributesInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new playerGroupAttributesInPostRequest and sets the default values. + /// + public PlayerGroupAttributesInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerGroupAttributesInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroupAttributesInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupAttributesInResponse.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupAttributesInResponse.cs new file mode 100644 index 0000000000..cfec46d5cc --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupAttributesInResponse.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroupAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new playerGroupAttributesInResponse and sets the default values. + /// + public PlayerGroupAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerGroupAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroupAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupDataInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupDataInPostRequest.cs new file mode 100644 index 0000000000..59ce873ed1 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupDataInPostRequest.cs @@ -0,0 +1,80 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroupDataInPostRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerGroupAttributesInPostRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public PlayerGroupAttributesInPostRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerGroupRelationshipsInPostRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public PlayerGroupRelationshipsInPostRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public PlayerGroupResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new playerGroupDataInPostRequest and sets the default values. + /// + public PlayerGroupDataInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerGroupDataInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroupDataInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(PlayerGroupAttributesInPostRequest.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(PlayerGroupRelationshipsInPostRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupDataInResponse.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupDataInResponse.cs new file mode 100644 index 0000000000..e2d32ceff5 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupDataInResponse.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroupDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerGroupAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public PlayerGroupAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerGroupDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public PlayerGroupDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerGroupRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public PlayerGroupRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new PlayerGroupDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroupDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(PlayerGroupAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(PlayerGroupDataInResponse_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(PlayerGroupRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupDataInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupDataInResponse_meta.cs new file mode 100644 index 0000000000..3bc51918dc --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroupDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new playerGroupDataInResponse_meta and sets the default values. + /// + public PlayerGroupDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerGroupDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroupDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupIdentifier.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupIdentifier.cs new file mode 100644 index 0000000000..1b5e77effe --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupIdentifier.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroupIdentifier : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property + public PlayerGroupResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new playerGroupIdentifier and sets the default values. + /// + public PlayerGroupIdentifier() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerGroupIdentifier CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroupIdentifier(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupPostRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupPostRequestDocument.cs new file mode 100644 index 0000000000..5110a8a0d8 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupPostRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroupPostRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerGroupDataInPostRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public PlayerGroupDataInPostRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new playerGroupPostRequestDocument and sets the default values. + /// + public PlayerGroupPostRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerGroupPostRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroupPostRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(PlayerGroupDataInPostRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupPrimaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupPrimaryResponseDocument.cs new file mode 100644 index 0000000000..f5d3233277 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupPrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroupPrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerGroups? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public PlayerGroups Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerGroupPrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public PlayerGroupPrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new playerGroupPrimaryResponseDocument and sets the default values. + /// + public PlayerGroupPrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerGroupPrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroupPrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(PlayerGroups.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(PlayerGroupPrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupPrimaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupPrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..310e68e0a5 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupPrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroupPrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new playerGroupPrimaryResponseDocument_meta and sets the default values. + /// + public PlayerGroupPrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerGroupPrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroupPrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupRelationshipsInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupRelationshipsInPostRequest.cs new file mode 100644 index 0000000000..0e0e6a1706 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupRelationshipsInPostRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroupRelationshipsInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The players property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyPlayerInRequest? Players { + get { return BackingStore?.Get("players"); } + set { BackingStore?.Set("players", value); } + } +#nullable restore +#else + public ToManyPlayerInRequest Players { + get { return BackingStore?.Get("players"); } + set { BackingStore?.Set("players", value); } + } +#endif + /// + /// Instantiates a new playerGroupRelationshipsInPostRequest and sets the default values. + /// + public PlayerGroupRelationshipsInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerGroupRelationshipsInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroupRelationshipsInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"players", n => { Players = n.GetObjectValue(ToManyPlayerInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("players", Players); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupRelationshipsInResponse.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupRelationshipsInResponse.cs new file mode 100644 index 0000000000..85d0d3ab54 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupRelationshipsInResponse.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroupRelationshipsInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The players property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyPlayerInResponse? Players { + get { return BackingStore?.Get("players"); } + set { BackingStore?.Set("players", value); } + } +#nullable restore +#else + public ToManyPlayerInResponse Players { + get { return BackingStore?.Get("players"); } + set { BackingStore?.Set("players", value); } + } +#endif + /// + /// Instantiates a new playerGroupRelationshipsInResponse and sets the default values. + /// + public PlayerGroupRelationshipsInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerGroupRelationshipsInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroupRelationshipsInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"players", n => { Players = n.GetObjectValue(ToManyPlayerInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("players", Players); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupResourceType.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupResourceType.cs new file mode 100644 index 0000000000..0cb78c91da --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroupResourceType.cs @@ -0,0 +1,9 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public enum PlayerGroupResourceType { + [EnumMember(Value = "playerGroups")] + PlayerGroups, + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroups.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroups.cs new file mode 100644 index 0000000000..4dd61dc916 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroups.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroups : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerGroupAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public PlayerGroupAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerGroups_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public PlayerGroups_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerGroupRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public PlayerGroupRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new PlayerGroups CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroups(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(PlayerGroupAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(PlayerGroups_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(PlayerGroupRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroups_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroups_meta.cs new file mode 100644 index 0000000000..952fee4d45 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerGroups_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerGroups_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new playerGroups_meta and sets the default values. + /// + public PlayerGroups_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerGroups_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerGroups_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerIdentifier.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerIdentifier.cs new file mode 100644 index 0000000000..c75f852607 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerIdentifier.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerIdentifier : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property + public PlayerResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new playerIdentifier and sets the default values. + /// + public PlayerIdentifier() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerIdentifier CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerIdentifier(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerPostRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerPostRequestDocument.cs new file mode 100644 index 0000000000..dc8a6e64ea --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerPostRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerPostRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerDataInPostRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public PlayerDataInPostRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new playerPostRequestDocument and sets the default values. + /// + public PlayerPostRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerPostRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerPostRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(PlayerDataInPostRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerPrimaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerPrimaryResponseDocument.cs new file mode 100644 index 0000000000..6c71def1fd --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerPrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerPrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Players? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public Players Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerPrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public PlayerPrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new playerPrimaryResponseDocument and sets the default values. + /// + public PlayerPrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerPrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerPrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(Players.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(PlayerPrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerPrimaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerPrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..8044378862 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerPrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerPrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new playerPrimaryResponseDocument_meta and sets the default values. + /// + public PlayerPrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerPrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerPrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerRelationshipsInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerRelationshipsInPostRequest.cs new file mode 100644 index 0000000000..68efa80e80 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerRelationshipsInPostRequest.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerRelationshipsInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The memberOf property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyPlayerGroupInRequest? MemberOf { + get { return BackingStore?.Get("memberOf"); } + set { BackingStore?.Set("memberOf", value); } + } +#nullable restore +#else + public ToManyPlayerGroupInRequest MemberOf { + get { return BackingStore?.Get("memberOf"); } + set { BackingStore?.Set("memberOf", value); } + } +#endif + /// The ownedGames property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyGameInRequest? OwnedGames { + get { return BackingStore?.Get("ownedGames"); } + set { BackingStore?.Set("ownedGames", value); } + } +#nullable restore +#else + public ToManyGameInRequest OwnedGames { + get { return BackingStore?.Get("ownedGames"); } + set { BackingStore?.Set("ownedGames", value); } + } +#endif + /// + /// Instantiates a new playerRelationshipsInPostRequest and sets the default values. + /// + public PlayerRelationshipsInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerRelationshipsInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerRelationshipsInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"memberOf", n => { MemberOf = n.GetObjectValue(ToManyPlayerGroupInRequest.CreateFromDiscriminatorValue); } }, + {"ownedGames", n => { OwnedGames = n.GetObjectValue(ToManyGameInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("memberOf", MemberOf); + writer.WriteObjectValue("ownedGames", OwnedGames); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerRelationshipsInResponse.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerRelationshipsInResponse.cs new file mode 100644 index 0000000000..4e3ffd4f8f --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerRelationshipsInResponse.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class PlayerRelationshipsInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The memberOf property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyPlayerGroupInResponse? MemberOf { + get { return BackingStore?.Get("memberOf"); } + set { BackingStore?.Set("memberOf", value); } + } +#nullable restore +#else + public ToManyPlayerGroupInResponse MemberOf { + get { return BackingStore?.Get("memberOf"); } + set { BackingStore?.Set("memberOf", value); } + } +#endif + /// The ownedGames property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyGameInResponse? OwnedGames { + get { return BackingStore?.Get("ownedGames"); } + set { BackingStore?.Set("ownedGames", value); } + } +#nullable restore +#else + public ToManyGameInResponse OwnedGames { + get { return BackingStore?.Get("ownedGames"); } + set { BackingStore?.Set("ownedGames", value); } + } +#endif + /// + /// Instantiates a new playerRelationshipsInResponse and sets the default values. + /// + public PlayerRelationshipsInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PlayerRelationshipsInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PlayerRelationshipsInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"memberOf", n => { MemberOf = n.GetObjectValue(ToManyPlayerGroupInResponse.CreateFromDiscriminatorValue); } }, + {"ownedGames", n => { OwnedGames = n.GetObjectValue(ToManyGameInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("memberOf", MemberOf); + writer.WriteObjectValue("ownedGames", OwnedGames); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerResourceType.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerResourceType.cs new file mode 100644 index 0000000000..e0d3635e75 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/PlayerResourceType.cs @@ -0,0 +1,9 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public enum PlayerResourceType { + [EnumMember(Value = "players")] + Players, + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/Players.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/Players.cs new file mode 100644 index 0000000000..ab0c37c8b0 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/Players.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class Players : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public PlayerAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Players_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public Players_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PlayerRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public PlayerRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new Players CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Players(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(PlayerAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(Players_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(PlayerRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/Players_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/Players_meta.cs new file mode 100644 index 0000000000..597ebff0ea --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/Players_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class Players_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new players_meta and sets the default values. + /// + public Players_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static Players_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Players_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyGameInRequest.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyGameInRequest.cs new file mode 100644 index 0000000000..f421681fa4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyGameInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ToManyGameInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new toManyGameInRequest and sets the default values. + /// + public ToManyGameInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyGameInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyGameInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(GameIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyGameInResponse.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyGameInResponse.cs new file mode 100644 index 0000000000..8453e6bb4d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyGameInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ToManyGameInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyGameInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ToManyGameInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new toManyGameInResponse and sets the default values. + /// + public ToManyGameInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyGameInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyGameInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(GameIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ToManyGameInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyGameInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyGameInResponse_meta.cs new file mode 100644 index 0000000000..58351c6d89 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyGameInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ToManyGameInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new toManyGameInResponse_meta and sets the default values. + /// + public ToManyGameInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyGameInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyGameInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerGroupInRequest.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerGroupInRequest.cs new file mode 100644 index 0000000000..f06a7725fe --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerGroupInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ToManyPlayerGroupInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new toManyPlayerGroupInRequest and sets the default values. + /// + public ToManyPlayerGroupInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyPlayerGroupInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyPlayerGroupInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(PlayerGroupIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerGroupInResponse.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerGroupInResponse.cs new file mode 100644 index 0000000000..b5eae74093 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerGroupInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ToManyPlayerGroupInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyPlayerGroupInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ToManyPlayerGroupInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new toManyPlayerGroupInResponse and sets the default values. + /// + public ToManyPlayerGroupInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyPlayerGroupInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyPlayerGroupInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(PlayerGroupIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ToManyPlayerGroupInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerGroupInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerGroupInResponse_meta.cs new file mode 100644 index 0000000000..c3bc834950 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerGroupInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ToManyPlayerGroupInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new toManyPlayerGroupInResponse_meta and sets the default values. + /// + public ToManyPlayerGroupInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyPlayerGroupInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyPlayerGroupInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerInRequest.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerInRequest.cs new file mode 100644 index 0000000000..53b93e18e6 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ToManyPlayerInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new toManyPlayerInRequest and sets the default values. + /// + public ToManyPlayerInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyPlayerInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyPlayerInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(PlayerIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerInResponse.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerInResponse.cs new file mode 100644 index 0000000000..b4d9d442ba --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ToManyPlayerInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyPlayerInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ToManyPlayerInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new toManyPlayerInResponse and sets the default values. + /// + public ToManyPlayerInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyPlayerInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyPlayerInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(PlayerIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ToManyPlayerInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerInResponse_meta.cs new file mode 100644 index 0000000000..4576580ef7 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Models/ToManyPlayerInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models { + public class ToManyPlayerInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new toManyPlayerInResponse_meta and sets the default values. + /// + public ToManyPlayerInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyPlayerInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyPlayerInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/PlayerGroups/PlayerGroupsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/PlayerGroups/PlayerGroupsRequestBuilder.cs new file mode 100644 index 0000000000..7328dd8195 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/PlayerGroups/PlayerGroupsRequestBuilder.cs @@ -0,0 +1,96 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.PlayerGroups { + /// + /// Builds and executes requests for operations under \playerGroups + /// + public class PlayerGroupsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new PlayerGroupsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public PlayerGroupsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/playerGroups{?query*}", pathParameters) { + } + /// + /// Instantiates a new PlayerGroupsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public PlayerGroupsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/playerGroups{?query*}", rawUrl) { + } + /// + /// Creates a new playerGroup. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PostAsync(PlayerGroupPostRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(PlayerGroupPostRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, PlayerGroupPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Creates a new playerGroup. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPostRequestInformation(PlayerGroupPostRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(PlayerGroupPostRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public PlayerGroupsRequestBuilder WithUrl(string rawUrl) { + return new PlayerGroupsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Creates a new playerGroup. + /// + public class PlayerGroupsRequestBuilderPostQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Players/PlayersRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Players/PlayersRequestBuilder.cs new file mode 100644 index 0000000000..a4ccec23eb --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Players/PlayersRequestBuilder.cs @@ -0,0 +1,95 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.ClientIdGenerationModes.GeneratedCode.Players { + /// + /// Builds and executes requests for operations under \players + /// + public class PlayersRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new PlayersRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public PlayersRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/players{?query*}", pathParameters) { + } + /// + /// Instantiates a new PlayersRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public PlayersRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/players{?query*}", rawUrl) { + } + /// + /// Creates a new player. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PostAsync(PlayerPostRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(PlayerPostRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, PlayerPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Creates a new player. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPostRequestInformation(PlayerPostRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(PlayerPostRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public PlayersRequestBuilder WithUrl(string rawUrl) { + return new PlayersRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Creates a new player. + /// + public class PlayersRequestBuilderPostQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs b/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs index 6d38e6cf9d..4f77f8f859 100644 --- a/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs +++ b/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs @@ -14,13 +14,13 @@ namespace OpenApiKiotaEndToEndTests.Headers; -public sealed class ETagTests : IClassFixture, HeadersDbContext>> +public sealed class ETagTests : IClassFixture, HeaderDbContext>> { - private readonly IntegrationTestContext, HeadersDbContext> _testContext; + private readonly IntegrationTestContext, HeaderDbContext> _testContext; private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; private readonly HeaderFakers _fakers = new(); - public ETagTests(IntegrationTestContext, HeadersDbContext> testContext, ITestOutputHelper testOutputHelper) + public ETagTests(IntegrationTestContext, HeaderDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); @@ -55,7 +55,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.Should().BeNullOrEmpty(); - headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().NotBeNullOrEmpty(); + string[] eTagHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); + eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues[0].Should().Match("\"*\""); } [Fact] @@ -85,13 +87,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().NotBeNullOrEmpty(); + string[] eTagHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); + eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues[0].Should().Match("\"*\""); } [Fact] public async Task Returns_no_ETag_for_failed_GET_request() { // Arrange + string unknownCountryId = Unknown.StringId.For(); + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); var apiClient = new HeadersClient(requestAdapter); @@ -101,13 +107,18 @@ public async Task Returns_no_ETag_for_failed_GET_request() }; // Act - Func> action = () => apiClient.Countries[Unknown.StringId.For()] - .GetAsync(configuration => configuration.Options.Add(headerInspector)); + Func action = async () => await apiClient.Countries[unknownCountryId].GetAsync(configuration => configuration.Options.Add(headerInspector)); // Assert ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); exception.Errors.ShouldHaveCount(1); - exception.Errors[0].Status.Should().Be(((int)HttpStatusCode.NotFound).ToString()); + + ErrorObject error = exception.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("The requested resource does not exist."); + error.Detail.Should().Be($"Resource of type 'countries' with ID '{unknownCountryId}' does not exist."); headerInspector.ResponseHeaders.Should().NotContainKey(HeaderNames.ETag); } @@ -126,8 +137,7 @@ public async Task Returns_no_ETag_for_POST_request() InspectResponseHeaders = true }; - // Act - CountryPrimaryResponseDocument? response = await apiClient.Countries.PostAsync(new CountryPostRequestDocument + var requestBody = new CountryPostRequestDocument { Data = new CountryDataInPostRequest { @@ -138,7 +148,11 @@ public async Task Returns_no_ETag_for_POST_request() Population = newCountry.Population } } - }, configuration => configuration.Options.Add(headerInspector)); + }; + + // Act + CountryPrimaryResponseDocument? response = + await apiClient.Countries.PostAsync(requestBody, configuration => configuration.Options.Add(headerInspector)); // Assert response.ShouldNotBeNull(); @@ -173,7 +187,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => headerInspector.ResponseHeaders.Clear(); // Act - Func> action = () => apiClient.Countries.GetAsync(configuration => + Func action = async () => await apiClient.Countries.GetAsync(configuration => { configuration.Headers.Add(HeaderNames.IfNoneMatch, responseETag); configuration.Options.Add(headerInspector); @@ -181,9 +195,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert ApiException exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.Message.Should().Be("The server returned an unexpected status code and no error factory is registered for this code: 304"); exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotModified); - headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().Equal([responseETag]); + string[] eTagHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); + eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues[0].Should().Be(responseETag); } [Fact] @@ -217,6 +234,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().NotBeNullOrEmpty(); + string[] eTagHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); + eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues[0].Should().Match("\"*\""); } } diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/CountriesRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/CountriesRequestBuilder.cs index b35a2d5664..0cbfce9521 100644 --- a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/CountriesRequestBuilder.cs +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/CountriesRequestBuilder.cs @@ -86,6 +86,7 @@ public async Task PostAsync(CountryPostRequestDo var errorMapping = new Dictionary> { {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, }; diff --git a/test/OpenApiKiotaEndToEndTests/Headers/HeaderTests.cs b/test/OpenApiKiotaEndToEndTests/Headers/HeaderTests.cs new file mode 100644 index 0000000000..761f713a9b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/HeaderTests.cs @@ -0,0 +1,196 @@ +using FluentAssertions; +using Microsoft.Kiota.Http.HttpClientLibrary; +using Microsoft.Kiota.Http.HttpClientLibrary.Middleware.Options; +using Microsoft.Net.Http.Headers; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.Headers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.Headers; + +public sealed class HeaderTests : IClassFixture, HeaderDbContext>> +{ + private readonly IntegrationTestContext, HeaderDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly HeaderFakers _fakers = new(); + + public HeaderTests(IntegrationTestContext, HeaderDbContext> testContext, ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Returns_Location_for_post_resource_request() + { + // Arrange + Country newCountry = _fakers.Country.Generate(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new HeadersClient(requestAdapter); + + var headerInspector = new HeadersInspectionHandlerOption + { + InspectResponseHeaders = true + }; + + var requestBody = new CountryPostRequestDocument + { + Data = new CountryDataInPostRequest + { + Type = CountryResourceType.Countries, + Attributes = new CountryAttributesInPostRequest + { + Name = newCountry.Name, + Population = newCountry.Population + } + } + }; + + // Act + CountryPrimaryResponseDocument? response = + await apiClient.Countries.PostAsync(requestBody, configuration => configuration.Options.Add(headerInspector)); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldNotBeNull(); + + string[] locationHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.Location).WhoseValue.ToArray(); + locationHeaderValues.ShouldHaveCount(1); + locationHeaderValues[0].Should().Be($"/countries/{response.Data.Id}"); + } + + [Fact] + public async Task Returns_ContentLength_for_head_primary_resources_request() + { + // Arrange + Country existingCountry = _fakers.Country.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Countries.Add(existingCountry); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new HeadersClient(requestAdapter); + + var headerInspector = new HeadersInspectionHandlerOption + { + InspectResponseHeaders = true + }; + + // Act + Stream? response = await apiClient.Countries.HeadAsync(configuration => configuration.Options.Add(headerInspector)); + + // Assert + response.Should().BeNullOrEmpty(); + + string[] contentLengthHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); + contentLengthHeaderValues.ShouldHaveCount(1); + long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); + } + + [Fact] + public async Task Returns_ContentLength_for_head_primary_resource_request() + { + // Arrange + Country existingCountry = _fakers.Country.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.Countries.Add(existingCountry); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new HeadersClient(requestAdapter); + + var headerInspector = new HeadersInspectionHandlerOption + { + InspectResponseHeaders = true + }; + + // Act + Stream? response = await apiClient.Countries[existingCountry.StringId].HeadAsync(configuration => configuration.Options.Add(headerInspector)); + + // Assert + response.Should().BeNullOrEmpty(); + + string[] contentLengthHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); + contentLengthHeaderValues.ShouldHaveCount(1); + long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); + } + + [Fact] + public async Task Returns_ContentLength_for_head_secondary_resource_request() + { + // Arrange + Country existingCountry = _fakers.Country.Generate(); + existingCountry.Languages = _fakers.Language.Generate(1).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.Countries.Add(existingCountry); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new HeadersClient(requestAdapter); + + var headerInspector = new HeadersInspectionHandlerOption + { + InspectResponseHeaders = true + }; + + // Act + Stream? response = await apiClient.Countries[existingCountry.StringId].Languages.HeadAsync(configuration => configuration.Options.Add(headerInspector)); + + // Assert + response.Should().BeNullOrEmpty(); + + string[] contentLengthHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); + contentLengthHeaderValues.ShouldHaveCount(1); + long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); + } + + [Fact] + public async Task Returns_ContentLength_for_head_relationship_request() + { + // Arrange + Country existingCountry = _fakers.Country.Generate(); + existingCountry.Languages = _fakers.Language.Generate(1).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.Countries.Add(existingCountry); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new HeadersClient(requestAdapter); + + var headerInspector = new HeadersInspectionHandlerOption + { + InspectResponseHeaders = true + }; + + // Act + Stream? response = await apiClient.Countries[existingCountry.StringId].Relationships.Languages + .HeadAsync(configuration => configuration.Options.Add(headerInspector)); + + // Assert + response.Should().BeNullOrEmpty(); + + string[] contentLengthHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); + contentLengthHeaderValues.ShouldHaveCount(1); + long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); + } +} diff --git a/test/OpenApiKiotaEndToEndTests/OpenApiKiotaEndToEndTests.csproj b/test/OpenApiKiotaEndToEndTests/OpenApiKiotaEndToEndTests.csproj index cd5c358217..dc3ad9c2b3 100644 --- a/test/OpenApiKiotaEndToEndTests/OpenApiKiotaEndToEndTests.csproj +++ b/test/OpenApiKiotaEndToEndTests/OpenApiKiotaEndToEndTests.csproj @@ -30,6 +30,10 @@ Command="dotnet kiota generate --language CSharp --class-name HeadersClient --namespace-name OpenApiKiotaEndToEndTests.Headers.GeneratedCode --output ./Headers/GeneratedCode --backing-store --exclude-backward-compatible --clean-output --clear-cache --log-level Error --openapi ../OpenApiTests/Headers/GeneratedSwagger/swagger.g.json" /> + + diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs index 89485e11a3..913d03ea8b 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs @@ -11,13 +11,13 @@ namespace OpenApiKiotaEndToEndTests.QueryStrings; -public sealed class FilterTests : IClassFixture, QueryStringsDbContext>> +public sealed class FilterTests : IClassFixture, QueryStringDbContext>> { - private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly IntegrationTestContext, QueryStringDbContext> _testContext; private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; private readonly QueryStringFakers _fakers = new(); - public FilterTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) + public FilterTests(IntegrationTestContext, QueryStringDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); @@ -164,6 +164,7 @@ public async Task Cannot_use_empty_filter() // Assert ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); exception.Links.ShouldNotBeNull(); exception.Links.Describedby.Should().Be("swagger/v1/swagger.json"); exception.Errors.ShouldHaveCount(1); diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/NameValuePairsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/NameValuePairsRequestBuilder.cs index 74592af605..d26de14062 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/NameValuePairsRequestBuilder.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/NameValuePairsRequestBuilder.cs @@ -86,6 +86,7 @@ public async Task PostAsync(NameValuePairP var errorMapping = new Dictionary> { {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, }; diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/NodesRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/NodesRequestBuilder.cs index d1f0ce9a41..1e52351f46 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/NodesRequestBuilder.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/NodesRequestBuilder.cs @@ -86,6 +86,7 @@ public async Task PostAsync(NodePostRequestDocument var errorMapping = new Dictionary> { {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, }; diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs index c366d98ed8..0c7c769b8b 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs @@ -10,13 +10,13 @@ namespace OpenApiKiotaEndToEndTests.QueryStrings; -public sealed class IncludeTests : IClassFixture, QueryStringsDbContext>> +public sealed class IncludeTests : IClassFixture, QueryStringDbContext>> { - private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly IntegrationTestContext, QueryStringDbContext> _testContext; private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; private readonly QueryStringFakers _fakers = new(); - public IncludeTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) + public IncludeTests(IntegrationTestContext, QueryStringDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs index 609ce51c51..98a1df9746 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs @@ -11,13 +11,13 @@ namespace OpenApiKiotaEndToEndTests.QueryStrings; -public sealed class PaginationTests : IClassFixture, QueryStringsDbContext>> +public sealed class PaginationTests : IClassFixture, QueryStringDbContext>> { - private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly IntegrationTestContext, QueryStringDbContext> _testContext; private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; private readonly QueryStringFakers _fakers = new(); - public PaginationTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) + public PaginationTests(IntegrationTestContext, QueryStringDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); @@ -156,6 +156,7 @@ public async Task Cannot_use_empty_page_size() // Assert ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); exception.Errors.ShouldHaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); @@ -187,6 +188,7 @@ public async Task Cannot_use_empty_page_number() // Assert ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); exception.Errors.ShouldHaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs index 04dd1d8659..16ec5bbcef 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs @@ -11,13 +11,13 @@ namespace OpenApiKiotaEndToEndTests.QueryStrings; -public sealed class SortTests : IClassFixture, QueryStringsDbContext>> +public sealed class SortTests : IClassFixture, QueryStringDbContext>> { - private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly IntegrationTestContext, QueryStringDbContext> _testContext; private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; private readonly QueryStringFakers _fakers = new(); - public SortTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) + public SortTests(IntegrationTestContext, QueryStringDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); @@ -155,6 +155,7 @@ public async Task Cannot_use_empty_sort() // Assert ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); exception.Errors.ShouldHaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs index 620fbfd1a3..aa24c1f829 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs @@ -10,13 +10,13 @@ namespace OpenApiKiotaEndToEndTests.QueryStrings; -public sealed class SparseFieldSetTests : IClassFixture, QueryStringsDbContext>> +public sealed class SparseFieldSetTests : IClassFixture, QueryStringDbContext>> { - private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly IntegrationTestContext, QueryStringDbContext> _testContext; private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; private readonly QueryStringFakers _fakers = new(); - public SparseFieldSetTests(IntegrationTestContext, QueryStringsDbContext> testContext, + public SparseFieldSetTests(IntegrationTestContext, QueryStringDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/CreateResourceTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/CreateResourceTests.cs new file mode 100644 index 0000000000..61f61fc198 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/CreateResourceTests.cs @@ -0,0 +1,213 @@ +using System.Net; +using FluentAssertions; +using Microsoft.EntityFrameworkCore; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.RestrictedControllers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.RestrictedControllers; + +public sealed class CreateResourceTests : IClassFixture, RestrictionDbContext>> +{ + private readonly IntegrationTestContext, RestrictionDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly RestrictionFakers _fakers = new(); + + public CreateResourceTests(IntegrationTestContext, RestrictionDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_create_resource_with_includes_and_fieldsets() + { + // Arrange + DataStream existingVideoStream = _fakers.DataStream.Generate(); + DataStream existingAudioStream = _fakers.DataStream.Generate(); + WriteOnlyChannel newChannel = _fakers.WriteOnlyChannel.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.DataStreams.AddRange(existingVideoStream, existingAudioStream); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + var requestBody = new WriteOnlyChannelPostRequestDocument + { + Data = new WriteOnlyChannelDataInPostRequest + { + Type = WriteOnlyChannelResourceType.WriteOnlyChannels, + Attributes = new WriteOnlyChannelAttributesInPostRequest + { + Name = newChannel.Name, + IsAdultOnly = newChannel.IsAdultOnly + }, + Relationships = new WriteOnlyChannelRelationshipsInPostRequest + { + VideoStream = new ToOneDataStreamInRequest + { + Data = new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = existingVideoStream.StringId! + } + }, + AudioStreams = new ToManyDataStreamInRequest + { + Data = + [ + new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = existingAudioStream.StringId! + } + ] + } + } + } + }; + + var queryString = new Dictionary + { + ["include"] = "videoStream,audioStreams", + ["fields[writeOnlyChannels]"] = "name,isCommercial,videoStream,audioStreams", + ["fields[dataStreams]"] = "bytesTransmitted" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + WriteOnlyChannelPrimaryResponseDocument? response = await apiClient.WriteOnlyChannels.PostAsync(requestBody); + + response.ShouldNotBeNull(); + + response.Data.ShouldNotBeNull(); + response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Name.Should().Be(newChannel.Name); + response.Data.Attributes.IsCommercial.Should().BeNull(); + response.Data.Attributes.IsAdultOnly.Should().BeNull(); + response.Data.Relationships.ShouldNotBeNull(); + response.Data.Relationships.VideoStream.ShouldNotBeNull(); + response.Data.Relationships.VideoStream.Data.ShouldNotBeNull(); + response.Data.Relationships.VideoStream.Data.Id.Should().Be(existingVideoStream.StringId); + response.Data.Relationships.UltraHighDefinitionVideoStream.Should().BeNull(); + response.Data.Relationships.AudioStreams.ShouldNotBeNull(); + response.Data.Relationships.AudioStreams.Data.ShouldHaveCount(1); + response.Data.Relationships.AudioStreams.Data.ElementAt(0).Id.Should().Be(existingAudioStream.StringId); + + response.Included.ShouldHaveCount(2); + DataStreamDataInResponse[] dataStreamIncludes = response.Included.OfType().ToArray(); + + DataStreamDataInResponse videoStream = dataStreamIncludes.Single(include => include.Id == existingVideoStream.StringId); + videoStream.Attributes.ShouldNotBeNull(); + videoStream.Attributes.BytesTransmitted.Should().Be((long?)existingVideoStream.BytesTransmitted); + + DataStreamDataInResponse audioStream = dataStreamIncludes.Single(include => include.Id == existingAudioStream.StringId); + audioStream.Attributes.ShouldNotBeNull(); + audioStream.Attributes.BytesTransmitted.Should().Be((long?)existingAudioStream.BytesTransmitted); + + long newChannelId = int.Parse(response.Data.Id.ShouldNotBeNull()); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.VideoStream) + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(newChannelId); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.Name.Should().Be(newChannel.Name); + channelInDatabase.IsCommercial.Should().BeNull(); + channelInDatabase.IsAdultOnly.Should().Be(newChannel.IsAdultOnly); + + channelInDatabase.VideoStream.ShouldNotBeNull(); + channelInDatabase.VideoStream.Id.Should().Be(existingVideoStream.Id); + + channelInDatabase.AudioStreams.ShouldHaveCount(1); + channelInDatabase.AudioStreams.ElementAt(0).Id.Should().Be(existingAudioStream.Id); + }); + } + } + + [Fact] + public async Task Cannot_create_resource_for_missing_request_body() + { + // Arrange + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + WriteOnlyChannelPostRequestDocument requestBody = null!; + + // Act + Func action = async () => _ = await apiClient.WriteOnlyChannels.PostAsync(requestBody); + + // Assert + await action.Should().ThrowExactlyAsync().WithParameterName("body"); + } + + [Fact] + public async Task Cannot_create_resource_with_unknown_relationship_ID() + { + // Arrange + WriteOnlyChannel newChannel = _fakers.WriteOnlyChannel.Generate(); + + string unknownVideoStreamId = Unknown.StringId.For(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + var requestBody = new WriteOnlyChannelPostRequestDocument + { + Data = new WriteOnlyChannelDataInPostRequest + { + Type = WriteOnlyChannelResourceType.WriteOnlyChannels, + Attributes = new WriteOnlyChannelAttributesInPostRequest + { + Name = newChannel.Name + }, + Relationships = new WriteOnlyChannelRelationshipsInPostRequest + { + VideoStream = new ToOneDataStreamInRequest + { + Data = new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = unknownVideoStreamId + } + } + } + } + }; + + // Act + Func action = async () => _ = await apiClient.WriteOnlyChannels.PostAsync(requestBody); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("A related resource does not exist."); + error.Detail.Should().Be($"Related resource of type 'dataStreams' with ID '{unknownVideoStreamId}' in relationship 'videoStream' does not exist."); + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/DeleteResourceTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/DeleteResourceTests.cs new file mode 100644 index 0000000000..87236e77bf --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/DeleteResourceTests.cs @@ -0,0 +1,80 @@ +using System.Net; +using FluentAssertions; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.RestrictedControllers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.RestrictedControllers; + +public sealed class DeleteResourceTests : IClassFixture, RestrictionDbContext>> +{ + private readonly IntegrationTestContext, RestrictionDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly RestrictionFakers _fakers = new(); + + public DeleteResourceTests(IntegrationTestContext, RestrictionDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_delete_existing_resource() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + await apiClient.WriteOnlyChannels[existingChannel.StringId].DeleteAsync(); + + // Assert + await _testContext.RunOnDatabaseAsync(async dbContext => + { + WriteOnlyChannel? channelInDatabase = await dbContext.WriteOnlyChannels.FirstWithIdOrDefaultAsync(existingChannel.Id); + + channelInDatabase.Should().BeNull(); + }); + } + + [Fact] + public async Task Cannot_delete_unknown_resource() + { + // Arrange + string unknownChannelId = Unknown.StringId.For(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + Func action = async () => await apiClient.WriteOnlyChannels[unknownChannelId].DeleteAsync(); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("The requested resource does not exist."); + error.Detail.Should().Be($"Resource of type 'writeOnlyChannels' with ID '{unknownChannelId}' does not exist."); + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs new file mode 100644 index 0000000000..5b0a83e064 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs @@ -0,0 +1,153 @@ +using System.Net; +using FluentAssertions; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.RestrictedControllers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.RestrictedControllers; + +public sealed class FetchRelationshipTests : IClassFixture, RestrictionDbContext>> +{ + private readonly IntegrationTestContext, RestrictionDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly RestrictionFakers _fakers = new(); + + public FetchRelationshipTests(IntegrationTestContext, RestrictionDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_get_ToOne_relationship() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + DataStreamIdentifierResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId].Relationships.VideoStream.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(channel.VideoStream.StringId); + } + + [Fact] + public async Task Can_get_empty_ToOne_relationship() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + NullableDataStreamIdentifierResponseDocument? response = + await apiClient.ReadOnlyChannels[channel.StringId].Relationships.UltraHighDefinitionVideoStream.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.Should().BeNull(); + } + + [Fact] + public async Task Can_get_ToMany_relationship() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + channel.AudioStreams = _fakers.DataStream.Generate(2).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + DataStreamIdentifierCollectionResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId].Relationships.AudioStreams.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(2); + response.Data.Should().ContainSingle(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(0).StringId); + response.Data.Should().ContainSingle(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(1).StringId); + } + + [Fact] + public async Task Can_get_empty_ToMany_relationship() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + DataStreamIdentifierCollectionResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId].Relationships.AudioStreams.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(0); + } + + [Fact] + public async Task Cannot_get_relationship_for_unknown_primary_ID() + { + // Arrange + string unknownChannelId = Unknown.StringId.For(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + Func action = async () => _ = await apiClient.ReadOnlyChannels[unknownChannelId].Relationships.VideoStream.GetAsync(); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("The requested resource does not exist."); + error.Detail.Should().Be($"Resource of type 'readOnlyChannels' with ID '{unknownChannelId}' does not exist."); + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchResourceTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchResourceTests.cs new file mode 100644 index 0000000000..38efd0156c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchResourceTests.cs @@ -0,0 +1,271 @@ +using System.Net; +using FluentAssertions; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.RestrictedControllers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.RestrictedControllers; + +public sealed class FetchResourceTests : IClassFixture, RestrictionDbContext>> +{ + private readonly IntegrationTestContext, RestrictionDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly RestrictionFakers _fakers = new(); + + public FetchResourceTests(IntegrationTestContext, RestrictionDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_get_primary_resources() + { + // Arrange + List channels = _fakers.ReadOnlyChannel.Generate(2); + channels.ForEach(channel => channel.VideoStream = _fakers.DataStream.Generate()); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.ReadOnlyChannels.AddRange(channels); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + ReadOnlyChannelCollectionResponseDocument? response = await apiClient.ReadOnlyChannels.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(2); + + ReadOnlyChannelDataInResponse channel1 = response.Data.Single(channel => channel.Id == channels.ElementAt(0).StringId); + channel1.Attributes.ShouldNotBeNull(); + channel1.Attributes.Name.Should().Be(channels[0].Name); + channel1.Attributes.IsCommercial.Should().Be(channels[0].IsCommercial); + channel1.Attributes.IsAdultOnly.Should().Be(channels[0].IsAdultOnly); + channel1.Relationships.ShouldNotBeNull(); + channel1.Relationships.VideoStream.ShouldNotBeNull(); + channel1.Relationships.VideoStream.Data.Should().BeNull(); + channel1.Relationships.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channel1.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); + channel1.Relationships.AudioStreams.ShouldNotBeNull(); + channel1.Relationships.AudioStreams.Data.Should().BeNull(); + + ReadOnlyChannelDataInResponse channel2 = response.Data.Single(channel => channel.Id == channels.ElementAt(1).StringId); + channel2.Attributes.ShouldNotBeNull(); + channel2.Attributes.Name.Should().Be(channels[1].Name); + channel2.Attributes.IsCommercial.Should().Be(channels[1].IsCommercial); + channel2.Attributes.IsAdultOnly.Should().Be(channels[1].IsAdultOnly); + channel2.Relationships.ShouldNotBeNull(); + channel2.Relationships.VideoStream.ShouldNotBeNull(); + channel2.Relationships.VideoStream.Data.Should().BeNull(); + channel2.Relationships.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channel2.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); + channel2.Relationships.AudioStreams.ShouldNotBeNull(); + channel2.Relationships.AudioStreams.Data.Should().BeNull(); + } + + [Fact] + public async Task Can_get_primary_resource_by_ID() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + ReadOnlyChannelPrimaryResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId].GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(channel.StringId); + response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Name.Should().Be(channel.Name); + response.Data.Attributes.IsCommercial.Should().Be(channel.IsCommercial); + response.Data.Attributes.IsAdultOnly.Should().Be(channel.IsAdultOnly); + response.Data.Relationships.ShouldNotBeNull(); + response.Data.Relationships.VideoStream.ShouldNotBeNull(); + response.Data.Relationships.VideoStream.Data.Should().BeNull(); + response.Data.Relationships.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + response.Data.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); + response.Data.Relationships.AudioStreams.ShouldNotBeNull(); + response.Data.Relationships.AudioStreams.Data.Should().BeNull(); + } + + [Fact] + public async Task Cannot_get_primary_resource_for_unknown_ID() + { + // Arrange + string unknownChannelId = Unknown.StringId.For(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + Func action = async () => _ = await apiClient.ReadOnlyChannels[unknownChannelId].GetAsync(); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("The requested resource does not exist."); + error.Detail.Should().Be($"Resource of type 'readOnlyChannels' with ID '{unknownChannelId}' does not exist."); + } + + [Fact] + public async Task Can_get_secondary_ToOne_resource() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + DataStreamSecondaryResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId].VideoStream.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(channel.VideoStream.StringId); + response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.BytesTransmitted.Should().Be((long?)channel.VideoStream.BytesTransmitted); + } + + [Fact] + public async Task Can_get_unknown_secondary_ToOne_resource() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + NullableDataStreamSecondaryResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId].UltraHighDefinitionVideoStream.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.Should().BeNull(); + } + + [Fact] + public async Task Can_get_secondary_ToMany_resources() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + channel.AudioStreams = _fakers.DataStream.Generate(2).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + DataStreamCollectionResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId].AudioStreams.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(2); + + DataStreamDataInResponse audioStream1 = response.Data.Single(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(0).StringId); + audioStream1.Attributes.ShouldNotBeNull(); + audioStream1.Attributes.BytesTransmitted.Should().Be((long?)channel.AudioStreams.ElementAt(0).BytesTransmitted); + + DataStreamDataInResponse audioStream2 = response.Data.Single(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(1).StringId); + audioStream2.Attributes.ShouldNotBeNull(); + audioStream2.Attributes.BytesTransmitted.Should().Be((long?)channel.AudioStreams.ElementAt(1).BytesTransmitted); + } + + [Fact] + public async Task Can_get_no_secondary_ToMany_resources() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + DataStreamCollectionResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId].AudioStreams.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(0); + } + + [Fact] + public async Task Cannot_get_secondary_resource_for_unknown_primary_ID() + { + // Arrange + string unknownChannelId = Unknown.StringId.For(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + // Act + Func action = async () => _ = await apiClient.ReadOnlyChannels[unknownChannelId].VideoStream.GetAsync(); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("The requested resource does not exist."); + error.Detail.Should().Be($"Resource of type 'readOnlyChannels' with ID '{unknownChannelId}' does not exist."); + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/DataStreams/DataStreamsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/DataStreams/DataStreamsRequestBuilder.cs new file mode 100644 index 0000000000..c74abf6cee --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/DataStreams/DataStreamsRequestBuilder.cs @@ -0,0 +1,140 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.DataStreams.Item; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.DataStreams { + /// + /// Builds and executes requests for operations under \dataStreams + /// + public class DataStreamsRequestBuilder : BaseRequestBuilder { + /// Gets an item from the OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.dataStreams.item collection + /// The identifier of the dataStream to retrieve. + public DataStreamsItemRequestBuilder this[string position] { get { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new DataStreamsItemRequestBuilder(urlTplParams, RequestAdapter); + } } + /// + /// Instantiates a new DataStreamsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public DataStreamsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/dataStreams{?query*}", pathParameters) { + } + /// + /// Instantiates a new DataStreamsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public DataStreamsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/dataStreams{?query*}", rawUrl) { + } + /// + /// Retrieves a collection of dataStreams. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, DataStreamCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves a collection of dataStreams. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public DataStreamsRequestBuilder WithUrl(string rawUrl) { + return new DataStreamsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves a collection of dataStreams. + /// + public class DataStreamsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class DataStreamsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/DataStreams/Item/DataStreamsItemRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/DataStreams/Item/DataStreamsItemRequestBuilder.cs new file mode 100644 index 0000000000..d1c0cff7e5 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/DataStreams/Item/DataStreamsItemRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.DataStreams.Item { + /// + /// Builds and executes requests for operations under \dataStreams\{id} + /// + public class DataStreamsItemRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new DataStreamsItemRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public DataStreamsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/dataStreams/{id}{?query*}", pathParameters) { + } + /// + /// Instantiates a new DataStreamsItemRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public DataStreamsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/dataStreams/{id}{?query*}", rawUrl) { + } + /// + /// Retrieves an individual dataStream by its identifier. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, DataStreamPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves an individual dataStream by its identifier. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public DataStreamsItemRequestBuilder WithUrl(string rawUrl) { + return new DataStreamsItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves an individual dataStream by its identifier. + /// + public class DataStreamsItemRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class DataStreamsItemRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataInResponse.cs new file mode 100644 index 0000000000..ca63ad73b3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataInResponse.cs @@ -0,0 +1,80 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#nullable restore +#else + public string Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#endif + /// + /// Instantiates a new dataInResponse and sets the default values. + /// + public DataInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("type")?.GetStringValue(); + return mappingValue switch { + "dataStreams" => new DataStreamDataInResponse(), + "readOnlyChannels" => new ReadOnlyChannelDataInResponse(), + "readOnlyResourceChannels" => new ReadOnlyResourceChannelDataInResponse(), + "writeOnlyChannels" => new WriteOnlyChannelDataInResponse(), + _ => new DataInResponse(), + }; + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteStringValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamAttributesInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamAttributesInResponse.cs new file mode 100644 index 0000000000..931e394418 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamAttributesInResponse.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The bytesTransmitted property + public long? BytesTransmitted { + get { return BackingStore?.Get("bytesTransmitted"); } + set { BackingStore?.Set("bytesTransmitted", value); } + } + /// + /// Instantiates a new dataStreamAttributesInResponse and sets the default values. + /// + public DataStreamAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"bytesTransmitted", n => { BytesTransmitted = n.GetLongValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteLongValue("bytesTransmitted", BytesTransmitted); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamCollectionResponseDocument.cs new file mode 100644 index 0000000000..158ddc441e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamCollectionResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public DataStreamCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new dataStreamCollectionResponseDocument and sets the default values. + /// + public DataStreamCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(DataStreamDataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(DataStreamCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamCollectionResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..afd14f56ac --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new dataStreamCollectionResponseDocument_meta and sets the default values. + /// + public DataStreamCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamDataInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamDataInResponse.cs new file mode 100644 index 0000000000..38c5fd45c0 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamDataInResponse.cs @@ -0,0 +1,81 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public DataStreamAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public DataStreamDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new DataStreamDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(DataStreamAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(DataStreamDataInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamDataInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamDataInResponse_meta.cs new file mode 100644 index 0000000000..b3ee7d1b04 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new dataStreamDataInResponse_meta and sets the default values. + /// + public DataStreamDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifier.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifier.cs new file mode 100644 index 0000000000..0a72f67869 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifier.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamIdentifier : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property + public DataStreamResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new dataStreamIdentifier and sets the default values. + /// + public DataStreamIdentifier() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamIdentifier CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamIdentifier(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifierCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifierCollectionResponseDocument.cs new file mode 100644 index 0000000000..a754e5583f --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifierCollectionResponseDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamIdentifierCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceIdentifierCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceIdentifierCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamIdentifierCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public DataStreamIdentifierCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new dataStreamIdentifierCollectionResponseDocument and sets the default values. + /// + public DataStreamIdentifierCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamIdentifierCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamIdentifierCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(DataStreamIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceIdentifierCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(DataStreamIdentifierCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifierCollectionResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifierCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..9824cc09fe --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifierCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamIdentifierCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new dataStreamIdentifierCollectionResponseDocument_meta and sets the default values. + /// + public DataStreamIdentifierCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamIdentifierCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamIdentifierCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifierResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifierResponseDocument.cs new file mode 100644 index 0000000000..2ceb60c7a6 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifierResponseDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamIdentifierResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public DataStreamIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceIdentifierDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceIdentifierDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamIdentifierResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public DataStreamIdentifierResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new dataStreamIdentifierResponseDocument and sets the default values. + /// + public DataStreamIdentifierResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamIdentifierResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamIdentifierResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(DataStreamIdentifier.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceIdentifierDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(DataStreamIdentifierResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifierResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifierResponseDocument_meta.cs new file mode 100644 index 0000000000..6aab4bce1b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamIdentifierResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamIdentifierResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new dataStreamIdentifierResponseDocument_meta and sets the default values. + /// + public DataStreamIdentifierResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamIdentifierResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamIdentifierResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamPrimaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamPrimaryResponseDocument.cs new file mode 100644 index 0000000000..3bd63c8167 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamPrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamPrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreams? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public DataStreams Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamPrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public DataStreamPrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new dataStreamPrimaryResponseDocument and sets the default values. + /// + public DataStreamPrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamPrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamPrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(DataStreams.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(DataStreamPrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamPrimaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamPrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..c8bcd6a0ac --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamPrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamPrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new dataStreamPrimaryResponseDocument_meta and sets the default values. + /// + public DataStreamPrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamPrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamPrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamResourceType.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamResourceType.cs new file mode 100644 index 0000000000..bdf90b8b55 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamResourceType.cs @@ -0,0 +1,9 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public enum DataStreamResourceType { + [EnumMember(Value = "dataStreams")] + DataStreams, + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamSecondaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamSecondaryResponseDocument.cs new file mode 100644 index 0000000000..5a01d43e4b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamSecondaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamSecondaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public VideoStream? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public VideoStream Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamSecondaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public DataStreamSecondaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new dataStreamSecondaryResponseDocument and sets the default values. + /// + public DataStreamSecondaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamSecondaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamSecondaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(VideoStream.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(DataStreamSecondaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamSecondaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamSecondaryResponseDocument_meta.cs new file mode 100644 index 0000000000..bf4155ad0b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreamSecondaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreamSecondaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new dataStreamSecondaryResponseDocument_meta and sets the default values. + /// + public DataStreamSecondaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreamSecondaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreamSecondaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreams.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreams.cs new file mode 100644 index 0000000000..6d1f2a9d23 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreams.cs @@ -0,0 +1,81 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreams : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public DataStreamAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreams_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public DataStreams_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new DataStreams CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreams(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(DataStreamAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(DataStreams_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreams_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreams_meta.cs new file mode 100644 index 0000000000..90e02609ec --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/DataStreams_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class DataStreams_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new DataStreams_meta and sets the default values. + /// + public DataStreams_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataStreams_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new DataStreams_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorLinks.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorLinks.cs new file mode 100644 index 0000000000..8624611090 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorLinks.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ErrorLinks : IBackedModel, IParsable { + /// The about property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? About { + get { return BackingStore?.Get("about"); } + set { BackingStore?.Set("about", value); } + } +#nullable restore +#else + public string About { + get { return BackingStore?.Get("about"); } + set { BackingStore?.Set("about", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The type property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#nullable restore +#else + public string Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#endif + /// + /// Instantiates a new errorLinks and sets the default values. + /// + public ErrorLinks() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorLinks CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorLinks(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"about", n => { About = n.GetStringValue(); } }, + {"type", n => { Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("about", About); + writer.WriteStringValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorObject.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorObject.cs new file mode 100644 index 0000000000..1def860105 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorObject.cs @@ -0,0 +1,169 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ErrorObject : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The code property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Code { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } +#nullable restore +#else + public string Code { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } +#endif + /// The detail property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Detail { + get { return BackingStore?.Get("detail"); } + set { BackingStore?.Set("detail", value); } + } +#nullable restore +#else + public string Detail { + get { return BackingStore?.Get("detail"); } + set { BackingStore?.Set("detail", value); } + } +#endif + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorLinks? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public ErrorLinks Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorObject_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ErrorObject_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The source property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorSource? Source { + get { return BackingStore?.Get("source"); } + set { BackingStore?.Set("source", value); } + } +#nullable restore +#else + public ErrorSource Source { + get { return BackingStore?.Get("source"); } + set { BackingStore?.Set("source", value); } + } +#endif + /// The status property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Status { + get { return BackingStore?.Get("status"); } + set { BackingStore?.Set("status", value); } + } +#nullable restore +#else + public string Status { + get { return BackingStore?.Get("status"); } + set { BackingStore?.Set("status", value); } + } +#endif + /// The title property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#nullable restore +#else + public string Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#endif + /// + /// Instantiates a new errorObject and sets the default values. + /// + public ErrorObject() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorObject CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorObject(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"code", n => { Code = n.GetStringValue(); } }, + {"detail", n => { Detail = n.GetStringValue(); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"links", n => { Links = n.GetObjectValue(ErrorLinks.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ErrorObject_meta.CreateFromDiscriminatorValue); } }, + {"source", n => { Source = n.GetObjectValue(ErrorSource.CreateFromDiscriminatorValue); } }, + {"status", n => { Status = n.GetStringValue(); } }, + {"title", n => { Title = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("code", Code); + writer.WriteStringValue("detail", Detail); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("source", Source); + writer.WriteStringValue("status", Status); + writer.WriteStringValue("title", Title); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorObject_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorObject_meta.cs new file mode 100644 index 0000000000..e4b2d86a54 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorObject_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ErrorObject_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new errorObject_meta and sets the default values. + /// + public ErrorObject_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorObject_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorObject_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorResponseDocument.cs new file mode 100644 index 0000000000..618b385483 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorResponseDocument.cs @@ -0,0 +1,92 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ErrorResponseDocument : ApiException, IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The errors property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Errors { + get { return BackingStore?.Get?>("errors"); } + set { BackingStore?.Set("errors", value); } + } +#nullable restore +#else + public List Errors { + get { return BackingStore?.Get>("errors"); } + set { BackingStore?.Set("errors", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInErrorDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInErrorDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The primary error message. + public override string Message { get => base.Message; } + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ErrorResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new errorResponseDocument and sets the default values. + /// + public ErrorResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"errors", n => { Errors = n.GetCollectionOfObjectValues(ErrorObject.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInErrorDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ErrorResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("errors", Errors); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorResponseDocument_meta.cs new file mode 100644 index 0000000000..52a2796799 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ErrorResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new errorResponseDocument_meta and sets the default values. + /// + public ErrorResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorSource.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorSource.cs new file mode 100644 index 0000000000..d3c906fcb5 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ErrorSource.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ErrorSource : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The header property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Header { + get { return BackingStore?.Get("header"); } + set { BackingStore?.Set("header", value); } + } +#nullable restore +#else + public string Header { + get { return BackingStore?.Get("header"); } + set { BackingStore?.Set("header", value); } + } +#endif + /// The parameter property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Parameter { + get { return BackingStore?.Get("parameter"); } + set { BackingStore?.Set("parameter", value); } + } +#nullable restore +#else + public string Parameter { + get { return BackingStore?.Get("parameter"); } + set { BackingStore?.Set("parameter", value); } + } +#endif + /// The pointer property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Pointer { + get { return BackingStore?.Get("pointer"); } + set { BackingStore?.Set("pointer", value); } + } +#nullable restore +#else + public string Pointer { + get { return BackingStore?.Get("pointer"); } + set { BackingStore?.Set("pointer", value); } + } +#endif + /// + /// Instantiates a new errorSource and sets the default values. + /// + public ErrorSource() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorSource CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorSource(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"header", n => { Header = n.GetStringValue(); } }, + {"parameter", n => { Parameter = n.GetStringValue(); } }, + {"pointer", n => { Pointer = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("header", Header); + writer.WriteStringValue("parameter", Parameter); + writer.WriteStringValue("pointer", Pointer); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInErrorDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInErrorDocument.cs new file mode 100644 index 0000000000..d24c7f45c2 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInErrorDocument.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class LinksInErrorDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInErrorDocument and sets the default values. + /// + public LinksInErrorDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInErrorDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInErrorDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInRelationship.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInRelationship.cs new file mode 100644 index 0000000000..458b09753e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInRelationship.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class LinksInRelationship : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The related property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#nullable restore +#else + public string Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInRelationship and sets the default values. + /// + public LinksInRelationship() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInRelationship CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInRelationship(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"related", n => { Related = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("related", Related); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceCollectionDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceCollectionDocument.cs new file mode 100644 index 0000000000..e008a7ef80 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceCollectionDocument.cs @@ -0,0 +1,137 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class LinksInResourceCollectionDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The first property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#nullable restore +#else + public string First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#endif + /// The last property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#nullable restore +#else + public string Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#endif + /// The next property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#nullable restore +#else + public string Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#endif + /// The prev property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#nullable restore +#else + public string Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceCollectionDocument and sets the default values. + /// + public LinksInResourceCollectionDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceCollectionDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceCollectionDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"first", n => { First = n.GetStringValue(); } }, + {"last", n => { Last = n.GetStringValue(); } }, + {"next", n => { Next = n.GetStringValue(); } }, + {"prev", n => { Prev = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("first", First); + writer.WriteStringValue("last", Last); + writer.WriteStringValue("next", Next); + writer.WriteStringValue("prev", Prev); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceData.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceData.cs new file mode 100644 index 0000000000..7d08a4752a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceData.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class LinksInResourceData : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceData and sets the default values. + /// + public LinksInResourceData() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceData CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceData(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceDocument.cs new file mode 100644 index 0000000000..85f981bea1 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceDocument.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class LinksInResourceDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceDocument and sets the default values. + /// + public LinksInResourceDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceIdentifierCollectionDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceIdentifierCollectionDocument.cs new file mode 100644 index 0000000000..297bd13b25 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceIdentifierCollectionDocument.cs @@ -0,0 +1,153 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class LinksInResourceIdentifierCollectionDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The first property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#nullable restore +#else + public string First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#endif + /// The last property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#nullable restore +#else + public string Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#endif + /// The next property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#nullable restore +#else + public string Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#endif + /// The prev property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#nullable restore +#else + public string Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#endif + /// The related property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#nullable restore +#else + public string Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceIdentifierCollectionDocument and sets the default values. + /// + public LinksInResourceIdentifierCollectionDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceIdentifierCollectionDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceIdentifierCollectionDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"first", n => { First = n.GetStringValue(); } }, + {"last", n => { Last = n.GetStringValue(); } }, + {"next", n => { Next = n.GetStringValue(); } }, + {"prev", n => { Prev = n.GetStringValue(); } }, + {"related", n => { Related = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("first", First); + writer.WriteStringValue("last", Last); + writer.WriteStringValue("next", Next); + writer.WriteStringValue("prev", Prev); + writer.WriteStringValue("related", Related); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceIdentifierDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceIdentifierDocument.cs new file mode 100644 index 0000000000..1501dcef5c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/LinksInResourceIdentifierDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class LinksInResourceIdentifierDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The related property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#nullable restore +#else + public string Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceIdentifierDocument and sets the default values. + /// + public LinksInResourceIdentifierDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceIdentifierDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceIdentifierDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"related", n => { Related = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("related", Related); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableDataStreamIdentifierResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableDataStreamIdentifierResponseDocument.cs new file mode 100644 index 0000000000..5f82ead6db --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableDataStreamIdentifierResponseDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class NullableDataStreamIdentifierResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public DataStreamIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceIdentifierDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceIdentifierDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableDataStreamIdentifierResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NullableDataStreamIdentifierResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nullableDataStreamIdentifierResponseDocument and sets the default values. + /// + public NullableDataStreamIdentifierResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableDataStreamIdentifierResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableDataStreamIdentifierResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(DataStreamIdentifier.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceIdentifierDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NullableDataStreamIdentifierResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableDataStreamIdentifierResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableDataStreamIdentifierResponseDocument_meta.cs new file mode 100644 index 0000000000..6ba2f0b6a7 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableDataStreamIdentifierResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class NullableDataStreamIdentifierResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nullableDataStreamIdentifierResponseDocument_meta and sets the default values. + /// + public NullableDataStreamIdentifierResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableDataStreamIdentifierResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableDataStreamIdentifierResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableDataStreamSecondaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableDataStreamSecondaryResponseDocument.cs new file mode 100644 index 0000000000..38ccf0212d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableDataStreamSecondaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class NullableDataStreamSecondaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public UltraHighDefinitionVideoStream? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public UltraHighDefinitionVideoStream Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableDataStreamSecondaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NullableDataStreamSecondaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nullableDataStreamSecondaryResponseDocument and sets the default values. + /// + public NullableDataStreamSecondaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableDataStreamSecondaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableDataStreamSecondaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(UltraHighDefinitionVideoStream.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NullableDataStreamSecondaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableDataStreamSecondaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableDataStreamSecondaryResponseDocument_meta.cs new file mode 100644 index 0000000000..46f1743b21 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableDataStreamSecondaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class NullableDataStreamSecondaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nullableDataStreamSecondaryResponseDocument_meta and sets the default values. + /// + public NullableDataStreamSecondaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableDataStreamSecondaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableDataStreamSecondaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableToOneDataStreamInRequest.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableToOneDataStreamInRequest.cs new file mode 100644 index 0000000000..8f541a730b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableToOneDataStreamInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class NullableToOneDataStreamInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public DataStreamIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new nullableToOneDataStreamInRequest and sets the default values. + /// + public NullableToOneDataStreamInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableToOneDataStreamInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableToOneDataStreamInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(DataStreamIdentifier.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableToOneDataStreamInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableToOneDataStreamInResponse.cs new file mode 100644 index 0000000000..f1642b6a42 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableToOneDataStreamInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class NullableToOneDataStreamInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public DataStreamIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOneDataStreamInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NullableToOneDataStreamInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nullableToOneDataStreamInResponse and sets the default values. + /// + public NullableToOneDataStreamInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableToOneDataStreamInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableToOneDataStreamInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(DataStreamIdentifier.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NullableToOneDataStreamInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableToOneDataStreamInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableToOneDataStreamInResponse_meta.cs new file mode 100644 index 0000000000..d7960e37cb --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/NullableToOneDataStreamInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class NullableToOneDataStreamInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nullableToOneDataStreamInResponse_meta and sets the default values. + /// + public NullableToOneDataStreamInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableToOneDataStreamInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableToOneDataStreamInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelAttributesInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelAttributesInResponse.cs new file mode 100644 index 0000000000..adfd1c6478 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelAttributesInResponse.cs @@ -0,0 +1,71 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyChannelAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The isAdultOnly property + public bool? IsAdultOnly { + get { return BackingStore?.Get("isAdultOnly"); } + set { BackingStore?.Set("isAdultOnly", value); } + } + /// The isCommercial property + public bool? IsCommercial { + get { return BackingStore?.Get("isCommercial"); } + set { BackingStore?.Set("isCommercial", value); } + } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new readOnlyChannelAttributesInResponse and sets the default values. + /// + public ReadOnlyChannelAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyChannelAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyChannelAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"isAdultOnly", n => { IsAdultOnly = n.GetBoolValue(); } }, + {"isCommercial", n => { IsCommercial = n.GetBoolValue(); } }, + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteBoolValue("isAdultOnly", IsAdultOnly); + writer.WriteBoolValue("isCommercial", IsCommercial); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelCollectionResponseDocument.cs new file mode 100644 index 0000000000..211c339691 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelCollectionResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyChannelCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyChannelCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ReadOnlyChannelCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new readOnlyChannelCollectionResponseDocument and sets the default values. + /// + public ReadOnlyChannelCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyChannelCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyChannelCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(ReadOnlyChannelDataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ReadOnlyChannelCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelCollectionResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..3bc4113990 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyChannelCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new readOnlyChannelCollectionResponseDocument_meta and sets the default values. + /// + public ReadOnlyChannelCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyChannelCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyChannelCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelDataInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelDataInResponse.cs new file mode 100644 index 0000000000..b5a7fd189d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelDataInResponse.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyChannelDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyChannelAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public ReadOnlyChannelAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyChannelDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ReadOnlyChannelDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyChannelRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public ReadOnlyChannelRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new ReadOnlyChannelDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyChannelDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(ReadOnlyChannelAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ReadOnlyChannelDataInResponse_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(ReadOnlyChannelRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelDataInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelDataInResponse_meta.cs new file mode 100644 index 0000000000..f1945fafcb --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyChannelDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new readOnlyChannelDataInResponse_meta and sets the default values. + /// + public ReadOnlyChannelDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyChannelDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyChannelDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelPrimaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelPrimaryResponseDocument.cs new file mode 100644 index 0000000000..c14be0aa50 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelPrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyChannelPrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyChannels? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public ReadOnlyChannels Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyChannelPrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ReadOnlyChannelPrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new readOnlyChannelPrimaryResponseDocument and sets the default values. + /// + public ReadOnlyChannelPrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyChannelPrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyChannelPrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(ReadOnlyChannels.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ReadOnlyChannelPrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelPrimaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelPrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..46d6dbe9f3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelPrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyChannelPrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new readOnlyChannelPrimaryResponseDocument_meta and sets the default values. + /// + public ReadOnlyChannelPrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyChannelPrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyChannelPrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelRelationshipsInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelRelationshipsInResponse.cs new file mode 100644 index 0000000000..790868c105 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannelRelationshipsInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyChannelRelationshipsInResponse : IBackedModel, IParsable { + /// The audioStreams property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyDataStreamInResponse? AudioStreams { + get { return BackingStore?.Get("audioStreams"); } + set { BackingStore?.Set("audioStreams", value); } + } +#nullable restore +#else + public ToManyDataStreamInResponse AudioStreams { + get { return BackingStore?.Get("audioStreams"); } + set { BackingStore?.Set("audioStreams", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The ultraHighDefinitionVideoStream property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOneDataStreamInResponse? UltraHighDefinitionVideoStream { + get { return BackingStore?.Get("ultraHighDefinitionVideoStream"); } + set { BackingStore?.Set("ultraHighDefinitionVideoStream", value); } + } +#nullable restore +#else + public NullableToOneDataStreamInResponse UltraHighDefinitionVideoStream { + get { return BackingStore?.Get("ultraHighDefinitionVideoStream"); } + set { BackingStore?.Set("ultraHighDefinitionVideoStream", value); } + } +#endif + /// The videoStream property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOneDataStreamInResponse? VideoStream { + get { return BackingStore?.Get("videoStream"); } + set { BackingStore?.Set("videoStream", value); } + } +#nullable restore +#else + public ToOneDataStreamInResponse VideoStream { + get { return BackingStore?.Get("videoStream"); } + set { BackingStore?.Set("videoStream", value); } + } +#endif + /// + /// Instantiates a new readOnlyChannelRelationshipsInResponse and sets the default values. + /// + public ReadOnlyChannelRelationshipsInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyChannelRelationshipsInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyChannelRelationshipsInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"audioStreams", n => { AudioStreams = n.GetObjectValue(ToManyDataStreamInResponse.CreateFromDiscriminatorValue); } }, + {"ultraHighDefinitionVideoStream", n => { UltraHighDefinitionVideoStream = n.GetObjectValue(NullableToOneDataStreamInResponse.CreateFromDiscriminatorValue); } }, + {"videoStream", n => { VideoStream = n.GetObjectValue(ToOneDataStreamInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("audioStreams", AudioStreams); + writer.WriteObjectValue("ultraHighDefinitionVideoStream", UltraHighDefinitionVideoStream); + writer.WriteObjectValue("videoStream", VideoStream); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannels.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannels.cs new file mode 100644 index 0000000000..cf726bcac9 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannels.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyChannels : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyChannelAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public ReadOnlyChannelAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyChannels_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ReadOnlyChannels_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyChannelRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public ReadOnlyChannelRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new ReadOnlyChannels CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyChannels(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(ReadOnlyChannelAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ReadOnlyChannels_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(ReadOnlyChannelRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannels_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannels_meta.cs new file mode 100644 index 0000000000..401d49313e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyChannels_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyChannels_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new ReadOnlyChannels_meta and sets the default values. + /// + public ReadOnlyChannels_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyChannels_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyChannels_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelAttributesInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelAttributesInResponse.cs new file mode 100644 index 0000000000..285063d083 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelAttributesInResponse.cs @@ -0,0 +1,71 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyResourceChannelAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The isAdultOnly property + public bool? IsAdultOnly { + get { return BackingStore?.Get("isAdultOnly"); } + set { BackingStore?.Set("isAdultOnly", value); } + } + /// The isCommercial property + public bool? IsCommercial { + get { return BackingStore?.Get("isCommercial"); } + set { BackingStore?.Set("isCommercial", value); } + } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new readOnlyResourceChannelAttributesInResponse and sets the default values. + /// + public ReadOnlyResourceChannelAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyResourceChannelAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyResourceChannelAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"isAdultOnly", n => { IsAdultOnly = n.GetBoolValue(); } }, + {"isCommercial", n => { IsCommercial = n.GetBoolValue(); } }, + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteBoolValue("isAdultOnly", IsAdultOnly); + writer.WriteBoolValue("isCommercial", IsCommercial); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelCollectionResponseDocument.cs new file mode 100644 index 0000000000..5d716965dc --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelCollectionResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyResourceChannelCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyResourceChannelCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ReadOnlyResourceChannelCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new readOnlyResourceChannelCollectionResponseDocument and sets the default values. + /// + public ReadOnlyResourceChannelCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyResourceChannelCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyResourceChannelCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(ReadOnlyResourceChannelDataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ReadOnlyResourceChannelCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelCollectionResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..1b0914fe78 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyResourceChannelCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new readOnlyResourceChannelCollectionResponseDocument_meta and sets the default values. + /// + public ReadOnlyResourceChannelCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyResourceChannelCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyResourceChannelCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelDataInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelDataInResponse.cs new file mode 100644 index 0000000000..483cbf1e58 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelDataInResponse.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyResourceChannelDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyResourceChannelAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public ReadOnlyResourceChannelAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyResourceChannelDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ReadOnlyResourceChannelDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyResourceChannelRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public ReadOnlyResourceChannelRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new ReadOnlyResourceChannelDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyResourceChannelDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(ReadOnlyResourceChannelAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ReadOnlyResourceChannelDataInResponse_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(ReadOnlyResourceChannelRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelDataInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelDataInResponse_meta.cs new file mode 100644 index 0000000000..df106ea8b7 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyResourceChannelDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new readOnlyResourceChannelDataInResponse_meta and sets the default values. + /// + public ReadOnlyResourceChannelDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyResourceChannelDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyResourceChannelDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelPrimaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelPrimaryResponseDocument.cs new file mode 100644 index 0000000000..52e7a34306 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelPrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyResourceChannelPrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyResourceChannels? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public ReadOnlyResourceChannels Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyResourceChannelPrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ReadOnlyResourceChannelPrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new readOnlyResourceChannelPrimaryResponseDocument and sets the default values. + /// + public ReadOnlyResourceChannelPrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyResourceChannelPrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyResourceChannelPrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(ReadOnlyResourceChannels.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ReadOnlyResourceChannelPrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelPrimaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelPrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..d761caf19b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelPrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyResourceChannelPrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new readOnlyResourceChannelPrimaryResponseDocument_meta and sets the default values. + /// + public ReadOnlyResourceChannelPrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyResourceChannelPrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyResourceChannelPrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelRelationshipsInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelRelationshipsInResponse.cs new file mode 100644 index 0000000000..64d112216e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannelRelationshipsInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyResourceChannelRelationshipsInResponse : IBackedModel, IParsable { + /// The audioStreams property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyDataStreamInResponse? AudioStreams { + get { return BackingStore?.Get("audioStreams"); } + set { BackingStore?.Set("audioStreams", value); } + } +#nullable restore +#else + public ToManyDataStreamInResponse AudioStreams { + get { return BackingStore?.Get("audioStreams"); } + set { BackingStore?.Set("audioStreams", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The ultraHighDefinitionVideoStream property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOneDataStreamInResponse? UltraHighDefinitionVideoStream { + get { return BackingStore?.Get("ultraHighDefinitionVideoStream"); } + set { BackingStore?.Set("ultraHighDefinitionVideoStream", value); } + } +#nullable restore +#else + public NullableToOneDataStreamInResponse UltraHighDefinitionVideoStream { + get { return BackingStore?.Get("ultraHighDefinitionVideoStream"); } + set { BackingStore?.Set("ultraHighDefinitionVideoStream", value); } + } +#endif + /// The videoStream property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOneDataStreamInResponse? VideoStream { + get { return BackingStore?.Get("videoStream"); } + set { BackingStore?.Set("videoStream", value); } + } +#nullable restore +#else + public ToOneDataStreamInResponse VideoStream { + get { return BackingStore?.Get("videoStream"); } + set { BackingStore?.Set("videoStream", value); } + } +#endif + /// + /// Instantiates a new readOnlyResourceChannelRelationshipsInResponse and sets the default values. + /// + public ReadOnlyResourceChannelRelationshipsInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyResourceChannelRelationshipsInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyResourceChannelRelationshipsInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"audioStreams", n => { AudioStreams = n.GetObjectValue(ToManyDataStreamInResponse.CreateFromDiscriminatorValue); } }, + {"ultraHighDefinitionVideoStream", n => { UltraHighDefinitionVideoStream = n.GetObjectValue(NullableToOneDataStreamInResponse.CreateFromDiscriminatorValue); } }, + {"videoStream", n => { VideoStream = n.GetObjectValue(ToOneDataStreamInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("audioStreams", AudioStreams); + writer.WriteObjectValue("ultraHighDefinitionVideoStream", UltraHighDefinitionVideoStream); + writer.WriteObjectValue("videoStream", VideoStream); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannels.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannels.cs new file mode 100644 index 0000000000..36aed6a72a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannels.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyResourceChannels : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyResourceChannelAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public ReadOnlyResourceChannelAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyResourceChannels_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ReadOnlyResourceChannels_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ReadOnlyResourceChannelRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public ReadOnlyResourceChannelRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new ReadOnlyResourceChannels CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyResourceChannels(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(ReadOnlyResourceChannelAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ReadOnlyResourceChannels_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(ReadOnlyResourceChannelRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannels_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannels_meta.cs new file mode 100644 index 0000000000..4b672ab933 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ReadOnlyResourceChannels_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ReadOnlyResourceChannels_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new ReadOnlyResourceChannels_meta and sets the default values. + /// + public ReadOnlyResourceChannels_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ReadOnlyResourceChannels_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ReadOnlyResourceChannels_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToManyDataStreamInRequest.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToManyDataStreamInRequest.cs new file mode 100644 index 0000000000..8e0c86eb48 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToManyDataStreamInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ToManyDataStreamInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new toManyDataStreamInRequest and sets the default values. + /// + public ToManyDataStreamInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyDataStreamInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyDataStreamInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(DataStreamIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToManyDataStreamInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToManyDataStreamInResponse.cs new file mode 100644 index 0000000000..44b9ce6511 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToManyDataStreamInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ToManyDataStreamInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyDataStreamInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ToManyDataStreamInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new toManyDataStreamInResponse and sets the default values. + /// + public ToManyDataStreamInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyDataStreamInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyDataStreamInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(DataStreamIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ToManyDataStreamInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToManyDataStreamInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToManyDataStreamInResponse_meta.cs new file mode 100644 index 0000000000..a74a9d8ff1 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToManyDataStreamInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ToManyDataStreamInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new toManyDataStreamInResponse_meta and sets the default values. + /// + public ToManyDataStreamInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyDataStreamInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyDataStreamInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToOneDataStreamInRequest.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToOneDataStreamInRequest.cs new file mode 100644 index 0000000000..82251592f5 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToOneDataStreamInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ToOneDataStreamInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public DataStreamIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new toOneDataStreamInRequest and sets the default values. + /// + public ToOneDataStreamInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToOneDataStreamInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToOneDataStreamInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(DataStreamIdentifier.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToOneDataStreamInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToOneDataStreamInResponse.cs new file mode 100644 index 0000000000..ab515544e0 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToOneDataStreamInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ToOneDataStreamInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public DataStreamIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOneDataStreamInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ToOneDataStreamInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new toOneDataStreamInResponse and sets the default values. + /// + public ToOneDataStreamInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToOneDataStreamInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToOneDataStreamInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(DataStreamIdentifier.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ToOneDataStreamInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToOneDataStreamInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToOneDataStreamInResponse_meta.cs new file mode 100644 index 0000000000..f6b1ea7d30 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/ToOneDataStreamInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class ToOneDataStreamInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new toOneDataStreamInResponse_meta and sets the default values. + /// + public ToOneDataStreamInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToOneDataStreamInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToOneDataStreamInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/UltraHighDefinitionVideoStream.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/UltraHighDefinitionVideoStream.cs new file mode 100644 index 0000000000..80c4c4fc8f --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/UltraHighDefinitionVideoStream.cs @@ -0,0 +1,81 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class UltraHighDefinitionVideoStream : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public DataStreamAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public UltraHighDefinitionVideoStream_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public UltraHighDefinitionVideoStream_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new UltraHighDefinitionVideoStream CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new UltraHighDefinitionVideoStream(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(DataStreamAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(UltraHighDefinitionVideoStream_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/UltraHighDefinitionVideoStream_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/UltraHighDefinitionVideoStream_meta.cs new file mode 100644 index 0000000000..1e1babb87a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/UltraHighDefinitionVideoStream_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class UltraHighDefinitionVideoStream_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new ultraHighDefinitionVideoStream_meta and sets the default values. + /// + public UltraHighDefinitionVideoStream_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static UltraHighDefinitionVideoStream_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new UltraHighDefinitionVideoStream_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/VideoStream.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/VideoStream.cs new file mode 100644 index 0000000000..eb0d58e755 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/VideoStream.cs @@ -0,0 +1,81 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class VideoStream : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public DataStreamAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public DataStreamAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public VideoStream_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public VideoStream_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new VideoStream CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new VideoStream(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(DataStreamAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(VideoStream_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/VideoStream_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/VideoStream_meta.cs new file mode 100644 index 0000000000..370c85fbe5 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/VideoStream_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class VideoStream_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new videoStream_meta and sets the default values. + /// + public VideoStream_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static VideoStream_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new VideoStream_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelAttributesInPatchRequest.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelAttributesInPatchRequest.cs new file mode 100644 index 0000000000..8b87b2571b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelAttributesInPatchRequest.cs @@ -0,0 +1,71 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelAttributesInPatchRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The isAdultOnly property + public bool? IsAdultOnly { + get { return BackingStore?.Get("isAdultOnly"); } + set { BackingStore?.Set("isAdultOnly", value); } + } + /// The isCommercial property + public bool? IsCommercial { + get { return BackingStore?.Get("isCommercial"); } + set { BackingStore?.Set("isCommercial", value); } + } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new writeOnlyChannelAttributesInPatchRequest and sets the default values. + /// + public WriteOnlyChannelAttributesInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelAttributesInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelAttributesInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"isAdultOnly", n => { IsAdultOnly = n.GetBoolValue(); } }, + {"isCommercial", n => { IsCommercial = n.GetBoolValue(); } }, + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteBoolValue("isAdultOnly", IsAdultOnly); + writer.WriteBoolValue("isCommercial", IsCommercial); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelAttributesInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelAttributesInPostRequest.cs new file mode 100644 index 0000000000..f4be0b347d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelAttributesInPostRequest.cs @@ -0,0 +1,71 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelAttributesInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The isAdultOnly property + public bool? IsAdultOnly { + get { return BackingStore?.Get("isAdultOnly"); } + set { BackingStore?.Set("isAdultOnly", value); } + } + /// The isCommercial property + public bool? IsCommercial { + get { return BackingStore?.Get("isCommercial"); } + set { BackingStore?.Set("isCommercial", value); } + } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new writeOnlyChannelAttributesInPostRequest and sets the default values. + /// + public WriteOnlyChannelAttributesInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelAttributesInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelAttributesInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"isAdultOnly", n => { IsAdultOnly = n.GetBoolValue(); } }, + {"isCommercial", n => { IsCommercial = n.GetBoolValue(); } }, + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteBoolValue("isAdultOnly", IsAdultOnly); + writer.WriteBoolValue("isCommercial", IsCommercial); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelAttributesInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelAttributesInResponse.cs new file mode 100644 index 0000000000..45ed6eb1be --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelAttributesInResponse.cs @@ -0,0 +1,71 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The isAdultOnly property + public bool? IsAdultOnly { + get { return BackingStore?.Get("isAdultOnly"); } + set { BackingStore?.Set("isAdultOnly", value); } + } + /// The isCommercial property + public bool? IsCommercial { + get { return BackingStore?.Get("isCommercial"); } + set { BackingStore?.Set("isCommercial", value); } + } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new writeOnlyChannelAttributesInResponse and sets the default values. + /// + public WriteOnlyChannelAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"isAdultOnly", n => { IsAdultOnly = n.GetBoolValue(); } }, + {"isCommercial", n => { IsCommercial = n.GetBoolValue(); } }, + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteBoolValue("isAdultOnly", IsAdultOnly); + writer.WriteBoolValue("isCommercial", IsCommercial); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelDataInPatchRequest.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelDataInPatchRequest.cs new file mode 100644 index 0000000000..585a5f19f4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelDataInPatchRequest.cs @@ -0,0 +1,96 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelDataInPatchRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannelAttributesInPatchRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public WriteOnlyChannelAttributesInPatchRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannelRelationshipsInPatchRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public WriteOnlyChannelRelationshipsInPatchRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public WriteOnlyChannelResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new writeOnlyChannelDataInPatchRequest and sets the default values. + /// + public WriteOnlyChannelDataInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelDataInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelDataInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(WriteOnlyChannelAttributesInPatchRequest.CreateFromDiscriminatorValue); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"relationships", n => { Relationships = n.GetObjectValue(WriteOnlyChannelRelationshipsInPatchRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelDataInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelDataInPostRequest.cs new file mode 100644 index 0000000000..2fe8a83583 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelDataInPostRequest.cs @@ -0,0 +1,80 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelDataInPostRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannelAttributesInPostRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public WriteOnlyChannelAttributesInPostRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannelRelationshipsInPostRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public WriteOnlyChannelRelationshipsInPostRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public WriteOnlyChannelResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new writeOnlyChannelDataInPostRequest and sets the default values. + /// + public WriteOnlyChannelDataInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelDataInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelDataInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(WriteOnlyChannelAttributesInPostRequest.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(WriteOnlyChannelRelationshipsInPostRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelDataInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelDataInResponse.cs new file mode 100644 index 0000000000..5f2e816aba --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelDataInResponse.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannelAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public WriteOnlyChannelAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannelDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public WriteOnlyChannelDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannelRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public WriteOnlyChannelRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new WriteOnlyChannelDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(WriteOnlyChannelAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(WriteOnlyChannelDataInResponse_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(WriteOnlyChannelRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelDataInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelDataInResponse_meta.cs new file mode 100644 index 0000000000..d95c9a238e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new writeOnlyChannelDataInResponse_meta and sets the default values. + /// + public WriteOnlyChannelDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelPatchRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelPatchRequestDocument.cs new file mode 100644 index 0000000000..729d9c4817 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelPatchRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelPatchRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannelDataInPatchRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public WriteOnlyChannelDataInPatchRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new writeOnlyChannelPatchRequestDocument and sets the default values. + /// + public WriteOnlyChannelPatchRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelPatchRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelPatchRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(WriteOnlyChannelDataInPatchRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelPostRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelPostRequestDocument.cs new file mode 100644 index 0000000000..a002baca36 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelPostRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelPostRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannelDataInPostRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public WriteOnlyChannelDataInPostRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new writeOnlyChannelPostRequestDocument and sets the default values. + /// + public WriteOnlyChannelPostRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelPostRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelPostRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(WriteOnlyChannelDataInPostRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelPrimaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelPrimaryResponseDocument.cs new file mode 100644 index 0000000000..be8841fcd2 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelPrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelPrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannels? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public WriteOnlyChannels Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannelPrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public WriteOnlyChannelPrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new writeOnlyChannelPrimaryResponseDocument and sets the default values. + /// + public WriteOnlyChannelPrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelPrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelPrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(WriteOnlyChannels.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(WriteOnlyChannelPrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelPrimaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelPrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..c38391dc85 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelPrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelPrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new writeOnlyChannelPrimaryResponseDocument_meta and sets the default values. + /// + public WriteOnlyChannelPrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelPrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelPrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelRelationshipsInPatchRequest.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelRelationshipsInPatchRequest.cs new file mode 100644 index 0000000000..6d70f0d57a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelRelationshipsInPatchRequest.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelRelationshipsInPatchRequest : IBackedModel, IParsable { + /// The audioStreams property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyDataStreamInRequest? AudioStreams { + get { return BackingStore?.Get("audioStreams"); } + set { BackingStore?.Set("audioStreams", value); } + } +#nullable restore +#else + public ToManyDataStreamInRequest AudioStreams { + get { return BackingStore?.Get("audioStreams"); } + set { BackingStore?.Set("audioStreams", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The ultraHighDefinitionVideoStream property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOneDataStreamInRequest? UltraHighDefinitionVideoStream { + get { return BackingStore?.Get("ultraHighDefinitionVideoStream"); } + set { BackingStore?.Set("ultraHighDefinitionVideoStream", value); } + } +#nullable restore +#else + public NullableToOneDataStreamInRequest UltraHighDefinitionVideoStream { + get { return BackingStore?.Get("ultraHighDefinitionVideoStream"); } + set { BackingStore?.Set("ultraHighDefinitionVideoStream", value); } + } +#endif + /// The videoStream property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOneDataStreamInRequest? VideoStream { + get { return BackingStore?.Get("videoStream"); } + set { BackingStore?.Set("videoStream", value); } + } +#nullable restore +#else + public ToOneDataStreamInRequest VideoStream { + get { return BackingStore?.Get("videoStream"); } + set { BackingStore?.Set("videoStream", value); } + } +#endif + /// + /// Instantiates a new writeOnlyChannelRelationshipsInPatchRequest and sets the default values. + /// + public WriteOnlyChannelRelationshipsInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelRelationshipsInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelRelationshipsInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"audioStreams", n => { AudioStreams = n.GetObjectValue(ToManyDataStreamInRequest.CreateFromDiscriminatorValue); } }, + {"ultraHighDefinitionVideoStream", n => { UltraHighDefinitionVideoStream = n.GetObjectValue(NullableToOneDataStreamInRequest.CreateFromDiscriminatorValue); } }, + {"videoStream", n => { VideoStream = n.GetObjectValue(ToOneDataStreamInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("audioStreams", AudioStreams); + writer.WriteObjectValue("ultraHighDefinitionVideoStream", UltraHighDefinitionVideoStream); + writer.WriteObjectValue("videoStream", VideoStream); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelRelationshipsInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelRelationshipsInPostRequest.cs new file mode 100644 index 0000000000..2fc5389c90 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelRelationshipsInPostRequest.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelRelationshipsInPostRequest : IBackedModel, IParsable { + /// The audioStreams property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyDataStreamInRequest? AudioStreams { + get { return BackingStore?.Get("audioStreams"); } + set { BackingStore?.Set("audioStreams", value); } + } +#nullable restore +#else + public ToManyDataStreamInRequest AudioStreams { + get { return BackingStore?.Get("audioStreams"); } + set { BackingStore?.Set("audioStreams", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The ultraHighDefinitionVideoStream property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOneDataStreamInRequest? UltraHighDefinitionVideoStream { + get { return BackingStore?.Get("ultraHighDefinitionVideoStream"); } + set { BackingStore?.Set("ultraHighDefinitionVideoStream", value); } + } +#nullable restore +#else + public NullableToOneDataStreamInRequest UltraHighDefinitionVideoStream { + get { return BackingStore?.Get("ultraHighDefinitionVideoStream"); } + set { BackingStore?.Set("ultraHighDefinitionVideoStream", value); } + } +#endif + /// The videoStream property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOneDataStreamInRequest? VideoStream { + get { return BackingStore?.Get("videoStream"); } + set { BackingStore?.Set("videoStream", value); } + } +#nullable restore +#else + public ToOneDataStreamInRequest VideoStream { + get { return BackingStore?.Get("videoStream"); } + set { BackingStore?.Set("videoStream", value); } + } +#endif + /// + /// Instantiates a new writeOnlyChannelRelationshipsInPostRequest and sets the default values. + /// + public WriteOnlyChannelRelationshipsInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelRelationshipsInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelRelationshipsInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"audioStreams", n => { AudioStreams = n.GetObjectValue(ToManyDataStreamInRequest.CreateFromDiscriminatorValue); } }, + {"ultraHighDefinitionVideoStream", n => { UltraHighDefinitionVideoStream = n.GetObjectValue(NullableToOneDataStreamInRequest.CreateFromDiscriminatorValue); } }, + {"videoStream", n => { VideoStream = n.GetObjectValue(ToOneDataStreamInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("audioStreams", AudioStreams); + writer.WriteObjectValue("ultraHighDefinitionVideoStream", UltraHighDefinitionVideoStream); + writer.WriteObjectValue("videoStream", VideoStream); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelRelationshipsInResponse.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelRelationshipsInResponse.cs new file mode 100644 index 0000000000..ee16a45266 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelRelationshipsInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannelRelationshipsInResponse : IBackedModel, IParsable { + /// The audioStreams property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyDataStreamInResponse? AudioStreams { + get { return BackingStore?.Get("audioStreams"); } + set { BackingStore?.Set("audioStreams", value); } + } +#nullable restore +#else + public ToManyDataStreamInResponse AudioStreams { + get { return BackingStore?.Get("audioStreams"); } + set { BackingStore?.Set("audioStreams", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The ultraHighDefinitionVideoStream property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOneDataStreamInResponse? UltraHighDefinitionVideoStream { + get { return BackingStore?.Get("ultraHighDefinitionVideoStream"); } + set { BackingStore?.Set("ultraHighDefinitionVideoStream", value); } + } +#nullable restore +#else + public NullableToOneDataStreamInResponse UltraHighDefinitionVideoStream { + get { return BackingStore?.Get("ultraHighDefinitionVideoStream"); } + set { BackingStore?.Set("ultraHighDefinitionVideoStream", value); } + } +#endif + /// The videoStream property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOneDataStreamInResponse? VideoStream { + get { return BackingStore?.Get("videoStream"); } + set { BackingStore?.Set("videoStream", value); } + } +#nullable restore +#else + public ToOneDataStreamInResponse VideoStream { + get { return BackingStore?.Get("videoStream"); } + set { BackingStore?.Set("videoStream", value); } + } +#endif + /// + /// Instantiates a new writeOnlyChannelRelationshipsInResponse and sets the default values. + /// + public WriteOnlyChannelRelationshipsInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannelRelationshipsInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannelRelationshipsInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"audioStreams", n => { AudioStreams = n.GetObjectValue(ToManyDataStreamInResponse.CreateFromDiscriminatorValue); } }, + {"ultraHighDefinitionVideoStream", n => { UltraHighDefinitionVideoStream = n.GetObjectValue(NullableToOneDataStreamInResponse.CreateFromDiscriminatorValue); } }, + {"videoStream", n => { VideoStream = n.GetObjectValue(ToOneDataStreamInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("audioStreams", AudioStreams); + writer.WriteObjectValue("ultraHighDefinitionVideoStream", UltraHighDefinitionVideoStream); + writer.WriteObjectValue("videoStream", VideoStream); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelResourceType.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelResourceType.cs new file mode 100644 index 0000000000..3d2acffe74 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannelResourceType.cs @@ -0,0 +1,9 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public enum WriteOnlyChannelResourceType { + [EnumMember(Value = "writeOnlyChannels")] + WriteOnlyChannels, + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannels.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannels.cs new file mode 100644 index 0000000000..392a2578fe --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannels.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannels : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannelAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public WriteOnlyChannelAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannels_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public WriteOnlyChannels_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public WriteOnlyChannelRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public WriteOnlyChannelRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new WriteOnlyChannels CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannels(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(WriteOnlyChannelAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(WriteOnlyChannels_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(WriteOnlyChannelRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannels_meta.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannels_meta.cs new file mode 100644 index 0000000000..42432cdb83 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/Models/WriteOnlyChannels_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models { + public class WriteOnlyChannels_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new writeOnlyChannels_meta and sets the default values. + /// + public WriteOnlyChannels_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static WriteOnlyChannels_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new WriteOnlyChannels_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/AudioStreams/AudioStreamsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/AudioStreams/AudioStreamsRequestBuilder.cs new file mode 100644 index 0000000000..a0eb5a9389 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/AudioStreams/AudioStreamsRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.AudioStreams { + /// + /// Builds and executes requests for operations under \readOnlyChannels\{id}\audioStreams + /// + public class AudioStreamsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new AudioStreamsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public AudioStreamsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/audioStreams{?query*}", pathParameters) { + } + /// + /// Instantiates a new AudioStreamsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public AudioStreamsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/audioStreams{?query*}", rawUrl) { + } + /// + /// Retrieves the related dataStreams of an individual readOnlyChannel's audioStreams relationship. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, DataStreamCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related dataStreams of an individual readOnlyChannel's audioStreams relationship. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public AudioStreamsRequestBuilder WithUrl(string rawUrl) { + return new AudioStreamsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related dataStreams of an individual readOnlyChannel's audioStreams relationship. + /// + public class AudioStreamsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class AudioStreamsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/ReadOnlyChannelsItemRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/ReadOnlyChannelsItemRequestBuilder.cs new file mode 100644 index 0000000000..21f825648b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/ReadOnlyChannelsItemRequestBuilder.cs @@ -0,0 +1,153 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.AudioStreams; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.Relationships; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.UltraHighDefinitionVideoStream; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.VideoStream; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item { + /// + /// Builds and executes requests for operations under \readOnlyChannels\{id} + /// + public class ReadOnlyChannelsItemRequestBuilder : BaseRequestBuilder { + /// The audioStreams property + public AudioStreamsRequestBuilder AudioStreams { get => + new AudioStreamsRequestBuilder(PathParameters, RequestAdapter); + } + /// The relationships property + public RelationshipsRequestBuilder Relationships { get => + new RelationshipsRequestBuilder(PathParameters, RequestAdapter); + } + /// The ultraHighDefinitionVideoStream property + public UltraHighDefinitionVideoStreamRequestBuilder UltraHighDefinitionVideoStream { get => + new UltraHighDefinitionVideoStreamRequestBuilder(PathParameters, RequestAdapter); + } + /// The videoStream property + public VideoStreamRequestBuilder VideoStream { get => + new VideoStreamRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new ReadOnlyChannelsItemRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public ReadOnlyChannelsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}{?query*}", pathParameters) { + } + /// + /// Instantiates a new ReadOnlyChannelsItemRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public ReadOnlyChannelsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}{?query*}", rawUrl) { + } + /// + /// Retrieves an individual readOnlyChannel by its identifier. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, ReadOnlyChannelPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves an individual readOnlyChannel by its identifier. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public ReadOnlyChannelsItemRequestBuilder WithUrl(string rawUrl) { + return new ReadOnlyChannelsItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves an individual readOnlyChannel by its identifier. + /// + public class ReadOnlyChannelsItemRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class ReadOnlyChannelsItemRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/Relationships/AudioStreams/AudioStreamsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/Relationships/AudioStreams/AudioStreamsRequestBuilder.cs new file mode 100644 index 0000000000..c947b745c6 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/Relationships/AudioStreams/AudioStreamsRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.Relationships.AudioStreams { + /// + /// Builds and executes requests for operations under \readOnlyChannels\{id}\relationships\audioStreams + /// + public class AudioStreamsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new AudioStreamsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public AudioStreamsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/relationships/audioStreams{?query*}", pathParameters) { + } + /// + /// Instantiates a new AudioStreamsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public AudioStreamsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/relationships/audioStreams{?query*}", rawUrl) { + } + /// + /// Retrieves the related dataStream identities of an individual readOnlyChannel's audioStreams relationship. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, DataStreamIdentifierCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related dataStream identities of an individual readOnlyChannel's audioStreams relationship. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public AudioStreamsRequestBuilder WithUrl(string rawUrl) { + return new AudioStreamsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related dataStream identities of an individual readOnlyChannel's audioStreams relationship. + /// + public class AudioStreamsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class AudioStreamsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/Relationships/RelationshipsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/Relationships/RelationshipsRequestBuilder.cs new file mode 100644 index 0000000000..923ebcaaf9 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/Relationships/RelationshipsRequestBuilder.cs @@ -0,0 +1,43 @@ +// +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.Relationships.AudioStreams; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.Relationships.UltraHighDefinitionVideoStream; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.Relationships.VideoStream; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.Relationships { + /// + /// Builds and executes requests for operations under \readOnlyChannels\{id}\relationships + /// + public class RelationshipsRequestBuilder : BaseRequestBuilder { + /// The audioStreams property + public AudioStreamsRequestBuilder AudioStreams { get => + new AudioStreamsRequestBuilder(PathParameters, RequestAdapter); + } + /// The ultraHighDefinitionVideoStream property + public UltraHighDefinitionVideoStreamRequestBuilder UltraHighDefinitionVideoStream { get => + new UltraHighDefinitionVideoStreamRequestBuilder(PathParameters, RequestAdapter); + } + /// The videoStream property + public VideoStreamRequestBuilder VideoStream { get => + new VideoStreamRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/relationships", pathParameters) { + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/relationships", rawUrl) { + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/Relationships/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/Relationships/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs new file mode 100644 index 0000000000..21f974019a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/Relationships/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.Relationships.UltraHighDefinitionVideoStream { + /// + /// Builds and executes requests for operations under \readOnlyChannels\{id}\relationships\ultraHighDefinitionVideoStream + /// + public class UltraHighDefinitionVideoStreamRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new UltraHighDefinitionVideoStreamRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public UltraHighDefinitionVideoStreamRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/relationships/ultraHighDefinitionVideoStream{?query*}", pathParameters) { + } + /// + /// Instantiates a new UltraHighDefinitionVideoStreamRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public UltraHighDefinitionVideoStreamRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/relationships/ultraHighDefinitionVideoStream{?query*}", rawUrl) { + } + /// + /// Retrieves the related dataStream identity of an individual readOnlyChannel's ultraHighDefinitionVideoStream relationship. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NullableDataStreamIdentifierResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related dataStream identity of an individual readOnlyChannel's ultraHighDefinitionVideoStream relationship. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public UltraHighDefinitionVideoStreamRequestBuilder WithUrl(string rawUrl) { + return new UltraHighDefinitionVideoStreamRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related dataStream identity of an individual readOnlyChannel's ultraHighDefinitionVideoStream relationship. + /// + public class UltraHighDefinitionVideoStreamRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class UltraHighDefinitionVideoStreamRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/Relationships/VideoStream/VideoStreamRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/Relationships/VideoStream/VideoStreamRequestBuilder.cs new file mode 100644 index 0000000000..c099f1cb4d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/Relationships/VideoStream/VideoStreamRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.Relationships.VideoStream { + /// + /// Builds and executes requests for operations under \readOnlyChannels\{id}\relationships\videoStream + /// + public class VideoStreamRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new VideoStreamRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public VideoStreamRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/relationships/videoStream{?query*}", pathParameters) { + } + /// + /// Instantiates a new VideoStreamRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public VideoStreamRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/relationships/videoStream{?query*}", rawUrl) { + } + /// + /// Retrieves the related dataStream identity of an individual readOnlyChannel's videoStream relationship. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, DataStreamIdentifierResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related dataStream identity of an individual readOnlyChannel's videoStream relationship. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public VideoStreamRequestBuilder WithUrl(string rawUrl) { + return new VideoStreamRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related dataStream identity of an individual readOnlyChannel's videoStream relationship. + /// + public class VideoStreamRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class VideoStreamRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs new file mode 100644 index 0000000000..705ef8ddf9 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.UltraHighDefinitionVideoStream { + /// + /// Builds and executes requests for operations under \readOnlyChannels\{id}\ultraHighDefinitionVideoStream + /// + public class UltraHighDefinitionVideoStreamRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new UltraHighDefinitionVideoStreamRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public UltraHighDefinitionVideoStreamRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/ultraHighDefinitionVideoStream{?query*}", pathParameters) { + } + /// + /// Instantiates a new UltraHighDefinitionVideoStreamRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public UltraHighDefinitionVideoStreamRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/ultraHighDefinitionVideoStream{?query*}", rawUrl) { + } + /// + /// Retrieves the related dataStream of an individual readOnlyChannel's ultraHighDefinitionVideoStream relationship. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NullableDataStreamSecondaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related dataStream of an individual readOnlyChannel's ultraHighDefinitionVideoStream relationship. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public UltraHighDefinitionVideoStreamRequestBuilder WithUrl(string rawUrl) { + return new UltraHighDefinitionVideoStreamRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related dataStream of an individual readOnlyChannel's ultraHighDefinitionVideoStream relationship. + /// + public class UltraHighDefinitionVideoStreamRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class UltraHighDefinitionVideoStreamRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/VideoStream/VideoStreamRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/VideoStream/VideoStreamRequestBuilder.cs new file mode 100644 index 0000000000..a2562b2a1d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/Item/VideoStream/VideoStreamRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item.VideoStream { + /// + /// Builds and executes requests for operations under \readOnlyChannels\{id}\videoStream + /// + public class VideoStreamRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new VideoStreamRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public VideoStreamRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/videoStream{?query*}", pathParameters) { + } + /// + /// Instantiates a new VideoStreamRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public VideoStreamRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels/{id}/videoStream{?query*}", rawUrl) { + } + /// + /// Retrieves the related dataStream of an individual readOnlyChannel's videoStream relationship. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, DataStreamSecondaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related dataStream of an individual readOnlyChannel's videoStream relationship. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public VideoStreamRequestBuilder WithUrl(string rawUrl) { + return new VideoStreamRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related dataStream of an individual readOnlyChannel's videoStream relationship. + /// + public class VideoStreamRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class VideoStreamRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/ReadOnlyChannelsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/ReadOnlyChannelsRequestBuilder.cs new file mode 100644 index 0000000000..da95b04923 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyChannels/ReadOnlyChannelsRequestBuilder.cs @@ -0,0 +1,140 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels.Item; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels { + /// + /// Builds and executes requests for operations under \readOnlyChannels + /// + public class ReadOnlyChannelsRequestBuilder : BaseRequestBuilder { + /// Gets an item from the OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.readOnlyChannels.item collection + /// The identifier of the readOnlyChannel to retrieve. + public ReadOnlyChannelsItemRequestBuilder this[string position] { get { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new ReadOnlyChannelsItemRequestBuilder(urlTplParams, RequestAdapter); + } } + /// + /// Instantiates a new ReadOnlyChannelsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public ReadOnlyChannelsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels{?query*}", pathParameters) { + } + /// + /// Instantiates a new ReadOnlyChannelsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public ReadOnlyChannelsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyChannels{?query*}", rawUrl) { + } + /// + /// Retrieves a collection of readOnlyChannels. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, ReadOnlyChannelCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves a collection of readOnlyChannels. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public ReadOnlyChannelsRequestBuilder WithUrl(string rawUrl) { + return new ReadOnlyChannelsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves a collection of readOnlyChannels. + /// + public class ReadOnlyChannelsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class ReadOnlyChannelsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/Item/AudioStreams/AudioStreamsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/Item/AudioStreams/AudioStreamsRequestBuilder.cs new file mode 100644 index 0000000000..212f15810a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/Item/AudioStreams/AudioStreamsRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyResourceChannels.Item.AudioStreams { + /// + /// Builds and executes requests for operations under \readOnlyResourceChannels\{id}\audioStreams + /// + public class AudioStreamsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new AudioStreamsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public AudioStreamsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyResourceChannels/{id}/audioStreams{?query*}", pathParameters) { + } + /// + /// Instantiates a new AudioStreamsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public AudioStreamsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyResourceChannels/{id}/audioStreams{?query*}", rawUrl) { + } + /// + /// Retrieves the related dataStreams of an individual readOnlyResourceChannel's audioStreams relationship. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, DataStreamCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related dataStreams of an individual readOnlyResourceChannel's audioStreams relationship. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public AudioStreamsRequestBuilder WithUrl(string rawUrl) { + return new AudioStreamsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related dataStreams of an individual readOnlyResourceChannel's audioStreams relationship. + /// + public class AudioStreamsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class AudioStreamsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/Item/ReadOnlyResourceChannelsItemRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/Item/ReadOnlyResourceChannelsItemRequestBuilder.cs new file mode 100644 index 0000000000..c8ae9bebed --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/Item/ReadOnlyResourceChannelsItemRequestBuilder.cs @@ -0,0 +1,148 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyResourceChannels.Item.AudioStreams; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyResourceChannels.Item.UltraHighDefinitionVideoStream; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyResourceChannels.Item.VideoStream; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyResourceChannels.Item { + /// + /// Builds and executes requests for operations under \readOnlyResourceChannels\{id} + /// + public class ReadOnlyResourceChannelsItemRequestBuilder : BaseRequestBuilder { + /// The audioStreams property + public AudioStreamsRequestBuilder AudioStreams { get => + new AudioStreamsRequestBuilder(PathParameters, RequestAdapter); + } + /// The ultraHighDefinitionVideoStream property + public UltraHighDefinitionVideoStreamRequestBuilder UltraHighDefinitionVideoStream { get => + new UltraHighDefinitionVideoStreamRequestBuilder(PathParameters, RequestAdapter); + } + /// The videoStream property + public VideoStreamRequestBuilder VideoStream { get => + new VideoStreamRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new ReadOnlyResourceChannelsItemRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public ReadOnlyResourceChannelsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyResourceChannels/{id}{?query*}", pathParameters) { + } + /// + /// Instantiates a new ReadOnlyResourceChannelsItemRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public ReadOnlyResourceChannelsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyResourceChannels/{id}{?query*}", rawUrl) { + } + /// + /// Retrieves an individual readOnlyResourceChannel by its identifier. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, ReadOnlyResourceChannelPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves an individual readOnlyResourceChannel by its identifier. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public ReadOnlyResourceChannelsItemRequestBuilder WithUrl(string rawUrl) { + return new ReadOnlyResourceChannelsItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves an individual readOnlyResourceChannel by its identifier. + /// + public class ReadOnlyResourceChannelsItemRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class ReadOnlyResourceChannelsItemRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/Item/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/Item/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs new file mode 100644 index 0000000000..5507e5ae18 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/Item/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyResourceChannels.Item.UltraHighDefinitionVideoStream { + /// + /// Builds and executes requests for operations under \readOnlyResourceChannels\{id}\ultraHighDefinitionVideoStream + /// + public class UltraHighDefinitionVideoStreamRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new UltraHighDefinitionVideoStreamRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public UltraHighDefinitionVideoStreamRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyResourceChannels/{id}/ultraHighDefinitionVideoStream{?query*}", pathParameters) { + } + /// + /// Instantiates a new UltraHighDefinitionVideoStreamRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public UltraHighDefinitionVideoStreamRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyResourceChannels/{id}/ultraHighDefinitionVideoStream{?query*}", rawUrl) { + } + /// + /// Retrieves the related dataStream of an individual readOnlyResourceChannel's ultraHighDefinitionVideoStream relationship. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NullableDataStreamSecondaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related dataStream of an individual readOnlyResourceChannel's ultraHighDefinitionVideoStream relationship. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public UltraHighDefinitionVideoStreamRequestBuilder WithUrl(string rawUrl) { + return new UltraHighDefinitionVideoStreamRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related dataStream of an individual readOnlyResourceChannel's ultraHighDefinitionVideoStream relationship. + /// + public class UltraHighDefinitionVideoStreamRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class UltraHighDefinitionVideoStreamRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/Item/VideoStream/VideoStreamRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/Item/VideoStream/VideoStreamRequestBuilder.cs new file mode 100644 index 0000000000..1eb0def9b0 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/Item/VideoStream/VideoStreamRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyResourceChannels.Item.VideoStream { + /// + /// Builds and executes requests for operations under \readOnlyResourceChannels\{id}\videoStream + /// + public class VideoStreamRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new VideoStreamRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public VideoStreamRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyResourceChannels/{id}/videoStream{?query*}", pathParameters) { + } + /// + /// Instantiates a new VideoStreamRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public VideoStreamRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyResourceChannels/{id}/videoStream{?query*}", rawUrl) { + } + /// + /// Retrieves the related dataStream of an individual readOnlyResourceChannel's videoStream relationship. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, DataStreamSecondaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related dataStream of an individual readOnlyResourceChannel's videoStream relationship. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public VideoStreamRequestBuilder WithUrl(string rawUrl) { + return new VideoStreamRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related dataStream of an individual readOnlyResourceChannel's videoStream relationship. + /// + public class VideoStreamRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class VideoStreamRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/ReadOnlyResourceChannelsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/ReadOnlyResourceChannelsRequestBuilder.cs new file mode 100644 index 0000000000..123ad6207d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/ReadOnlyResourceChannels/ReadOnlyResourceChannelsRequestBuilder.cs @@ -0,0 +1,140 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyResourceChannels.Item; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyResourceChannels { + /// + /// Builds and executes requests for operations under \readOnlyResourceChannels + /// + public class ReadOnlyResourceChannelsRequestBuilder : BaseRequestBuilder { + /// Gets an item from the OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.readOnlyResourceChannels.item collection + /// The identifier of the readOnlyResourceChannel to retrieve. + public ReadOnlyResourceChannelsItemRequestBuilder this[string position] { get { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new ReadOnlyResourceChannelsItemRequestBuilder(urlTplParams, RequestAdapter); + } } + /// + /// Instantiates a new ReadOnlyResourceChannelsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public ReadOnlyResourceChannelsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyResourceChannels{?query*}", pathParameters) { + } + /// + /// Instantiates a new ReadOnlyResourceChannelsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public ReadOnlyResourceChannelsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/readOnlyResourceChannels{?query*}", rawUrl) { + } + /// + /// Retrieves a collection of readOnlyResourceChannels. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, ReadOnlyResourceChannelCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves a collection of readOnlyResourceChannels. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public ReadOnlyResourceChannelsRequestBuilder WithUrl(string rawUrl) { + return new ReadOnlyResourceChannelsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves a collection of readOnlyResourceChannels. + /// + public class ReadOnlyResourceChannelsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class ReadOnlyResourceChannelsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/RelationshipChannelsItemRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/RelationshipChannelsItemRequestBuilder.cs new file mode 100644 index 0000000000..779f5ae91e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/RelationshipChannelsItemRequestBuilder.cs @@ -0,0 +1,33 @@ +// +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.RelationshipChannels.Item.Relationships; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.RelationshipChannels.Item { + /// + /// Builds and executes requests for operations under \relationshipChannels\{id} + /// + public class RelationshipChannelsItemRequestBuilder : BaseRequestBuilder { + /// The relationships property + public RelationshipsRequestBuilder Relationships { get => + new RelationshipsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new RelationshipChannelsItemRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RelationshipChannelsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/relationshipChannels/{id}", pathParameters) { + } + /// + /// Instantiates a new RelationshipChannelsItemRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipChannelsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/relationshipChannels/{id}", rawUrl) { + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/Relationships/AudioStreams/AudioStreamsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/Relationships/AudioStreams/AudioStreamsRequestBuilder.cs new file mode 100644 index 0000000000..e630915111 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/Relationships/AudioStreams/AudioStreamsRequestBuilder.cs @@ -0,0 +1,256 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.RelationshipChannels.Item.Relationships.AudioStreams { + /// + /// Builds and executes requests for operations under \relationshipChannels\{id}\relationships\audioStreams + /// + public class AudioStreamsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new AudioStreamsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public AudioStreamsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/relationshipChannels/{id}/relationships/audioStreams{?query*}", pathParameters) { + } + /// + /// Instantiates a new AudioStreamsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public AudioStreamsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/relationshipChannels/{id}/relationships/audioStreams{?query*}", rawUrl) { + } + /// + /// Removes existing dataStreams from the audioStreams relationship of an individual relationshipChannel. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task DeleteAsync(ToManyDataStreamInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(ToManyDataStreamInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToDeleteRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related dataStream identities of an individual relationshipChannel's audioStreams relationship. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, DataStreamIdentifierCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns existing dataStreams to the audioStreams relationship of an individual relationshipChannel. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PatchAsync(ToManyDataStreamInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToManyDataStreamInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Adds existing dataStreams to the audioStreams relationship of an individual relationshipChannel. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PostAsync(ToManyDataStreamInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(ToManyDataStreamInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Removes existing dataStreams from the audioStreams relationship of an individual relationshipChannel. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToDeleteRequestInformation(ToManyDataStreamInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(ToManyDataStreamInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Retrieves the related dataStream identities of an individual relationshipChannel's audioStreams relationship. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Assigns existing dataStreams to the audioStreams relationship of an individual relationshipChannel. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPatchRequestInformation(ToManyDataStreamInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToManyDataStreamInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Adds existing dataStreams to the audioStreams relationship of an individual relationshipChannel. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPostRequestInformation(ToManyDataStreamInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(ToManyDataStreamInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public AudioStreamsRequestBuilder WithUrl(string rawUrl) { + return new AudioStreamsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related dataStream identities of an individual relationshipChannel's audioStreams relationship. + /// + public class AudioStreamsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class AudioStreamsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/Relationships/RelationshipsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/Relationships/RelationshipsRequestBuilder.cs new file mode 100644 index 0000000000..0b3a0851d7 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/Relationships/RelationshipsRequestBuilder.cs @@ -0,0 +1,43 @@ +// +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.RelationshipChannels.Item.Relationships.AudioStreams; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.RelationshipChannels.Item.Relationships.UltraHighDefinitionVideoStream; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.RelationshipChannels.Item.Relationships.VideoStream; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.RelationshipChannels.Item.Relationships { + /// + /// Builds and executes requests for operations under \relationshipChannels\{id}\relationships + /// + public class RelationshipsRequestBuilder : BaseRequestBuilder { + /// The audioStreams property + public AudioStreamsRequestBuilder AudioStreams { get => + new AudioStreamsRequestBuilder(PathParameters, RequestAdapter); + } + /// The ultraHighDefinitionVideoStream property + public UltraHighDefinitionVideoStreamRequestBuilder UltraHighDefinitionVideoStream { get => + new UltraHighDefinitionVideoStreamRequestBuilder(PathParameters, RequestAdapter); + } + /// The videoStream property + public VideoStreamRequestBuilder VideoStream { get => + new VideoStreamRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/relationshipChannels/{id}/relationships", pathParameters) { + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/relationshipChannels/{id}/relationships", rawUrl) { + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/Relationships/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/Relationships/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs new file mode 100644 index 0000000000..a5ea77b46c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/Relationships/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs @@ -0,0 +1,174 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.RelationshipChannels.Item.Relationships.UltraHighDefinitionVideoStream { + /// + /// Builds and executes requests for operations under \relationshipChannels\{id}\relationships\ultraHighDefinitionVideoStream + /// + public class UltraHighDefinitionVideoStreamRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new UltraHighDefinitionVideoStreamRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public UltraHighDefinitionVideoStreamRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/relationshipChannels/{id}/relationships/ultraHighDefinitionVideoStream{?query*}", pathParameters) { + } + /// + /// Instantiates a new UltraHighDefinitionVideoStreamRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public UltraHighDefinitionVideoStreamRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/relationshipChannels/{id}/relationships/ultraHighDefinitionVideoStream{?query*}", rawUrl) { + } + /// + /// Retrieves the related dataStream identity of an individual relationshipChannel's ultraHighDefinitionVideoStream relationship. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NullableDataStreamIdentifierResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Clears or assigns an existing dataStream to the ultraHighDefinitionVideoStream relationship of an individual relationshipChannel. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PatchAsync(NullableToOneDataStreamInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(NullableToOneDataStreamInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related dataStream identity of an individual relationshipChannel's ultraHighDefinitionVideoStream relationship. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Clears or assigns an existing dataStream to the ultraHighDefinitionVideoStream relationship of an individual relationshipChannel. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPatchRequestInformation(NullableToOneDataStreamInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(NullableToOneDataStreamInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public UltraHighDefinitionVideoStreamRequestBuilder WithUrl(string rawUrl) { + return new UltraHighDefinitionVideoStreamRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related dataStream identity of an individual relationshipChannel's ultraHighDefinitionVideoStream relationship. + /// + public class UltraHighDefinitionVideoStreamRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class UltraHighDefinitionVideoStreamRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/Relationships/VideoStream/VideoStreamRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/Relationships/VideoStream/VideoStreamRequestBuilder.cs new file mode 100644 index 0000000000..e4f62c59bc --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/Item/Relationships/VideoStream/VideoStreamRequestBuilder.cs @@ -0,0 +1,174 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.RelationshipChannels.Item.Relationships.VideoStream { + /// + /// Builds and executes requests for operations under \relationshipChannels\{id}\relationships\videoStream + /// + public class VideoStreamRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new VideoStreamRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public VideoStreamRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/relationshipChannels/{id}/relationships/videoStream{?query*}", pathParameters) { + } + /// + /// Instantiates a new VideoStreamRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public VideoStreamRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/relationshipChannels/{id}/relationships/videoStream{?query*}", rawUrl) { + } + /// + /// Retrieves the related dataStream identity of an individual relationshipChannel's videoStream relationship. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, DataStreamIdentifierResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns an existing dataStream to the videoStream relationship of an individual relationshipChannel. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PatchAsync(ToOneDataStreamInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToOneDataStreamInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related dataStream identity of an individual relationshipChannel's videoStream relationship. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Assigns an existing dataStream to the videoStream relationship of an individual relationshipChannel. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPatchRequestInformation(ToOneDataStreamInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToOneDataStreamInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public VideoStreamRequestBuilder WithUrl(string rawUrl) { + return new VideoStreamRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related dataStream identity of an individual relationshipChannel's videoStream relationship. + /// + public class VideoStreamRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class VideoStreamRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/RelationshipChannelsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/RelationshipChannelsRequestBuilder.cs new file mode 100644 index 0000000000..8d16a4cd39 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RelationshipChannels/RelationshipChannelsRequestBuilder.cs @@ -0,0 +1,36 @@ +// +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.RelationshipChannels.Item; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.RelationshipChannels { + /// + /// Builds and executes requests for operations under \relationshipChannels + /// + public class RelationshipChannelsRequestBuilder : BaseRequestBuilder { + /// Gets an item from the OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.relationshipChannels.item collection + /// The identifier of the relationshipChannel whose related dataStream identities to retrieve. + public RelationshipChannelsItemRequestBuilder this[string position] { get { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new RelationshipChannelsItemRequestBuilder(urlTplParams, RequestAdapter); + } } + /// + /// Instantiates a new RelationshipChannelsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RelationshipChannelsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/relationshipChannels", pathParameters) { + } + /// + /// Instantiates a new RelationshipChannelsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipChannelsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/relationshipChannels", rawUrl) { + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RestrictedControllersClient.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RestrictedControllersClient.cs new file mode 100644 index 0000000000..96b636ee32 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/RestrictedControllersClient.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Store; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Serialization.Form; +using Microsoft.Kiota.Serialization.Json; +using Microsoft.Kiota.Serialization.Multipart; +using Microsoft.Kiota.Serialization.Text; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.DataStreams; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyChannels; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.ReadOnlyResourceChannels; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.RelationshipChannels; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.WriteOnlyChannels; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode { + /// + /// The main entry point of the SDK, exposes the configuration and the fluent API. + /// + public class RestrictedControllersClient : BaseRequestBuilder { + /// The dataStreams property + public DataStreamsRequestBuilder DataStreams { get => + new DataStreamsRequestBuilder(PathParameters, RequestAdapter); + } + /// The readOnlyChannels property + public ReadOnlyChannelsRequestBuilder ReadOnlyChannels { get => + new ReadOnlyChannelsRequestBuilder(PathParameters, RequestAdapter); + } + /// The readOnlyResourceChannels property + public ReadOnlyResourceChannelsRequestBuilder ReadOnlyResourceChannels { get => + new ReadOnlyResourceChannelsRequestBuilder(PathParameters, RequestAdapter); + } + /// The relationshipChannels property + public RelationshipChannelsRequestBuilder RelationshipChannels { get => + new RelationshipChannelsRequestBuilder(PathParameters, RequestAdapter); + } + /// The writeOnlyChannels property + public WriteOnlyChannelsRequestBuilder WriteOnlyChannels { get => + new WriteOnlyChannelsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new RestrictedControllersClient and sets the default values. + /// + /// The backing store to use for the models. + /// The request adapter to use to execute the requests. + public RestrictedControllersClient(IRequestAdapter requestAdapter, IBackingStoreFactory backingStore = default) : base(requestAdapter, "{+baseurl}", new Dictionary()) { + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + if (string.IsNullOrEmpty(RequestAdapter.BaseUrl)) { + RequestAdapter.BaseUrl = "http://localhost"; + } + PathParameters.TryAdd("baseurl", RequestAdapter.BaseUrl); + RequestAdapter.EnableBackingStore(backingStore); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/Relationships/AudioStreams/AudioStreamsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/Relationships/AudioStreams/AudioStreamsRequestBuilder.cs new file mode 100644 index 0000000000..caac687889 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/Relationships/AudioStreams/AudioStreamsRequestBuilder.cs @@ -0,0 +1,161 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.WriteOnlyChannels.Item.Relationships.AudioStreams { + /// + /// Builds and executes requests for operations under \writeOnlyChannels\{id}\relationships\audioStreams + /// + public class AudioStreamsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new AudioStreamsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public AudioStreamsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/writeOnlyChannels/{id}/relationships/audioStreams", pathParameters) { + } + /// + /// Instantiates a new AudioStreamsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public AudioStreamsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/writeOnlyChannels/{id}/relationships/audioStreams", rawUrl) { + } + /// + /// Removes existing dataStreams from the audioStreams relationship of an individual writeOnlyChannel. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task DeleteAsync(ToManyDataStreamInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(ToManyDataStreamInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToDeleteRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns existing dataStreams to the audioStreams relationship of an individual writeOnlyChannel. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PatchAsync(ToManyDataStreamInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToManyDataStreamInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Adds existing dataStreams to the audioStreams relationship of an individual writeOnlyChannel. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PostAsync(ToManyDataStreamInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(ToManyDataStreamInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Removes existing dataStreams from the audioStreams relationship of an individual writeOnlyChannel. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToDeleteRequestInformation(ToManyDataStreamInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(ToManyDataStreamInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Assigns existing dataStreams to the audioStreams relationship of an individual writeOnlyChannel. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPatchRequestInformation(ToManyDataStreamInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToManyDataStreamInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Adds existing dataStreams to the audioStreams relationship of an individual writeOnlyChannel. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPostRequestInformation(ToManyDataStreamInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(ToManyDataStreamInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public AudioStreamsRequestBuilder WithUrl(string rawUrl) { + return new AudioStreamsRequestBuilder(rawUrl, RequestAdapter); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/Relationships/RelationshipsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/Relationships/RelationshipsRequestBuilder.cs new file mode 100644 index 0000000000..327cf1413c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/Relationships/RelationshipsRequestBuilder.cs @@ -0,0 +1,43 @@ +// +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.WriteOnlyChannels.Item.Relationships.AudioStreams; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.WriteOnlyChannels.Item.Relationships.UltraHighDefinitionVideoStream; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.WriteOnlyChannels.Item.Relationships.VideoStream; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.WriteOnlyChannels.Item.Relationships { + /// + /// Builds and executes requests for operations under \writeOnlyChannels\{id}\relationships + /// + public class RelationshipsRequestBuilder : BaseRequestBuilder { + /// The audioStreams property + public AudioStreamsRequestBuilder AudioStreams { get => + new AudioStreamsRequestBuilder(PathParameters, RequestAdapter); + } + /// The ultraHighDefinitionVideoStream property + public UltraHighDefinitionVideoStreamRequestBuilder UltraHighDefinitionVideoStream { get => + new UltraHighDefinitionVideoStreamRequestBuilder(PathParameters, RequestAdapter); + } + /// The videoStream property + public VideoStreamRequestBuilder VideoStream { get => + new VideoStreamRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/writeOnlyChannels/{id}/relationships", pathParameters) { + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/writeOnlyChannels/{id}/relationships", rawUrl) { + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/Relationships/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/Relationships/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs new file mode 100644 index 0000000000..27515be249 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/Relationships/UltraHighDefinitionVideoStream/UltraHighDefinitionVideoStreamRequestBuilder.cs @@ -0,0 +1,79 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.WriteOnlyChannels.Item.Relationships.UltraHighDefinitionVideoStream { + /// + /// Builds and executes requests for operations under \writeOnlyChannels\{id}\relationships\ultraHighDefinitionVideoStream + /// + public class UltraHighDefinitionVideoStreamRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new UltraHighDefinitionVideoStreamRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public UltraHighDefinitionVideoStreamRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/writeOnlyChannels/{id}/relationships/ultraHighDefinitionVideoStream", pathParameters) { + } + /// + /// Instantiates a new UltraHighDefinitionVideoStreamRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public UltraHighDefinitionVideoStreamRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/writeOnlyChannels/{id}/relationships/ultraHighDefinitionVideoStream", rawUrl) { + } + /// + /// Clears or assigns an existing dataStream to the ultraHighDefinitionVideoStream relationship of an individual writeOnlyChannel. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PatchAsync(NullableToOneDataStreamInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(NullableToOneDataStreamInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Clears or assigns an existing dataStream to the ultraHighDefinitionVideoStream relationship of an individual writeOnlyChannel. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPatchRequestInformation(NullableToOneDataStreamInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(NullableToOneDataStreamInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public UltraHighDefinitionVideoStreamRequestBuilder WithUrl(string rawUrl) { + return new UltraHighDefinitionVideoStreamRequestBuilder(rawUrl, RequestAdapter); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/Relationships/VideoStream/VideoStreamRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/Relationships/VideoStream/VideoStreamRequestBuilder.cs new file mode 100644 index 0000000000..f459933056 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/Relationships/VideoStream/VideoStreamRequestBuilder.cs @@ -0,0 +1,79 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.WriteOnlyChannels.Item.Relationships.VideoStream { + /// + /// Builds and executes requests for operations under \writeOnlyChannels\{id}\relationships\videoStream + /// + public class VideoStreamRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new VideoStreamRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public VideoStreamRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/writeOnlyChannels/{id}/relationships/videoStream", pathParameters) { + } + /// + /// Instantiates a new VideoStreamRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public VideoStreamRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/writeOnlyChannels/{id}/relationships/videoStream", rawUrl) { + } + /// + /// Assigns an existing dataStream to the videoStream relationship of an individual writeOnlyChannel. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PatchAsync(ToOneDataStreamInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToOneDataStreamInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns an existing dataStream to the videoStream relationship of an individual writeOnlyChannel. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPatchRequestInformation(ToOneDataStreamInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToOneDataStreamInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public VideoStreamRequestBuilder WithUrl(string rawUrl) { + return new VideoStreamRequestBuilder(rawUrl, RequestAdapter); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/WriteOnlyChannelsItemRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/WriteOnlyChannelsItemRequestBuilder.cs new file mode 100644 index 0000000000..65fd7945e5 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/Item/WriteOnlyChannelsItemRequestBuilder.cs @@ -0,0 +1,134 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.WriteOnlyChannels.Item.Relationships; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.WriteOnlyChannels.Item { + /// + /// Builds and executes requests for operations under \writeOnlyChannels\{id} + /// + public class WriteOnlyChannelsItemRequestBuilder : BaseRequestBuilder { + /// The relationships property + public RelationshipsRequestBuilder Relationships { get => + new RelationshipsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new WriteOnlyChannelsItemRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public WriteOnlyChannelsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/writeOnlyChannels/{id}{?query*}", pathParameters) { + } + /// + /// Instantiates a new WriteOnlyChannelsItemRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public WriteOnlyChannelsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/writeOnlyChannels/{id}{?query*}", rawUrl) { + } + /// + /// Deletes an existing writeOnlyChannel by its identifier. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Updates an existing writeOnlyChannel. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PatchAsync(WriteOnlyChannelPatchRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(WriteOnlyChannelPatchRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, WriteOnlyChannelPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Deletes an existing writeOnlyChannel by its identifier. + /// + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToDeleteRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Updates an existing writeOnlyChannel. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPatchRequestInformation(WriteOnlyChannelPatchRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(WriteOnlyChannelPatchRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public WriteOnlyChannelsItemRequestBuilder WithUrl(string rawUrl) { + return new WriteOnlyChannelsItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Updates an existing writeOnlyChannel. + /// + public class WriteOnlyChannelsItemRequestBuilderPatchQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/WriteOnlyChannelsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/WriteOnlyChannelsRequestBuilder.cs new file mode 100644 index 0000000000..b2f0530d8a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/GeneratedCode/WriteOnlyChannels/WriteOnlyChannelsRequestBuilder.cs @@ -0,0 +1,104 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.WriteOnlyChannels.Item; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.WriteOnlyChannels { + /// + /// Builds and executes requests for operations under \writeOnlyChannels + /// + public class WriteOnlyChannelsRequestBuilder : BaseRequestBuilder { + /// Gets an item from the OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.writeOnlyChannels.item collection + /// The identifier of the writeOnlyChannel to update. + public WriteOnlyChannelsItemRequestBuilder this[string position] { get { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new WriteOnlyChannelsItemRequestBuilder(urlTplParams, RequestAdapter); + } } + /// + /// Instantiates a new WriteOnlyChannelsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public WriteOnlyChannelsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/writeOnlyChannels{?query*}", pathParameters) { + } + /// + /// Instantiates a new WriteOnlyChannelsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public WriteOnlyChannelsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/writeOnlyChannels{?query*}", rawUrl) { + } + /// + /// Creates a new writeOnlyChannel. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public async Task PostAsync(WriteOnlyChannelPostRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(WriteOnlyChannelPostRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, WriteOnlyChannelPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Creates a new writeOnlyChannel. + /// + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public RequestInformation ToPostRequestInformation(WriteOnlyChannelPostRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(WriteOnlyChannelPostRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public WriteOnlyChannelsRequestBuilder WithUrl(string rawUrl) { + return new WriteOnlyChannelsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Creates a new writeOnlyChannel. + /// + public class WriteOnlyChannelsRequestBuilderPostQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs new file mode 100644 index 0000000000..b2606ca26d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs @@ -0,0 +1,401 @@ +using System.Net; +using FluentAssertions; +using Microsoft.EntityFrameworkCore; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.RestrictedControllers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.RestrictedControllers; + +public sealed class UpdateRelationshipTests : IClassFixture, RestrictionDbContext>> +{ + private readonly IntegrationTestContext, RestrictionDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly RestrictionFakers _fakers = new(); + + public UpdateRelationshipTests(IntegrationTestContext, RestrictionDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_replace_ToOne_relationship() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.UltraHighDefinitionVideoStream = _fakers.DataStream.Generate(); + + DataStream existingVideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + dbContext.DataStreams.Add(existingVideoStream); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + var requestBody = new NullableToOneDataStreamInRequest + { + Data = new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = existingVideoStream.StringId! + } + }; + + // Act + await apiClient.WriteOnlyChannels[existingChannel.StringId].Relationships.UltraHighDefinitionVideoStream.PatchAsync(requestBody); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.UltraHighDefinitionVideoStream) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channelInDatabase.UltraHighDefinitionVideoStream.Id.Should().Be(existingVideoStream.Id); + }); + } + + [Fact] + public async Task Can_clear_ToOne_relationship() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.UltraHighDefinitionVideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + var requestBody = new NullableToOneDataStreamInRequest + { + Data = null + }; + + // Act + await apiClient.WriteOnlyChannels[existingChannel.StringId].Relationships.UltraHighDefinitionVideoStream.PatchAsync(requestBody); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.UltraHighDefinitionVideoStream) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.UltraHighDefinitionVideoStream.Should().BeNull(); + }); + } + + [Fact] + public async Task Can_replace_ToMany_relationship() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.AudioStreams = _fakers.DataStream.Generate(2).ToHashSet(); + + DataStream existingAudioStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + dbContext.DataStreams.Add(existingAudioStream); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + var requestBody = new ToManyDataStreamInRequest + { + Data = + [ + new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = existingAudioStream.StringId! + } + ] + }; + + // Act + await apiClient.WriteOnlyChannels[existingChannel.StringId].Relationships.AudioStreams.PatchAsync(requestBody); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.AudioStreams.Should().HaveCount(1); + channelInDatabase.AudioStreams.ElementAt(0).Id.Should().Be(existingAudioStream.Id); + }); + } + + [Fact] + public async Task Can_clear_ToMany_relationship() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.AudioStreams = _fakers.DataStream.Generate(2).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + var requestBody = new ToManyDataStreamInRequest + { + Data = [] + }; + + // Act + await apiClient.WriteOnlyChannels[existingChannel.StringId].Relationships.AudioStreams.PatchAsync(requestBody); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.AudioStreams.Should().BeEmpty(); + }); + } + + [Fact] + public async Task Can_add_to_ToMany_relationship() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.AudioStreams = _fakers.DataStream.Generate(1).ToHashSet(); + + DataStream existingAudioStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + dbContext.DataStreams.Add(existingAudioStream); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + var requestBody = new ToManyDataStreamInRequest + { + Data = + [ + new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = existingAudioStream.StringId! + } + ] + }; + + // Act + await apiClient.WriteOnlyChannels[existingChannel.StringId].Relationships.AudioStreams.PostAsync(requestBody); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.AudioStreams.Should().HaveCount(2); + channelInDatabase.AudioStreams.Should().ContainSingle(stream => stream.Id == existingChannel.AudioStreams.ElementAt(0).Id); + channelInDatabase.AudioStreams.Should().ContainSingle(stream => stream.Id == existingAudioStream.Id); + }); + } + + [Fact] + public async Task Can_remove_from_ToMany_relationship() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.AudioStreams = _fakers.DataStream.Generate(3).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + var requestBody = new ToManyDataStreamInRequest + { + Data = + [ + new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = existingChannel.AudioStreams.ElementAt(0).StringId! + }, + new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = existingChannel.AudioStreams.ElementAt(1).StringId! + } + ] + }; + + // Act + await apiClient.WriteOnlyChannels[existingChannel.StringId].Relationships.AudioStreams.DeleteAsync(requestBody); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.AudioStreams.Should().HaveCount(1); + channelInDatabase.AudioStreams.ElementAt(0).Id.Should().Be(existingChannel.AudioStreams.ElementAt(2).Id); + }); + } + + [Fact] + public async Task Cannot_update_relationship_for_missing_request_body() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + NullableToOneDataStreamInRequest requestBody = null!; + + // Act + Func action = async () => + await apiClient.WriteOnlyChannels[existingChannel.StringId].Relationships.UltraHighDefinitionVideoStream.PatchAsync(requestBody); + + // Assert + await action.Should().ThrowExactlyAsync().WithParameterName("body"); + } + + [Fact] + public async Task Cannot_update_relationship_with_unknown_relationship_IDs() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + string unknownAudioStreamId1 = Unknown.StringId.For(); + string unknownAudioStreamId2 = Unknown.StringId.AltFor(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + var requestBody = new ToManyDataStreamInRequest + { + Data = + [ + new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = unknownAudioStreamId1 + }, + new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = unknownAudioStreamId2 + } + ] + }; + + // Act + Func action = async () => await apiClient.WriteOnlyChannels[existingChannel.StringId].Relationships.AudioStreams.PatchAsync(requestBody); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.ShouldHaveCount(2); + + ErrorObject error1 = exception.Errors.ElementAt(0); + error1.Status.Should().Be("404"); + error1.Title.Should().Be("A related resource does not exist."); + error1.Detail.Should().Be($"Related resource of type 'dataStreams' with ID '{unknownAudioStreamId1}' in relationship 'audioStreams' does not exist."); + + ErrorObject error2 = exception.Errors.ElementAt(1); + error2.Status.Should().Be("404"); + error2.Title.Should().Be("A related resource does not exist."); + error2.Detail.Should().Be($"Related resource of type 'dataStreams' with ID '{unknownAudioStreamId2}' in relationship 'audioStreams' does not exist."); + } +} diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateResourceTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateResourceTests.cs new file mode 100644 index 0000000000..c8e2b890e8 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateResourceTests.cs @@ -0,0 +1,318 @@ +using System.Net; +using FluentAssertions; +using JsonApiDotNetCore.Resources; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode; +using OpenApiKiotaEndToEndTests.RestrictedControllers.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.RestrictedControllers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.RestrictedControllers; + +public sealed class UpdateResourceTests : IClassFixture, RestrictionDbContext>> +{ + private readonly IntegrationTestContext, RestrictionDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly RestrictionFakers _fakers = new(); + + public UpdateResourceTests(IntegrationTestContext, RestrictionDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + + testContext.ConfigureServices(services => services.AddScoped(typeof(IResourceChangeTracker<>), typeof(NeverSameResourceChangeTracker<>))); + } + + [Fact] + public async Task Can_update_resource_with_includes_and_fieldsets() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.UltraHighDefinitionVideoStream = _fakers.DataStream.Generate(); + existingChannel.AudioStreams = _fakers.DataStream.Generate(2).ToHashSet(); + + DataStream existingVideoStream = _fakers.DataStream.Generate(); + string? newChannelName = _fakers.WriteOnlyChannel.Generate().Name; + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + dbContext.DataStreams.Add(existingVideoStream); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + var requestBody = new WriteOnlyChannelPatchRequestDocument + { + Data = new WriteOnlyChannelDataInPatchRequest + { + Type = WriteOnlyChannelResourceType.WriteOnlyChannels, + Id = existingChannel.StringId!, + Attributes = new WriteOnlyChannelAttributesInPatchRequest + { + Name = newChannelName + }, + Relationships = new WriteOnlyChannelRelationshipsInPatchRequest + { + VideoStream = new ToOneDataStreamInRequest + { + Data = new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = existingVideoStream.StringId! + } + }, + UltraHighDefinitionVideoStream = new NullableToOneDataStreamInRequest + { + Data = null + }, + AudioStreams = new ToManyDataStreamInRequest + { + Data = [] + } + } + } + }; + + var queryString = new Dictionary + { + ["include"] = "videoStream,audioStreams", + ["fields[writeOnlyChannels]"] = "name,isCommercial,videoStream,audioStreams", + ["fields[dataStreams]"] = "bytesTransmitted" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + WriteOnlyChannelPrimaryResponseDocument? response = await apiClient.WriteOnlyChannels[existingChannel.StringId].PatchAsync(requestBody); + + response.ShouldNotBeNull(); + + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(existingChannel.StringId); + response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Name.Should().Be(newChannelName); + response.Data.Attributes.IsCommercial.Should().Be(existingChannel.IsCommercial); + response.Data.Attributes.IsAdultOnly.Should().BeNull(); + response.Data.Relationships.ShouldNotBeNull(); + response.Data.Relationships.VideoStream.ShouldNotBeNull(); + response.Data.Relationships.VideoStream.Data.ShouldNotBeNull(); + response.Data.Relationships.VideoStream.Data.Id.Should().Be(existingVideoStream.StringId); + response.Data.Relationships.UltraHighDefinitionVideoStream.Should().BeNull(); + response.Data.Relationships.AudioStreams.ShouldNotBeNull(); + response.Data.Relationships.AudioStreams.Data.Should().BeEmpty(); + + response.Included.ShouldHaveCount(1); + + DataStreamDataInResponse? videoStream = response.Included.ElementAt(0).Should().BeOfType().Which; + videoStream.Id.Should().Be(existingVideoStream.StringId); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.VideoStream) + .Include(channel => channel.UltraHighDefinitionVideoStream) + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.Name.Should().Be(newChannelName); + channelInDatabase.IsCommercial.Should().Be(existingChannel.IsCommercial); + channelInDatabase.IsAdultOnly.Should().Be(existingChannel.IsAdultOnly); + + channelInDatabase.VideoStream.ShouldNotBeNull(); + channelInDatabase.VideoStream.Id.Should().Be(existingVideoStream.Id); + + channelInDatabase.UltraHighDefinitionVideoStream.Should().BeNull(); + + channelInDatabase.AudioStreams.Should().BeEmpty(); + }); + } + } + + [Fact] + public async Task Can_update_resource_without_attributes_or_relationships() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.UltraHighDefinitionVideoStream = _fakers.DataStream.Generate(); + existingChannel.AudioStreams = _fakers.DataStream.Generate(2).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + var requestBody = new WriteOnlyChannelPatchRequestDocument + { + Data = new WriteOnlyChannelDataInPatchRequest + { + Type = WriteOnlyChannelResourceType.WriteOnlyChannels, + Id = existingChannel.StringId!, + Attributes = new WriteOnlyChannelAttributesInPatchRequest(), + Relationships = new WriteOnlyChannelRelationshipsInPatchRequest() + } + }; + + // Act + WriteOnlyChannelPrimaryResponseDocument? response = await apiClient.WriteOnlyChannels[existingChannel.StringId].PatchAsync(requestBody); + + response.ShouldNotBeNull(); + + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(existingChannel.StringId); + response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Name.Should().Be(existingChannel.Name); + response.Data.Attributes.IsCommercial.Should().Be(existingChannel.IsCommercial); + response.Data.Attributes.IsAdultOnly.Should().Be(existingChannel.IsAdultOnly); + response.Data.Relationships.ShouldNotBeNull(); + response.Data.Relationships.VideoStream.ShouldNotBeNull(); + response.Data.Relationships.VideoStream.Data.Should().BeNull(); + response.Data.Relationships.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + response.Data.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); + response.Data.Relationships.AudioStreams.ShouldNotBeNull(); + response.Data.Relationships.AudioStreams.Data.Should().BeNull(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.VideoStream) + .Include(channel => channel.UltraHighDefinitionVideoStream) + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.Name.Should().Be(existingChannel.Name); + channelInDatabase.IsCommercial.Should().Be(existingChannel.IsCommercial); + channelInDatabase.IsAdultOnly.Should().Be(existingChannel.IsAdultOnly); + + channelInDatabase.VideoStream.ShouldNotBeNull(); + channelInDatabase.VideoStream.Id.Should().Be(existingChannel.VideoStream.Id); + + channelInDatabase.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channelInDatabase.UltraHighDefinitionVideoStream.Id.Should().Be(existingChannel.UltraHighDefinitionVideoStream.Id); + + channelInDatabase.AudioStreams.Should().HaveCount(2); + }); + } + + [Fact] + public async Task Cannot_update_resource_for_missing_request_body() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + WriteOnlyChannelPatchRequestDocument requestBody = null!; + + // Act + Func action = async () => _ = await apiClient.WriteOnlyChannels[existingChannel.StringId].PatchAsync(requestBody); + + // Assert + await action.Should().ThrowExactlyAsync().WithParameterName("body"); + } + + [Fact] + public async Task Cannot_update_resource_with_unknown_relationship_IDs() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + string unknownDataStreamId = Unknown.StringId.For(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new RestrictedControllersClient(requestAdapter); + + var requestBody = new WriteOnlyChannelPatchRequestDocument + { + Data = new WriteOnlyChannelDataInPatchRequest + { + Type = WriteOnlyChannelResourceType.WriteOnlyChannels, + Id = existingChannel.StringId!, + Relationships = new WriteOnlyChannelRelationshipsInPatchRequest + { + VideoStream = new ToOneDataStreamInRequest + { + Data = new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = unknownDataStreamId + } + }, + AudioStreams = new ToManyDataStreamInRequest + { + Data = + [ + new DataStreamIdentifier + { + Type = DataStreamResourceType.DataStreams, + Id = unknownDataStreamId + } + ] + } + } + } + }; + + // Act + Func action = async () => _ = await apiClient.WriteOnlyChannels[existingChannel.StringId].PatchAsync(requestBody); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.ShouldHaveCount(2); + + ErrorObject error1 = exception.Errors.ElementAt(0); + error1.Status.Should().Be("404"); + error1.Title.Should().Be("A related resource does not exist."); + error1.Detail.Should().Be($"Related resource of type 'dataStreams' with ID '{unknownDataStreamId}' in relationship 'audioStreams' does not exist."); + + ErrorObject error2 = exception.Errors.ElementAt(1); + error2.Status.Should().Be("404"); + error2.Title.Should().Be("A related resource does not exist."); + error2.Detail.Should().Be($"Related resource of type 'dataStreams' with ID '{unknownDataStreamId}' in relationship 'videoStream' does not exist."); + } +} diff --git a/test/OpenApiNSwagClientTests/LegacyClient/GeneratedCode/IOpenApiClient.cs b/test/OpenApiNSwagClientTests/LegacyClient/GeneratedCode/IOpenApiClient.cs deleted file mode 100644 index 0f6f05177b..0000000000 --- a/test/OpenApiNSwagClientTests/LegacyClient/GeneratedCode/IOpenApiClient.cs +++ /dev/null @@ -1,6 +0,0 @@ -using JsonApiDotNetCore.OpenApi.Client.NSwag; - -namespace OpenApiNSwagClientTests.LegacyClient.GeneratedCode; - -// ReSharper disable once MemberCanBeInternal -public partial interface IOpenApiClient : IJsonApiClient; diff --git a/test/OpenApiNSwagClientTests/LegacyOpenApi/GeneratedCode/ILegacyClient.cs b/test/OpenApiNSwagClientTests/LegacyOpenApi/GeneratedCode/ILegacyClient.cs new file mode 100644 index 0000000000..b1e437ddc7 --- /dev/null +++ b/test/OpenApiNSwagClientTests/LegacyOpenApi/GeneratedCode/ILegacyClient.cs @@ -0,0 +1,6 @@ +using JsonApiDotNetCore.OpenApi.Client.NSwag; + +namespace OpenApiNSwagClientTests.LegacyOpenApi.GeneratedCode; + +// ReSharper disable once MemberCanBeInternal +public partial interface ILegacyClient : IJsonApiClient; diff --git a/test/OpenApiNSwagClientTests/LegacyClient/GeneratedCode/OpenApiClient.cs b/test/OpenApiNSwagClientTests/LegacyOpenApi/GeneratedCode/LegacyClient.cs similarity index 70% rename from test/OpenApiNSwagClientTests/LegacyClient/GeneratedCode/OpenApiClient.cs rename to test/OpenApiNSwagClientTests/LegacyOpenApi/GeneratedCode/LegacyClient.cs index 3f1b385d9e..660417de48 100644 --- a/test/OpenApiNSwagClientTests/LegacyClient/GeneratedCode/OpenApiClient.cs +++ b/test/OpenApiNSwagClientTests/LegacyOpenApi/GeneratedCode/LegacyClient.cs @@ -1,9 +1,9 @@ using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -namespace OpenApiNSwagClientTests.LegacyClient.GeneratedCode; +namespace OpenApiNSwagClientTests.LegacyOpenApi.GeneratedCode; -internal partial class OpenApiClient : JsonApiClient +internal partial class LegacyClient : JsonApiClient { partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings) { diff --git a/test/OpenApiNSwagClientTests/LegacyClient/PartialAttributeSerializationLifetimeTests.cs b/test/OpenApiNSwagClientTests/LegacyOpenApi/PartialAttributeSerializationLifetimeTests.cs similarity index 85% rename from test/OpenApiNSwagClientTests/LegacyClient/PartialAttributeSerializationLifetimeTests.cs rename to test/OpenApiNSwagClientTests/LegacyOpenApi/PartialAttributeSerializationLifetimeTests.cs index 9019111e9a..f4c60ee516 100644 --- a/test/OpenApiNSwagClientTests/LegacyClient/PartialAttributeSerializationLifetimeTests.cs +++ b/test/OpenApiNSwagClientTests/LegacyOpenApi/PartialAttributeSerializationLifetimeTests.cs @@ -1,11 +1,11 @@ using System.Net; using FluentAssertions; using JsonApiDotNetCore.OpenApi.Client.NSwag; -using OpenApiNSwagClientTests.LegacyClient.GeneratedCode; +using OpenApiNSwagClientTests.LegacyOpenApi.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiNSwagClientTests.LegacyClient; +namespace OpenApiNSwagClientTests.LegacyOpenApi; public sealed class PartialAttributeSerializationLifetimeTests { @@ -14,7 +14,7 @@ public async Task Disposed_registration_does_not_affect_request() { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); const string airplaneId = "XUuiP"; @@ -31,13 +31,13 @@ public async Task Disposed_registration_does_not_affect_request() using (apiClient.WithPartialAttributeSerialization(requestDocument, airplane => airplane.AirtimeInHours)) { - _ = await ApiResponse.TranslateAsync(() => apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); } wrapper.ChangeResponse(HttpStatusCode.NoContent, null); // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); // Assert wrapper.RequestBody.Should().BeJson($$""" @@ -58,7 +58,7 @@ public async Task Registration_can_be_used_for_multiple_requests() { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); const string airplaneId = "XUuiP"; @@ -78,14 +78,14 @@ public async Task Registration_can_be_used_for_multiple_requests() using (apiClient.WithPartialAttributeSerialization(requestDocument, airplane => airplane.AirtimeInHours)) { - _ = await ApiResponse.TranslateAsync(() => apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); wrapper.ChangeResponse(HttpStatusCode.NoContent, null); requestDocument.Data.Attributes.AirtimeInHours = null; // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); } // Assert @@ -107,7 +107,7 @@ public async Task Request_is_unaffected_by_registration_for_different_document_o { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); const string airplaneId1 = "XUuiP"; @@ -142,7 +142,7 @@ public async Task Request_is_unaffected_by_registration_for_different_document_o } // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.PatchAirplaneAsync(airplaneId2, null, requestDocument2)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId2, null, requestDocument2)); } // Assert @@ -164,7 +164,7 @@ public async Task Attribute_values_can_be_changed_after_registration() { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); const string airplaneId = "XUuiP"; @@ -187,7 +187,7 @@ public async Task Attribute_values_can_be_changed_after_registration() requestDocument.Data.Attributes.IsInMaintenance = false; // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); } // Assert @@ -209,7 +209,7 @@ public async Task Registration_is_unaffected_by_successive_registration_for_docu { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); const string airplaneId1 = "XUuiP"; @@ -239,7 +239,7 @@ public async Task Registration_is_unaffected_by_successive_registration_for_docu airplane => airplane.AirtimeInHours)) { // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.PatchAirplaneAsync(airplaneId1, null, requestDocument1)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId1, null, requestDocument1)); } } @@ -262,7 +262,7 @@ public async Task Registration_is_unaffected_by_preceding_disposed_registration_ { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); const string airplaneId1 = "XUuiP"; @@ -279,7 +279,7 @@ public async Task Registration_is_unaffected_by_preceding_disposed_registration_ using (apiClient.WithPartialAttributeSerialization(requestDocument1, airplane => airplane.AirtimeInHours)) { - _ = await ApiResponse.TranslateAsync(() => apiClient.PatchAirplaneAsync(airplaneId1, null, requestDocument1)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId1, null, requestDocument1)); } const string airplaneId2 = "DJy1u"; @@ -303,7 +303,7 @@ public async Task Registration_is_unaffected_by_preceding_disposed_registration_ airplane => airplane.SerialNumber)) { // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.PatchAirplaneAsync(airplaneId2, null, requestDocument2)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId2, null, requestDocument2)); } // Assert @@ -326,7 +326,7 @@ public async Task Registration_is_unaffected_by_preceding_disposed_registration_ { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); var requestDocument1 = new AirplanePostRequestDocument { @@ -343,7 +343,7 @@ public async Task Registration_is_unaffected_by_preceding_disposed_registration_ using (apiClient.WithPartialAttributeSerialization(requestDocument1, airplane => airplane.AirtimeInHours)) { - _ = await ApiResponse.TranslateAsync(() => apiClient.PostAirplaneAsync(null, requestDocument1)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PostAirplaneAsync(null, requestDocument1)); } const string airplaneId = "DJy1u"; @@ -367,7 +367,7 @@ public async Task Registration_is_unaffected_by_preceding_disposed_registration_ airplane => airplane.SerialNumber)) { // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument2)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument2)); } // Assert @@ -390,7 +390,7 @@ public async Task Registration_is_unaffected_by_preceding_registration_for_diffe { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); const string airplaneId1 = "XUuiP"; @@ -423,7 +423,7 @@ public async Task Registration_is_unaffected_by_preceding_registration_for_diffe airplane => airplane.IsInMaintenance, airplane => airplane.AirtimeInHours)) { // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.PatchAirplaneAsync(airplaneId2, null, requestDocument2)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId2, null, requestDocument2)); } } diff --git a/test/OpenApiNSwagClientTests/LegacyClient/RequestTests.cs b/test/OpenApiNSwagClientTests/LegacyOpenApi/RequestTests.cs similarity index 88% rename from test/OpenApiNSwagClientTests/LegacyClient/RequestTests.cs rename to test/OpenApiNSwagClientTests/LegacyOpenApi/RequestTests.cs index 587a9f88ff..0984d20372 100644 --- a/test/OpenApiNSwagClientTests/LegacyClient/RequestTests.cs +++ b/test/OpenApiNSwagClientTests/LegacyOpenApi/RequestTests.cs @@ -5,11 +5,11 @@ using JsonApiDotNetCore.Middleware; using JsonApiDotNetCore.OpenApi.Client.NSwag; using Microsoft.Net.Http.Headers; -using OpenApiNSwagClientTests.LegacyClient.GeneratedCode; +using OpenApiNSwagClientTests.LegacyOpenApi.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiNSwagClientTests.LegacyClient; +namespace OpenApiNSwagClientTests.LegacyOpenApi; public sealed class RequestTests { @@ -20,10 +20,10 @@ public async Task Getting_resource_collection_produces_expected_request() { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.GetFlightCollectionAsync(null, null)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.GetFlightCollectionAsync(null, null)); // Assert wrapper.Request.ShouldNotBeNull(); @@ -40,10 +40,10 @@ public async Task Getting_resource_produces_expected_request() const string flightId = "ZvuH1"; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.GetFlightAsync(flightId, null, null)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.GetFlightAsync(flightId, null, null)); // Assert wrapper.Request.ShouldNotBeNull(); @@ -58,7 +58,7 @@ public async Task Partial_posting_resource_with_selected_relationships_produces_ { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); var requestDocument = new FlightPostRequestDocument { @@ -88,7 +88,7 @@ public async Task Partial_posting_resource_with_selected_relationships_produces_ }; // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.PostFlightAsync(null, requestDocument)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PostFlightAsync(null, requestDocument)); // Assert wrapper.Request.ShouldNotBeNull(); @@ -127,7 +127,7 @@ public async Task Partial_posting_resource_produces_expected_request() { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); const char euroSign = '\x20AC'; const char checkMark = '\x2713'; @@ -159,7 +159,7 @@ public async Task Partial_posting_resource_produces_expected_request() airplane => airplane.SerialNumber)) { // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.PostAirplaneAsync(null, requestDocument)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PostAirplaneAsync(null, requestDocument)); } // Assert @@ -193,7 +193,7 @@ public async Task Partial_patching_resource_produces_expected_request() var lastServicedAt = 1.January(2021).At(15, 23, 5, 33).ToDateTimeOffset(4.Hours()); using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); var requestDocument = new AirplanePatchRequestDocument { @@ -212,7 +212,7 @@ public async Task Partial_patching_resource_produces_expected_request() airplane => airplane.SerialNumber, airplane => airplane.LastServicedAt, airplane => airplane.IsInMaintenance, airplane => airplane.AirtimeInHours)) { // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); } // Assert @@ -247,7 +247,7 @@ public async Task Deleting_resource_produces_expected_request() const string flightId = "ZvuH1"; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act await apiClient.DeleteFlightAsync(flightId); @@ -266,10 +266,10 @@ public async Task Getting_secondary_resource_produces_expected_request() const string flightId = "ZvuH1"; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.GetFlightPurserAsync(flightId, null, null)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.GetFlightPurserAsync(flightId, null, null)); // Assert wrapper.Request.ShouldNotBeNull(); @@ -286,10 +286,10 @@ public async Task Getting_secondary_resources_produces_expected_request() const string flightId = "ZvuH1"; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.GetFlightCabinCrewMembersAsync(flightId, null, null)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.GetFlightCabinCrewMembersAsync(flightId, null, null)); // Assert wrapper.Request.ShouldNotBeNull(); @@ -306,10 +306,10 @@ public async Task Getting_ToOne_relationship_produces_expected_request() const string flightId = "ZvuH1"; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.GetFlightPurserRelationshipAsync(flightId, null, null)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.GetFlightPurserRelationshipAsync(flightId, null, null)); // Assert wrapper.Request.ShouldNotBeNull(); @@ -326,7 +326,7 @@ public async Task Patching_ToOne_relationship_produces_expected_request() const string flightId = "ZvuH1"; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); var requestDocument = new ToOneFlightAttendantInRequest { @@ -365,10 +365,10 @@ public async Task Getting_ToMany_relationship_produces_expected_request() const string flightId = "ZvuH1"; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act - _ = await ApiResponse.TranslateAsync(() => apiClient.GetFlightCabinCrewMembersRelationshipAsync(flightId, null, null)); + _ = await ApiResponse.TranslateAsync(async () => await apiClient.GetFlightCabinCrewMembersRelationshipAsync(flightId, null, null)); // Assert wrapper.Request.ShouldNotBeNull(); @@ -385,7 +385,7 @@ public async Task Posting_ToMany_relationship_produces_expected_request() const string flightId = "ZvuH1"; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); var requestDocument = new ToManyFlightAttendantInRequest { @@ -438,7 +438,7 @@ public async Task Patching_ToMany_relationship_produces_expected_request() const string flightId = "ZvuH1"; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); var requestDocument = new ToManyFlightAttendantInRequest { @@ -491,7 +491,7 @@ public async Task Deleting_ToMany_relationship_produces_expected_request() const string flightId = "ZvuH1"; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); var requestDocument = new ToManyFlightAttendantInRequest { diff --git a/test/OpenApiNSwagClientTests/LegacyClient/ResponseTests.cs b/test/OpenApiNSwagClientTests/LegacyOpenApi/ResponseTests.cs similarity index 92% rename from test/OpenApiNSwagClientTests/LegacyClient/ResponseTests.cs rename to test/OpenApiNSwagClientTests/LegacyOpenApi/ResponseTests.cs index 414ed985de..093779198b 100644 --- a/test/OpenApiNSwagClientTests/LegacyClient/ResponseTests.cs +++ b/test/OpenApiNSwagClientTests/LegacyOpenApi/ResponseTests.cs @@ -2,11 +2,11 @@ using System.Net; using FluentAssertions; using JsonApiDotNetCore.OpenApi.Client.NSwag; -using OpenApiNSwagClientTests.LegacyClient.GeneratedCode; +using OpenApiNSwagClientTests.LegacyOpenApi.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiNSwagClientTests.LegacyClient; +namespace OpenApiNSwagClientTests.LegacyOpenApi; public sealed class ResponseTests { @@ -95,7 +95,7 @@ public async Task Getting_resource_collection_translates_response() """; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.OK, responseBody); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act FlightCollectionResponseDocument document = await apiClient.GetFlightCollectionAsync(null, null); @@ -176,7 +176,7 @@ public async Task Getting_resource_translates_response() """; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.OK, responseBody); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act FlightPrimaryResponseDocument document = await apiClient.GetFlightAsync(flightId, null, null); @@ -218,10 +218,10 @@ public async Task Getting_unknown_resource_translates_error_response() """; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NotFound, responseBody); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act - Func> action = () => apiClient.GetFlightAsync(flightId, null, null); + Func action = async () => await apiClient.GetFlightAsync(flightId, null, null); // Assert ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; @@ -293,7 +293,7 @@ public async Task Posting_resource_translates_response() """; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.Created, responseBody); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act FlightPrimaryResponseDocument document = await apiClient.PostFlightAsync(null, new FlightPostRequestDocument @@ -347,7 +347,7 @@ public async Task Patching_resource_with_side_effects_translates_response() """; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.OK, responseBody); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act FlightPrimaryResponseDocument document = await apiClient.PatchFlightAsync(flightId, null, new FlightPatchRequestDocument @@ -370,10 +370,10 @@ public async Task Patching_resource_without_side_effects_translates_response() // Arrange const string flightId = "ZvuH1"; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act - FlightPrimaryResponseDocument? document = await ApiResponse.TranslateAsync(() => apiClient.PatchFlightAsync(flightId, null, + FlightPrimaryResponseDocument? document = await ApiResponse.TranslateAsync(async () => await apiClient.PatchFlightAsync(flightId, null, new FlightPatchRequestDocument { Data = new FlightDataInPatchRequest @@ -392,10 +392,10 @@ public async Task Deleting_resource_produces_empty_response() { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act - Func action = () => apiClient.DeleteFlightAsync("ZvuH1"); + Func action = async () => await apiClient.DeleteFlightAsync("ZvuH1"); // Assert await action.Should().NotThrowAsync(); @@ -450,7 +450,7 @@ public async Task Getting_secondary_resource_translates_response() """; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.OK, responseBody); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act FlightAttendantSecondaryResponseDocument document = await apiClient.GetFlightPurserAsync(flightId, null, null); @@ -482,7 +482,7 @@ public async Task Getting_nullable_secondary_resource_translates_response() """; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.OK, responseBody); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act NullableFlightAttendantSecondaryResponseDocument document = await apiClient.GetFlightBackupPurserAsync(flightId, null, null); @@ -508,7 +508,7 @@ public async Task Getting_secondary_resources_translates_response() """; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.OK, responseBody); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act FlightAttendantCollectionResponseDocument document = await apiClient.GetFlightCabinCrewMembersAsync(flightId, null, null); @@ -534,7 +534,7 @@ public async Task Getting_nullable_ToOne_relationship_translates_response() """; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.OK, responseBody); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act NullableFlightAttendantIdentifierResponseDocument document = await apiClient.GetFlightBackupPurserRelationshipAsync(flightId, null, null); @@ -564,7 +564,7 @@ public async Task Getting_ToOne_relationship_translates_response() """; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.OK, responseBody); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act FlightAttendantIdentifierResponseDocument document = await apiClient.GetFlightPurserRelationshipAsync(flightId, null, null); @@ -580,7 +580,7 @@ public async Task Patching_ToOne_relationship_translates_response() { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act await apiClient.PatchFlightPurserRelationshipAsync("ZvuH1", new ToOneFlightAttendantInRequest @@ -620,7 +620,7 @@ public async Task Getting_ToMany_relationship_translates_response() """; using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.OK, responseBody); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act FlightAttendantIdentifierCollectionResponseDocument document = await apiClient.GetFlightCabinCrewMembersRelationshipAsync(flightId, null, null); @@ -638,10 +638,10 @@ public async Task Posting_ToMany_relationship_produces_empty_response() { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act - Func action = () => apiClient.PostFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantInRequest + Func action = async () => await apiClient.PostFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantInRequest { Data = new List { @@ -667,10 +667,10 @@ public async Task Patching_ToMany_relationship_produces_empty_response() { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act - Func action = () => apiClient.PatchFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantInRequest + Func action = async () => await apiClient.PatchFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantInRequest { Data = new List { @@ -696,10 +696,10 @@ public async Task Deleting_ToMany_relationship_produces_empty_response() { // Arrange using var wrapper = FakeHttpClientWrapper.Create(HttpStatusCode.NoContent, null); - IOpenApiClient apiClient = new OpenApiClient(wrapper.HttpClient); + ILegacyClient apiClient = new LegacyClient(wrapper.HttpClient); // Act - Func action = () => apiClient.DeleteFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantInRequest + Func action = async () => await apiClient.DeleteFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantInRequest { Data = new List { diff --git a/test/OpenApiNSwagClientTests/OpenApiNSwagClientTests.csproj b/test/OpenApiNSwagClientTests/OpenApiNSwagClientTests.csproj index 7a80e2b6e0..4dc9030f70 100644 --- a/test/OpenApiNSwagClientTests/OpenApiNSwagClientTests.csproj +++ b/test/OpenApiNSwagClientTests/OpenApiNSwagClientTests.csproj @@ -23,10 +23,10 @@ - - OpenApiNSwagClientTests.LegacyClient.GeneratedCode - OpenApiClient - OpenApiClient.cs + + OpenApiNSwagClientTests.LegacyOpenApi.GeneratedCode + LegacyClient + LegacyClient.cs NSwagCSharp /GenerateClientInterfaces:true /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/CreateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/CreateResourceTests.cs index 4654462c60..62ca68d887 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/CreateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/CreateResourceTests.cs @@ -51,7 +51,7 @@ public async Task Can_set_attribute_to_default_value(string attributePropertyNam using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument, includeAttributeSelector); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -92,7 +92,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -133,7 +133,7 @@ public async Task Cannot_omit_attribute(string attributePropertyName, string jso using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - Func> action = () => apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -169,7 +169,7 @@ public async Task Can_clear_relationship(string relationshipPropertyName, string var apiClient = new NrtOffMsvOffClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -207,7 +207,7 @@ public async Task Cannot_clear_relationship(string relationshipPropertyName, str var apiClient = new NrtOffMsvOffClient(wrapper.HttpClient); // Act - Func> action = () => apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -243,7 +243,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string var apiClient = new NrtOffMsvOffClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs index d29235e95a..92e5cd452e 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs @@ -79,7 +79,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -120,7 +120,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string var apiClient = new NrtOffMsvOffClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/CreateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/CreateResourceTests.cs index ac17bc38c1..ec9e0b969c 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/CreateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/CreateResourceTests.cs @@ -50,7 +50,7 @@ public async Task Can_set_attribute_to_default_value(string attributePropertyNam using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument, includeAttributeSelector); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -92,7 +92,7 @@ public async Task Cannot_set_attribute_to_default_value(string attributeProperty using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument, includeAttributeSelector); // Act - Func> action = () => apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -131,7 +131,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -171,7 +171,7 @@ public async Task Cannot_omit_attribute(string attributePropertyName, string jso using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - Func> action = () => apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -206,7 +206,7 @@ public async Task Can_clear_relationship(string relationshipPropertyName, string var apiClient = new NrtOffMsvOnClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -245,7 +245,7 @@ public async Task Cannot_clear_relationship(string relationshipPropertyName, str var apiClient = new NrtOffMsvOnClient(wrapper.HttpClient); // Act - Func> action = () => apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -282,7 +282,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string var apiClient = new NrtOffMsvOnClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -319,7 +319,7 @@ public async Task Cannot_omit_relationship(string relationshipPropertyName, stri var apiClient = new NrtOffMsvOnClient(wrapper.HttpClient); // Act - Func> action = () => apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs index 38b485d1dc..7bc48da908 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs @@ -79,7 +79,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -120,7 +120,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string var apiClient = new NrtOffMsvOnClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/CreateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/CreateResourceTests.cs index 5f5d92e1a6..87b1e1bd21 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/CreateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/CreateResourceTests.cs @@ -53,7 +53,7 @@ public async Task Can_set_attribute_to_default_value(string attributePropertyNam using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument, includeAttributeSelector); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -98,7 +98,7 @@ public async Task Cannot_set_attribute_to_default_value(string attributeProperty using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument, includeAttributeSelector); // Act - Func> action = async () => await apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -140,7 +140,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -184,7 +184,7 @@ public async Task Cannot_omit_attribute(string attributePropertyName, string jso using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - Func> action = async () => await apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -222,7 +222,7 @@ public async Task Can_clear_relationship(string relationshipPropertyName, string var apiClient = new NrtOnMsvOffClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -264,7 +264,7 @@ public async Task Cannot_clear_relationship(string relationshipPropertyName, str var apiClient = new NrtOnMsvOffClient(wrapper.HttpClient); // Act - Func> action = async () => await apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -303,7 +303,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string var apiClient = new NrtOnMsvOffClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -342,7 +342,7 @@ public async Task Cannot_omit_relationship(string relationshipPropertyName, stri var apiClient = new NrtOnMsvOffClient(wrapper.HttpClient); // Act - Func> action = async () => await apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs index c4b5789c0b..39b5edfc2f 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs @@ -85,7 +85,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -130,7 +130,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string var apiClient = new NrtOnMsvOffClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/CreateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/CreateResourceTests.cs index 979338c5ed..29e04ee849 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/CreateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/CreateResourceTests.cs @@ -52,7 +52,7 @@ public async Task Can_set_attribute_to_default_value(string attributePropertyNam using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument, includeAttributeSelector); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -98,7 +98,7 @@ public async Task Cannot_set_attribute_to_default_value(string attributeProperty using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument, includeAttributeSelector); // Act - Func> action = async () => await apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -139,7 +139,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -183,7 +183,7 @@ public async Task Cannot_omit_attribute(string attributePropertyName, string jso using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - Func> action = async () => await apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -220,7 +220,7 @@ public async Task Can_clear_relationship(string relationshipPropertyName, string var apiClient = new NrtOnMsvOnClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -263,7 +263,7 @@ public async Task Cannot_clear_relationship(string relationshipPropertyName, str var apiClient = new NrtOnMsvOnClient(wrapper.HttpClient); // Act - Func> action = async () => await apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -302,7 +302,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string var apiClient = new NrtOnMsvOnClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PostResourceAsync(null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PostResourceAsync(null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -343,7 +343,7 @@ public async Task Cannot_omit_relationship(string relationshipPropertyName, stri var apiClient = new NrtOnMsvOnClient(wrapper.HttpClient); // Act - Func> action = async () => await apiClient.PostResourceAsync(null, requestDocument); + Func action = async () => await apiClient.PostResourceAsync(null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs index 651368853c..ea057f1b79 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs @@ -85,7 +85,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -130,7 +130,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string var apiClient = new NrtOnMsvOnClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); + await ApiResponse.TranslateAsync(async () => await apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); diff --git a/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs b/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs index 83a20f1d0f..30caacafd6 100644 --- a/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs +++ b/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs @@ -1,3 +1,4 @@ +using System.Net; using FluentAssertions; using FluentAssertions.Specialized; using JsonApiDotNetCore.OpenApi.Client.NSwag; @@ -7,18 +8,22 @@ using OpenApiTests.ClientIdGenerationModes; using TestBuildingBlocks; using Xunit; +using Xunit.Abstractions; namespace OpenApiNSwagEndToEndTests.ClientIdGenerationModes; public sealed class ClientIdGenerationModesTests - : IClassFixture, ClientIdGenerationModesDbContext>> + : IClassFixture, ClientIdGenerationDbContext>> { - private readonly IntegrationTestContext, ClientIdGenerationModesDbContext> _testContext; - private readonly ClientIdGenerationModesFakers _fakers = new(); + private readonly IntegrationTestContext, ClientIdGenerationDbContext> _testContext; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; + private readonly ClientIdGenerationFakers _fakers = new(); - public ClientIdGenerationModesTests(IntegrationTestContext, ClientIdGenerationModesDbContext> testContext) + public ClientIdGenerationModesTests(IntegrationTestContext, ClientIdGenerationDbContext> testContext, + ITestOutputHelper testOutputHelper) { _testContext = testContext; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); testContext.UseController(); testContext.UseController(); @@ -29,23 +34,24 @@ public ClientIdGenerationModesTests(IntegrationTestContext> action = () => ApiResponse.TranslateAsync(() => apiClient.PostPlayerAsync(null, new PlayerPostRequestDocument + var requestBody = new PlayerPostRequestDocument { Data = new PlayerDataInPostRequest { - Id = null!, Attributes = new PlayerAttributesInPostRequest { - UserName = player.UserName + UserName = newPlayer.UserName } } - })); + }; + + // Act + Func action = async () => await ApiResponse.TranslateAsync(async () => await apiClient.PostPlayerAsync(null, requestBody)); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -56,33 +62,35 @@ public async Task Cannot_create_resource_without_ID_when_supplying_ID_is_require public async Task Can_create_resource_with_ID_when_supplying_ID_is_required() { // Arrange - Player player = _fakers.Player.Generate(); - player.Id = Guid.NewGuid(); + Player newPlayer = _fakers.Player.Generate(); + newPlayer.Id = Guid.NewGuid(); - using HttpClient httpClient = _testContext.Factory.CreateClient(); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); ClientIdGenerationModesClient apiClient = new(httpClient); - // Act - PlayerPrimaryResponseDocument? document = await ApiResponse.TranslateAsync(() => apiClient.PostPlayerAsync(null, new PlayerPostRequestDocument + var requestBody = new PlayerPostRequestDocument { Data = new PlayerDataInPostRequest { - Id = player.StringId!, + Id = newPlayer.StringId!, Attributes = new PlayerAttributesInPostRequest { - UserName = player.UserName + UserName = newPlayer.UserName } } - })); + }; + + // Act + PlayerPrimaryResponseDocument? document = await ApiResponse.TranslateAsync(async () => await apiClient.PostPlayerAsync(null, requestBody)); // Assert document.Should().BeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { - Player playerInDatabase = await dbContext.Players.FirstWithIdAsync(player.Id); + Player playerInDatabase = await dbContext.Players.FirstWithIdAsync(newPlayer.Id); - playerInDatabase.UserName.Should().Be(player.UserName); + playerInDatabase.UserName.Should().Be(newPlayer.UserName); }); } @@ -90,35 +98,38 @@ await _testContext.RunOnDatabaseAsync(async dbContext => public async Task Can_create_resource_without_ID_when_supplying_ID_is_allowed() { // Arrange - Game game = _fakers.Game.Generate(); + Game newGame = _fakers.Game.Generate(); - using HttpClient httpClient = _testContext.Factory.CreateClient(); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); ClientIdGenerationModesClient apiClient = new(httpClient); - // Act - GamePrimaryResponseDocument? document = await ApiResponse.TranslateAsync(() => apiClient.PostGameAsync(null, new GamePostRequestDocument + var requestBody = new GamePostRequestDocument { Data = new GameDataInPostRequest { - Id = null!, Attributes = new GameAttributesInPostRequest { - Title = game.Title, - PurchasePrice = (double)game.PurchasePrice + Title = newGame.Title, + PurchasePrice = (double)newGame.PurchasePrice } } - })); + }; + + // Act + GamePrimaryResponseDocument? document = await ApiResponse.TranslateAsync(async () => await apiClient.PostGameAsync(null, requestBody)); // Assert document.ShouldNotBeNull(); - document.Data.Id.Should().NotBeNullOrEmpty(); + document.Data.Id.ShouldNotBeNullOrEmpty(); + + Guid newGameId = Guid.Parse(document.Data.Id); await _testContext.RunOnDatabaseAsync(async dbContext => { - Game gameInDatabase = await dbContext.Games.FirstWithIdAsync(Guid.Parse(document.Data.Id)); + Game gameInDatabase = await dbContext.Games.FirstWithIdAsync(newGameId); - gameInDatabase.Title.Should().Be(game.Title); - gameInDatabase.PurchasePrice.Should().Be(game.PurchasePrice); + gameInDatabase.Title.Should().Be(newGame.Title); + gameInDatabase.PurchasePrice.Should().Be(newGame.PurchasePrice); }); } @@ -126,69 +137,117 @@ await _testContext.RunOnDatabaseAsync(async dbContext => public async Task Can_create_resource_with_ID_when_supplying_ID_is_allowed() { // Arrange - Game game = _fakers.Game.Generate(); - game.Id = Guid.NewGuid(); + Game newGame = _fakers.Game.Generate(); + newGame.Id = Guid.NewGuid(); - using HttpClient httpClient = _testContext.Factory.CreateClient(); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); ClientIdGenerationModesClient apiClient = new(httpClient); - // Act - GamePrimaryResponseDocument? document = await ApiResponse.TranslateAsync(() => apiClient.PostGameAsync(null, new GamePostRequestDocument + var requestBody = new GamePostRequestDocument { Data = new GameDataInPostRequest { - Id = game.StringId!, + Id = newGame.StringId!, Attributes = new GameAttributesInPostRequest { - Title = game.Title, - PurchasePrice = (double)game.PurchasePrice + Title = newGame.Title, + PurchasePrice = (double)newGame.PurchasePrice } } - })); + }; + + // Act + GamePrimaryResponseDocument? document = await ApiResponse.TranslateAsync(async () => await apiClient.PostGameAsync(null, requestBody)); // Assert document.Should().BeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { - Game gameInDatabase = await dbContext.Games.FirstWithIdAsync(game.Id); + Game gameInDatabase = await dbContext.Games.FirstWithIdAsync(newGame.Id); - gameInDatabase.Title.Should().Be(game.Title); - gameInDatabase.PurchasePrice.Should().Be(game.PurchasePrice); + gameInDatabase.Title.Should().Be(newGame.Title); + gameInDatabase.PurchasePrice.Should().Be(newGame.PurchasePrice); }); } [Fact] - public async Task Can_create_resource_without_ID_when_supplying_ID_is_forbidden() + public async Task Cannot_create_resource_with_existing_ID_when_supplying_ID_is_allowed() { // Arrange - PlayerGroup playerGroup = _fakers.Group.Generate(); + Game existingGame = _fakers.Game.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.Games.Add(existingGame); + await dbContext.SaveChangesAsync(); + }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); ClientIdGenerationModesClient apiClient = new(httpClient); + var requestBody = new GamePostRequestDocument + { + Data = new GameDataInPostRequest + { + Id = existingGame.StringId!, + Attributes = new GameAttributesInPostRequest + { + Title = existingGame.Title, + PurchasePrice = (double)existingGame.PurchasePrice + } + } + }; + // Act - PlayerGroupPrimaryResponseDocument? document = await ApiResponse.TranslateAsync(() => apiClient.PostPlayerGroupAsync(null, - new PlayerGroupPostRequestDocument + Func action = async () => _ = await apiClient.PostGameAsync(null, requestBody); + + // Assert + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.Conflict); + exception.Message.Should().Be("HTTP 409: The request body contains conflicting information or another resource with the same ID already exists."); + exception.Result.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("409"); + error.Title.Should().Be("Another resource with the specified ID already exists."); + error.Detail.Should().Be($"Another resource of type 'games' with ID '{existingGame.StringId}' already exists."); + } + + [Fact] + public async Task Can_create_resource_without_ID_when_supplying_ID_is_forbidden() + { + // Arrange + PlayerGroup newPlayerGroup = _fakers.Group.Generate(); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + ClientIdGenerationModesClient apiClient = new(httpClient); + + var requestBody = new PlayerGroupPostRequestDocument + { + Data = new PlayerGroupDataInPostRequest { - Data = new PlayerGroupDataInPostRequest + Attributes = new PlayerGroupAttributesInPostRequest { - Attributes = new PlayerGroupAttributesInPostRequest - { - Name = playerGroup.Name - } + Name = newPlayerGroup.Name } - })); + } + }; + + // Act + PlayerGroupPrimaryResponseDocument? document = await ApiResponse.TranslateAsync(async () => await apiClient.PostPlayerGroupAsync(null, requestBody)); // Assert document.ShouldNotBeNull(); - document.Data.Id.Should().NotBeNullOrEmpty(); + document.Data.Id.ShouldNotBeNullOrEmpty(); + + long newPlayerGroupId = long.Parse(document.Data.Id); await _testContext.RunOnDatabaseAsync(async dbContext => { - PlayerGroup playerGroupInDatabase = await dbContext.PlayerGroups.FirstWithIdAsync(long.Parse(document.Data.Id)); + PlayerGroup playerGroupInDatabase = await dbContext.PlayerGroups.FirstWithIdAsync(newPlayerGroupId); - playerGroupInDatabase.Name.Should().Be(playerGroup.Name); + playerGroupInDatabase.Name.Should().Be(newPlayerGroup.Name); }); } } diff --git a/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs b/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs index 3608ef459b..0df55f14f0 100644 --- a/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs +++ b/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs @@ -11,13 +11,13 @@ namespace OpenApiNSwagEndToEndTests.Headers; -public sealed class ETagTests : IClassFixture, HeadersDbContext>> +public sealed class ETagTests : IClassFixture, HeaderDbContext>> { - private readonly IntegrationTestContext, HeadersDbContext> _testContext; + private readonly IntegrationTestContext, HeaderDbContext> _testContext; private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; private readonly HeaderFakers _fakers = new(); - public ETagTests(IntegrationTestContext, HeadersDbContext> testContext, ITestOutputHelper testOutputHelper) + public ETagTests(IntegrationTestContext, HeaderDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); @@ -42,12 +42,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => var apiClient = new HeadersClient(httpClient); // Act - ApiResponse response = await ApiResponse.TranslateAsync(() => apiClient.HeadCountryCollectionAsync(null, null)); + ApiResponse response = await ApiResponse.TranslateAsync(async () => await apiClient.HeadCountryCollectionAsync(null, null)); // Assert response.StatusCode.Should().Be((int)HttpStatusCode.OK); - response.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().NotBeNullOrEmpty(); + string[] eTagHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); + eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues[0].Should().Match("\"*\""); } [Fact] @@ -67,12 +69,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => var apiClient = new HeadersClient(httpClient); // Act - ApiResponse response = await ApiResponse.TranslateAsync(() => apiClient.GetCountryCollectionAsync(null, null)); + ApiResponse response = + await ApiResponse.TranslateAsync(async () => await apiClient.GetCountryCollectionAsync(null, null)); // Assert response.StatusCode.Should().Be((int)HttpStatusCode.OK); - response.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().NotBeNullOrEmpty(); + string[] eTagHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); + eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues[0].Should().Match("\"*\""); response.Result.ShouldNotBeNull(); } @@ -81,17 +86,25 @@ await _testContext.RunOnDatabaseAsync(async dbContext => public async Task Returns_no_ETag_for_failed_GET_request() { // Arrange + string unknownCountryId = Unknown.StringId.For(); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); var apiClient = new HeadersClient(httpClient); // Act - Func>> action = () => - ApiResponse.TranslateAsync(() => apiClient.GetCountryAsync(Unknown.StringId.For(), null, null)); + Func action = async () => await ApiResponse.TranslateAsync(async () => await apiClient.GetCountryAsync(unknownCountryId, null, null)); // Assert ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be("HTTP 404: The country does not exist."); exception.Headers.Should().NotContainKey(HeaderNames.ETag); + exception.Result.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("The requested resource does not exist."); + error.Detail.Should().Be($"Resource of type 'countries' with ID '{unknownCountryId}' does not exist."); } [Fact] @@ -103,19 +116,21 @@ public async Task Returns_no_ETag_for_POST_request() using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); var apiClient = new HeadersClient(httpClient); - // Act - ApiResponse response = await ApiResponse.TranslateAsync(() => apiClient.PostCountryAsync(null, - new CountryPostRequestDocument + var requestBody = new CountryPostRequestDocument + { + Data = new CountryDataInPostRequest { - Data = new CountryDataInPostRequest + Attributes = new CountryAttributesInPostRequest { - Attributes = new CountryAttributesInPostRequest - { - Name = newCountry.Name, - Population = newCountry.Population - } + Name = newCountry.Name, + Population = newCountry.Population } - })); + } + }; + + // Act + ApiResponse response = + await ApiResponse.TranslateAsync(async () => await apiClient.PostCountryAsync(null, requestBody)); // Assert response.StatusCode.Should().Be((int)HttpStatusCode.Created); @@ -141,18 +156,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); var apiClient = new HeadersClient(httpClient); - ApiResponse response1 = await ApiResponse.TranslateAsync(() => apiClient.GetCountryCollectionAsync(null, null)); + ApiResponse response1 = + await ApiResponse.TranslateAsync(async () => await apiClient.GetCountryCollectionAsync(null, null)); string responseETag = response1.Headers[HeaderNames.ETag].Single(); // Act ApiResponse response2 = - await ApiResponse.TranslateAsync(() => apiClient.GetCountryCollectionAsync(null, responseETag)); + await ApiResponse.TranslateAsync(async () => await apiClient.GetCountryCollectionAsync(null, responseETag)); // Assert response2.StatusCode.Should().Be((int)HttpStatusCode.NotModified); - response2.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().Equal([responseETag]); + string[] eTagHeaderValues = response2.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); + eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues[0].Should().Be(responseETag); response2.Result.Should().BeNull(); } @@ -175,12 +193,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Act ApiResponse response = - await ApiResponse.TranslateAsync(() => apiClient.GetCountryCollectionAsync(null, "\"Not-a-matching-value\"")); + await ApiResponse.TranslateAsync(async () => await apiClient.GetCountryCollectionAsync(null, "\"Not-a-matching-value\"")); // Assert response.StatusCode.Should().Be((int)HttpStatusCode.OK); - response.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().NotBeNullOrEmpty(); + string[] eTagHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); + eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues[0].Should().Match("\"*\""); response.Result.ShouldNotBeNull(); } diff --git a/test/OpenApiNSwagEndToEndTests/Headers/HeaderTests.cs b/test/OpenApiNSwagEndToEndTests/Headers/HeaderTests.cs new file mode 100644 index 0000000000..3c928c1853 --- /dev/null +++ b/test/OpenApiNSwagEndToEndTests/Headers/HeaderTests.cs @@ -0,0 +1,170 @@ +using System.Net; +using FluentAssertions; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using Microsoft.Net.Http.Headers; +using OpenApiNSwagEndToEndTests.Headers.GeneratedCode; +using OpenApiTests; +using OpenApiTests.Headers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiNSwagEndToEndTests.Headers; + +public sealed class HeaderTests : IClassFixture, HeaderDbContext>> +{ + private readonly IntegrationTestContext, HeaderDbContext> _testContext; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; + private readonly HeaderFakers _fakers = new(); + + public HeaderTests(IntegrationTestContext, HeaderDbContext> testContext, ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Returns_Location_for_post_resource_request() + { + // Arrange + Country newCountry = _fakers.Country.Generate(); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new HeadersClient(httpClient); + + var requestBody = new CountryPostRequestDocument + { + Data = new CountryDataInPostRequest + { + Attributes = new CountryAttributesInPostRequest + { + Name = newCountry.Name, + Population = newCountry.Population + } + } + }; + + // Act + ApiResponse response = + await ApiResponse.TranslateAsync(async () => await apiClient.PostCountryAsync(null, requestBody)); + + // Assert + response.StatusCode.Should().Be((int)HttpStatusCode.Created); + + response.Result.ShouldNotBeNull(); + + string[] locationHeaderValues = response.Headers.Should().ContainKey(HeaderNames.Location).WhoseValue.ToArray(); + locationHeaderValues.ShouldHaveCount(1); + locationHeaderValues[0].Should().Be($"/countries/{response.Result.Data.Id}"); + } + + [Fact] + public async Task Returns_ContentLength_for_head_primary_resources_request() + { + // Arrange + Country existingCountry = _fakers.Country.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Countries.Add(existingCountry); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new HeadersClient(httpClient); + + // Act + ApiResponse response = await ApiResponse.TranslateAsync(async () => await apiClient.HeadCountryCollectionAsync(null, null)); + + // Assert + response.StatusCode.Should().Be((int)HttpStatusCode.OK); + + string[] contentLengthHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); + contentLengthHeaderValues.ShouldHaveCount(1); + long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); + } + + [Fact] + public async Task Returns_ContentLength_for_head_primary_resource_request() + { + // Arrange + Country existingCountry = _fakers.Country.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.Countries.Add(existingCountry); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new HeadersClient(httpClient); + + // Act + ApiResponse response = await ApiResponse.TranslateAsync(async () => await apiClient.HeadCountryAsync(existingCountry.StringId!, null, null)); + + // Assert + response.StatusCode.Should().Be((int)HttpStatusCode.OK); + + string[] contentLengthHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); + contentLengthHeaderValues.ShouldHaveCount(1); + long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); + } + + [Fact] + public async Task Returns_ContentLength_for_head_secondary_resource_request() + { + // Arrange + Country existingCountry = _fakers.Country.Generate(); + existingCountry.Languages = _fakers.Language.Generate(1).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.Countries.Add(existingCountry); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new HeadersClient(httpClient); + + // Act + ApiResponse response = await ApiResponse.TranslateAsync(async () => await apiClient.HeadCountryLanguagesAsync(existingCountry.StringId!, null, null)); + + // Assert + response.StatusCode.Should().Be((int)HttpStatusCode.OK); + + string[] contentLengthHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); + contentLengthHeaderValues.ShouldHaveCount(1); + long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); + } + + [Fact] + public async Task Returns_ContentLength_for_head_relationship_request() + { + // Arrange + Country existingCountry = _fakers.Country.Generate(); + existingCountry.Languages = _fakers.Language.Generate(1).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.Countries.Add(existingCountry); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new HeadersClient(httpClient); + + // Act + ApiResponse response = + await ApiResponse.TranslateAsync(async () => await apiClient.HeadCountryLanguagesRelationshipAsync(existingCountry.StringId!, null, null)); + + // Assert + response.StatusCode.Should().Be((int)HttpStatusCode.OK); + + string[] contentLengthHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); + contentLengthHeaderValues.ShouldHaveCount(1); + long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); + } +} diff --git a/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj b/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj index c70d144e98..2217894843 100644 --- a/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj +++ b/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj @@ -44,5 +44,12 @@ NSwagCSharp /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true + + OpenApiNSwagEndToEndTests.RestrictedControllers.GeneratedCode + RestrictedControllersClient + RestrictedControllersClient.cs + NSwagCSharp + /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true + diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs index 4468ecaf35..cb351910fa 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs @@ -10,13 +10,13 @@ namespace OpenApiNSwagEndToEndTests.QueryStrings; -public sealed class FilterTests : IClassFixture, QueryStringsDbContext>> +public sealed class FilterTests : IClassFixture, QueryStringDbContext>> { - private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly IntegrationTestContext, QueryStringDbContext> _testContext; private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; private readonly QueryStringFakers _fakers = new(); - public FilterTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) + public FilterTests(IntegrationTestContext, QueryStringDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/GeneratedCode/QueryStringsClient.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/GeneratedCode/QueryStringsClient.cs deleted file mode 100644 index 9d507d3109..0000000000 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/GeneratedCode/QueryStringsClient.cs +++ /dev/null @@ -1,14 +0,0 @@ -using JsonApiDotNetCore.OpenApi.Client.NSwag; -using Newtonsoft.Json; - -namespace OpenApiNSwagEndToEndTests.QueryStrings.GeneratedCode; - -internal partial class QueryStringsClient : JsonApiClient -{ - partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings) - { - SetSerializerSettingsForJsonApi(settings); - - settings.Formatting = Formatting.Indented; - } -} diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs index a88bab96ba..7fad959f3f 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs @@ -8,13 +8,13 @@ namespace OpenApiNSwagEndToEndTests.QueryStrings; -public sealed class IncludeTests : IClassFixture, QueryStringsDbContext>> +public sealed class IncludeTests : IClassFixture, QueryStringDbContext>> { - private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly IntegrationTestContext, QueryStringDbContext> _testContext; private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; private readonly QueryStringFakers _fakers = new(); - public IncludeTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) + public IncludeTests(IntegrationTestContext, QueryStringDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs index 6d6650b9d1..865a173471 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs @@ -10,13 +10,13 @@ namespace OpenApiNSwagEndToEndTests.QueryStrings; -public sealed class PaginationTests : IClassFixture, QueryStringsDbContext>> +public sealed class PaginationTests : IClassFixture, QueryStringDbContext>> { - private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly IntegrationTestContext, QueryStringDbContext> _testContext; private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; private readonly QueryStringFakers _fakers = new(); - public PaginationTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) + public PaginationTests(IntegrationTestContext, QueryStringDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs index 52e85dad0c..8a06f52ebb 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs @@ -10,13 +10,13 @@ namespace OpenApiNSwagEndToEndTests.QueryStrings; -public sealed class SortTests : IClassFixture, QueryStringsDbContext>> +public sealed class SortTests : IClassFixture, QueryStringDbContext>> { - private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly IntegrationTestContext, QueryStringDbContext> _testContext; private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; private readonly QueryStringFakers _fakers = new(); - public SortTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) + public SortTests(IntegrationTestContext, QueryStringDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs index c509082d40..6698effc33 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs @@ -8,13 +8,13 @@ namespace OpenApiNSwagEndToEndTests.QueryStrings; -public sealed class SparseFieldSetTests : IClassFixture, QueryStringsDbContext>> +public sealed class SparseFieldSetTests : IClassFixture, QueryStringDbContext>> { - private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly IntegrationTestContext, QueryStringDbContext> _testContext; private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; private readonly QueryStringFakers _fakers = new(); - public SparseFieldSetTests(IntegrationTestContext, QueryStringsDbContext> testContext, + public SparseFieldSetTests(IntegrationTestContext, QueryStringDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/CreateResourceTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/CreateResourceTests.cs new file mode 100644 index 0000000000..0a7c8acf1a --- /dev/null +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/CreateResourceTests.cs @@ -0,0 +1,197 @@ +using System.Net; +using FluentAssertions; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using Microsoft.EntityFrameworkCore; +using OpenApiNSwagEndToEndTests.RestrictedControllers.GeneratedCode; +using OpenApiTests; +using OpenApiTests.RestrictedControllers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiNSwagEndToEndTests.RestrictedControllers; + +public sealed class CreateResourceTests : IClassFixture, RestrictionDbContext>> +{ + private readonly IntegrationTestContext, RestrictionDbContext> _testContext; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; + private readonly RestrictionFakers _fakers = new(); + + public CreateResourceTests(IntegrationTestContext, RestrictionDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_create_resource_with_includes_and_fieldsets() + { + // Arrange + DataStream existingVideoStream = _fakers.DataStream.Generate(); + DataStream existingAudioStream = _fakers.DataStream.Generate(); + WriteOnlyChannel newChannel = _fakers.WriteOnlyChannel.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.DataStreams.AddRange(existingVideoStream, existingAudioStream); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + var requestBody = new WriteOnlyChannelPostRequestDocument + { + Data = new WriteOnlyChannelDataInPostRequest + { + Attributes = new WriteOnlyChannelAttributesInPostRequest + { + Name = newChannel.Name, + IsAdultOnly = newChannel.IsAdultOnly + }, + Relationships = new WriteOnlyChannelRelationshipsInPostRequest + { + VideoStream = new ToOneDataStreamInRequest + { + Data = new DataStreamIdentifier + { + Id = existingVideoStream.StringId! + } + }, + AudioStreams = new ToManyDataStreamInRequest + { + Data = + [ + new DataStreamIdentifier + { + Id = existingAudioStream.StringId! + } + ] + } + } + } + }; + + var queryString = new Dictionary + { + ["include"] = "videoStream,audioStreams", + ["fields[writeOnlyChannels]"] = "name,isCommercial,videoStream,audioStreams", + ["fields[dataStreams]"] = "bytesTransmitted" + }; + + // Act + WriteOnlyChannelPrimaryResponseDocument? response = + await ApiResponse.TranslateAsync(async () => await apiClient.PostWriteOnlyChannelAsync(queryString, requestBody)); + + response.ShouldNotBeNull(); + + response.Data.Attributes.Name.Should().Be(newChannel.Name); + response.Data.Attributes.IsCommercial.Should().BeNull(); + response.Data.Attributes.IsAdultOnly.Should().BeNull(); + response.Data.Relationships.VideoStream.Data.Id.Should().Be(existingVideoStream.StringId); + response.Data.Relationships.UltraHighDefinitionVideoStream.Should().BeNull(); + response.Data.Relationships.AudioStreams.Data.ShouldHaveCount(1); + response.Data.Relationships.AudioStreams.Data.ElementAt(0).Id.Should().Be(existingAudioStream.StringId); + + response.Included.ShouldHaveCount(2); + DataStreamDataInResponse[] dataStreamIncludes = response.Included.OfType().ToArray(); + + DataStreamDataInResponse videoStream = dataStreamIncludes.Single(include => include.Id == existingVideoStream.StringId); + videoStream.Attributes.BytesTransmitted.Should().Be((long?)existingVideoStream.BytesTransmitted); + + DataStreamDataInResponse audioStream = dataStreamIncludes.Single(include => include.Id == existingAudioStream.StringId); + audioStream.Attributes.BytesTransmitted.Should().Be((long?)existingAudioStream.BytesTransmitted); + + long newChannelId = int.Parse(response.Data.Id.ShouldNotBeNull()); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.VideoStream) + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(newChannelId); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.Name.Should().Be(newChannel.Name); + channelInDatabase.IsCommercial.Should().BeNull(); + channelInDatabase.IsAdultOnly.Should().Be(newChannel.IsAdultOnly); + + channelInDatabase.VideoStream.ShouldNotBeNull(); + channelInDatabase.VideoStream.Id.Should().Be(existingVideoStream.Id); + + channelInDatabase.AudioStreams.ShouldHaveCount(1); + channelInDatabase.AudioStreams.ElementAt(0).Id.Should().Be(existingAudioStream.Id); + }); + } + + [Fact] + public async Task Cannot_create_resource_for_missing_request_body() + { + // Arrange + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + WriteOnlyChannelPostRequestDocument requestBody = null!; + + // Act + Func action = async () => _ = await apiClient.PostWriteOnlyChannelAsync(null, requestBody); + + // Assert + await action.Should().ThrowExactlyAsync().WithParameterName("body"); + } + + [Fact] + public async Task Cannot_create_resource_with_unknown_relationship_ID() + { + // Arrange + WriteOnlyChannel newChannel = _fakers.WriteOnlyChannel.Generate(); + + string unknownVideoStreamId = Unknown.StringId.For(); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + var requestBody = new WriteOnlyChannelPostRequestDocument + { + Data = new WriteOnlyChannelDataInPostRequest + { + Attributes = new WriteOnlyChannelAttributesInPostRequest + { + Name = newChannel.Name + }, + Relationships = new WriteOnlyChannelRelationshipsInPostRequest + { + VideoStream = new ToOneDataStreamInRequest + { + Data = new DataStreamIdentifier + { + Id = unknownVideoStreamId + } + } + } + } + }; + + // Act + Func action = async () => _ = await apiClient.PostWriteOnlyChannelAsync(null, requestBody); + + // Assert + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be("HTTP 404: A related resource does not exist."); + exception.Result.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("A related resource does not exist."); + error.Detail.Should().Be($"Related resource of type 'dataStreams' with ID '{unknownVideoStreamId}' in relationship 'videoStream' does not exist."); + } +} diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/DeleteResourceTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/DeleteResourceTests.cs new file mode 100644 index 0000000000..723cf6013b --- /dev/null +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/DeleteResourceTests.cs @@ -0,0 +1,79 @@ +using System.Net; +using FluentAssertions; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using OpenApiNSwagEndToEndTests.RestrictedControllers.GeneratedCode; +using OpenApiTests; +using OpenApiTests.RestrictedControllers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiNSwagEndToEndTests.RestrictedControllers; + +public sealed class DeleteResourceTests : IClassFixture, RestrictionDbContext>> +{ + private readonly IntegrationTestContext, RestrictionDbContext> _testContext; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; + private readonly RestrictionFakers _fakers = new(); + + public DeleteResourceTests(IntegrationTestContext, RestrictionDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_delete_existing_resource() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + await apiClient.DeleteWriteOnlyChannelAsync(existingChannel.StringId!); + + // Assert + await _testContext.RunOnDatabaseAsync(async dbContext => + { + WriteOnlyChannel? channelInDatabase = await dbContext.WriteOnlyChannels.FirstWithIdOrDefaultAsync(existingChannel.Id); + + channelInDatabase.Should().BeNull(); + }); + } + + [Fact] + public async Task Cannot_delete_unknown_resource() + { + // Arrange + string unknownChannelId = Unknown.StringId.For(); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + Func action = async () => await apiClient.DeleteWriteOnlyChannelAsync(unknownChannelId); + + // Assert + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be("HTTP 404: The writeOnlyChannel does not exist."); + exception.Result.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("The requested resource does not exist."); + error.Detail.Should().Be($"Resource of type 'writeOnlyChannels' with ID '{unknownChannelId}' does not exist."); + } +} diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs new file mode 100644 index 0000000000..18297f3c39 --- /dev/null +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs @@ -0,0 +1,150 @@ +using System.Net; +using FluentAssertions; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using OpenApiNSwagEndToEndTests.RestrictedControllers.GeneratedCode; +using OpenApiTests; +using OpenApiTests.RestrictedControllers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiNSwagEndToEndTests.RestrictedControllers; + +public sealed class FetchRelationshipTests : IClassFixture, RestrictionDbContext>> +{ + private readonly IntegrationTestContext, RestrictionDbContext> _testContext; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; + private readonly RestrictionFakers _fakers = new(); + + public FetchRelationshipTests(IntegrationTestContext, RestrictionDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_get_ToOne_relationship() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + DataStreamIdentifierResponseDocument response = await apiClient.GetReadOnlyChannelVideoStreamRelationshipAsync(channel.StringId!, null, null); + + // Assert + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(channel.VideoStream.StringId); + } + + [Fact] + public async Task Can_get_empty_ToOne_relationship() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + NullableDataStreamIdentifierResponseDocument response = + await apiClient.GetReadOnlyChannelUltraHighDefinitionVideoStreamRelationshipAsync(channel.StringId!, null, null); + + // Assert + response.Data.Should().BeNull(); + } + + [Fact] + public async Task Can_get_ToMany_relationship() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + channel.AudioStreams = _fakers.DataStream.Generate(2).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + DataStreamIdentifierCollectionResponseDocument + response = await apiClient.GetReadOnlyChannelAudioStreamsRelationshipAsync(channel.StringId!, null, null); + + // Assert + response.Data.ShouldHaveCount(2); + response.Data.Should().ContainSingle(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(0).StringId); + response.Data.Should().ContainSingle(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(1).StringId); + } + + [Fact] + public async Task Can_get_empty_ToMany_relationship() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + DataStreamIdentifierCollectionResponseDocument + response = await apiClient.GetReadOnlyChannelAudioStreamsRelationshipAsync(channel.StringId!, null, null); + + // Assert + response.Data.ShouldHaveCount(0); + } + + [Fact] + public async Task Cannot_get_relationship_for_unknown_primary_ID() + { + // Arrange + string unknownChannelId = Unknown.StringId.For(); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + Func action = async () => _ = await apiClient.GetReadOnlyChannelVideoStreamRelationshipAsync(unknownChannelId, null, null); + + // Assert + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be("HTTP 404: The readOnlyChannel does not exist."); + exception.Result.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("The requested resource does not exist."); + error.Detail.Should().Be($"Resource of type 'readOnlyChannels' with ID '{unknownChannelId}' does not exist."); + } +} diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchResourceTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchResourceTests.cs new file mode 100644 index 0000000000..d4279048e8 --- /dev/null +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchResourceTests.cs @@ -0,0 +1,247 @@ +using System.Net; +using FluentAssertions; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using OpenApiNSwagEndToEndTests.RestrictedControllers.GeneratedCode; +using OpenApiTests; +using OpenApiTests.RestrictedControllers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiNSwagEndToEndTests.RestrictedControllers; + +public sealed class FetchResourceTests : IClassFixture, RestrictionDbContext>> +{ + private readonly IntegrationTestContext, RestrictionDbContext> _testContext; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; + private readonly RestrictionFakers _fakers = new(); + + public FetchResourceTests(IntegrationTestContext, RestrictionDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_get_primary_resources() + { + // Arrange + List channels = _fakers.ReadOnlyChannel.Generate(2); + channels.ForEach(channel => channel.VideoStream = _fakers.DataStream.Generate()); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.ReadOnlyChannels.AddRange(channels); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + ReadOnlyChannelCollectionResponseDocument response = await apiClient.GetReadOnlyChannelCollectionAsync(null, null); + + // Assert + response.Data.ShouldHaveCount(2); + + ReadOnlyChannelDataInResponse channel1 = response.Data.Single(channel => channel.Id == channels.ElementAt(0).StringId); + channel1.Attributes.Name.Should().Be(channels[0].Name); + channel1.Attributes.IsCommercial.Should().Be(channels[0].IsCommercial); + channel1.Attributes.IsAdultOnly.Should().Be(channels[0].IsAdultOnly); + channel1.Relationships.VideoStream.Data.Should().BeNull(); + channel1.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); + channel1.Relationships.AudioStreams.Data.Should().BeNull(); + + ReadOnlyChannelDataInResponse channel2 = response.Data.Single(channel => channel.Id == channels.ElementAt(1).StringId); + channel2.Attributes.Name.Should().Be(channels[1].Name); + channel2.Attributes.IsCommercial.Should().Be(channels[1].IsCommercial); + channel2.Attributes.IsAdultOnly.Should().Be(channels[1].IsAdultOnly); + channel2.Relationships.VideoStream.Data.Should().BeNull(); + channel2.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); + channel2.Relationships.AudioStreams.Data.Should().BeNull(); + } + + [Fact] + public async Task Can_get_primary_resource_by_ID() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + ReadOnlyChannelPrimaryResponseDocument response = await apiClient.GetReadOnlyChannelAsync(channel.StringId!, null, null); + + // Assert + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(channel.StringId); + response.Data.Attributes.Name.Should().Be(channel.Name); + response.Data.Attributes.IsCommercial.Should().Be(channel.IsCommercial); + response.Data.Attributes.IsAdultOnly.Should().Be(channel.IsAdultOnly); + response.Data.Relationships.VideoStream.Data.Should().BeNull(); + response.Data.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); + response.Data.Relationships.AudioStreams.Data.Should().BeNull(); + } + + [Fact] + public async Task Cannot_get_primary_resource_for_unknown_ID() + { + // Arrange + string unknownChannelId = Unknown.StringId.For(); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + Func action = async () => _ = await apiClient.GetReadOnlyChannelAsync(unknownChannelId, null, null); + + // Assert + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be("HTTP 404: The readOnlyChannel does not exist."); + exception.Result.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("The requested resource does not exist."); + error.Detail.Should().Be($"Resource of type 'readOnlyChannels' with ID '{unknownChannelId}' does not exist."); + } + + [Fact] + public async Task Can_get_secondary_ToOne_resource() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + DataStreamSecondaryResponseDocument response = await apiClient.GetReadOnlyChannelVideoStreamAsync(channel.StringId!, null, null); + + // Assert + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(channel.VideoStream.StringId); + response.Data.Attributes.BytesTransmitted.Should().Be((long?)channel.VideoStream.BytesTransmitted); + } + + [Fact] + public async Task Can_get_unknown_secondary_ToOne_resource() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + NullableDataStreamSecondaryResponseDocument response = + await apiClient.GetReadOnlyChannelUltraHighDefinitionVideoStreamAsync(channel.StringId!, null, null); + + // Assert + response.Data.Should().BeNull(); + } + + [Fact] + public async Task Can_get_secondary_ToMany_resources() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + channel.AudioStreams = _fakers.DataStream.Generate(2).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + DataStreamCollectionResponseDocument response = await apiClient.GetReadOnlyChannelAudioStreamsAsync(channel.StringId!, null, null); + + // Assert + response.Data.ShouldHaveCount(2); + + DataStreamDataInResponse audioStream1 = response.Data.Single(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(0).StringId); + audioStream1.Attributes.BytesTransmitted.Should().Be((long?)channel.AudioStreams.ElementAt(0).BytesTransmitted); + + DataStreamDataInResponse audioStream2 = response.Data.Single(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(1).StringId); + audioStream2.Attributes.BytesTransmitted.Should().Be((long?)channel.AudioStreams.ElementAt(1).BytesTransmitted); + } + + [Fact] + public async Task Can_get_no_secondary_ToMany_resources() + { + // Arrange + ReadOnlyChannel channel = _fakers.ReadOnlyChannel.Generate(); + channel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.ReadOnlyChannels.Add(channel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + DataStreamCollectionResponseDocument response = await apiClient.GetReadOnlyChannelAudioStreamsAsync(channel.StringId!, null, null); + + // Assert + response.Data.ShouldHaveCount(0); + } + + [Fact] + public async Task Cannot_get_secondary_resource_for_unknown_primary_ID() + { + // Arrange + string unknownChannelId = Unknown.StringId.For(); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + // Act + Func action = async () => _ = await apiClient.GetReadOnlyChannelVideoStreamAsync(unknownChannelId, null, null); + + // Assert + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be("HTTP 404: The readOnlyChannel does not exist."); + exception.Result.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("The requested resource does not exist."); + error.Detail.Should().Be($"Resource of type 'readOnlyChannels' with ID '{unknownChannelId}' does not exist."); + } +} diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs new file mode 100644 index 0000000000..90485d2730 --- /dev/null +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs @@ -0,0 +1,398 @@ +using System.Net; +using FluentAssertions; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using Microsoft.EntityFrameworkCore; +using OpenApiNSwagEndToEndTests.RestrictedControllers.GeneratedCode; +using OpenApiTests; +using OpenApiTests.RestrictedControllers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiNSwagEndToEndTests.RestrictedControllers; + +public sealed class UpdateRelationshipTests : IClassFixture, RestrictionDbContext>> +{ + private readonly IntegrationTestContext, RestrictionDbContext> _testContext; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; + private readonly RestrictionFakers _fakers = new(); + + public UpdateRelationshipTests(IntegrationTestContext, RestrictionDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_replace_ToOne_relationship() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.UltraHighDefinitionVideoStream = _fakers.DataStream.Generate(); + + DataStream existingVideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + dbContext.DataStreams.Add(existingVideoStream); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + var requestBody = new NullableToOneDataStreamInRequest + { + Data = new DataStreamIdentifier + { + Id = existingVideoStream.StringId! + } + }; + + // Act + await ApiResponse.TranslateAsync(async () => + await apiClient.PatchWriteOnlyChannelUltraHighDefinitionVideoStreamRelationshipAsync(existingChannel.StringId!, requestBody)); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.UltraHighDefinitionVideoStream) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channelInDatabase.UltraHighDefinitionVideoStream.Id.Should().Be(existingVideoStream.Id); + }); + } + + [Fact] + public async Task Can_clear_ToOne_relationship() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.UltraHighDefinitionVideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + var requestBody = new NullableToOneDataStreamInRequest + { + Data = null + }; + + // Act + await ApiResponse.TranslateAsync(async () => + await apiClient.PatchWriteOnlyChannelUltraHighDefinitionVideoStreamRelationshipAsync(existingChannel.StringId!, requestBody)); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.UltraHighDefinitionVideoStream) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.UltraHighDefinitionVideoStream.Should().BeNull(); + }); + } + + [Fact] + public async Task Can_replace_ToMany_relationship() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.AudioStreams = _fakers.DataStream.Generate(2).ToHashSet(); + + DataStream existingAudioStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + dbContext.DataStreams.Add(existingAudioStream); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + var requestBody = new ToManyDataStreamInRequest + { + Data = + [ + new DataStreamIdentifier + { + Id = existingAudioStream.StringId! + } + ] + }; + + // Act + await ApiResponse.TranslateAsync(async () => + await apiClient.PatchWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody)); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.AudioStreams.Should().HaveCount(1); + channelInDatabase.AudioStreams.ElementAt(0).Id.Should().Be(existingAudioStream.Id); + }); + } + + [Fact] + public async Task Can_clear_ToMany_relationship() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.AudioStreams = _fakers.DataStream.Generate(2).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + var requestBody = new ToManyDataStreamInRequest + { + Data = [] + }; + + // Act + await ApiResponse.TranslateAsync(async () => + await apiClient.PatchWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody)); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.AudioStreams.Should().BeEmpty(); + }); + } + + [Fact] + public async Task Can_add_to_ToMany_relationship() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.AudioStreams = _fakers.DataStream.Generate(1).ToHashSet(); + + DataStream existingAudioStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + dbContext.DataStreams.Add(existingAudioStream); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + var requestBody = new ToManyDataStreamInRequest + { + Data = + [ + new DataStreamIdentifier + { + Id = existingAudioStream.StringId! + } + ] + }; + + // Act + await ApiResponse.TranslateAsync(async () => await apiClient.PostWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody)); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.AudioStreams.Should().HaveCount(2); + channelInDatabase.AudioStreams.Should().ContainSingle(stream => stream.Id == existingChannel.AudioStreams.ElementAt(0).Id); + channelInDatabase.AudioStreams.Should().ContainSingle(stream => stream.Id == existingAudioStream.Id); + }); + } + + [Fact] + public async Task Can_remove_from_ToMany_relationship() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.AudioStreams = _fakers.DataStream.Generate(3).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + var requestBody = new ToManyDataStreamInRequest + { + Data = + [ + new DataStreamIdentifier + { + Id = existingChannel.AudioStreams.ElementAt(0).StringId! + }, + new DataStreamIdentifier + { + Id = existingChannel.AudioStreams.ElementAt(1).StringId! + } + ] + }; + + // Act + await ApiResponse.TranslateAsync(async () => + await apiClient.DeleteWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody)); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.AudioStreams.Should().HaveCount(1); + channelInDatabase.AudioStreams.ElementAt(0).Id.Should().Be(existingChannel.AudioStreams.ElementAt(2).Id); + }); + } + + [Fact] + public async Task Cannot_update_relationship_for_missing_request_body() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + NullableToOneDataStreamInRequest requestBody = null!; + + // Act + Func action = async () => + await apiClient.PatchWriteOnlyChannelUltraHighDefinitionVideoStreamRelationshipAsync(existingChannel.StringId!, requestBody); + + // Assert + await action.Should().ThrowExactlyAsync().WithParameterName("body"); + } + + [Fact] + public async Task Cannot_update_relationship_with_unknown_relationship_IDs() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + string unknownAudioStreamId1 = Unknown.StringId.For(); + string unknownAudioStreamId2 = Unknown.StringId.AltFor(); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + var requestBody = new ToManyDataStreamInRequest + { + Data = + [ + new DataStreamIdentifier + { + Id = unknownAudioStreamId1 + }, + new DataStreamIdentifier + { + Id = unknownAudioStreamId2 + } + ] + }; + + // Act + Func action = async () => await apiClient.PatchWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody); + + // Assert + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be("HTTP 404: The writeOnlyChannel or a related resource does not exist."); + exception.Result.Errors.ShouldHaveCount(2); + + ErrorObject error1 = exception.Result.Errors.ElementAt(0); + error1.Status.Should().Be("404"); + error1.Title.Should().Be("A related resource does not exist."); + error1.Detail.Should().Be($"Related resource of type 'dataStreams' with ID '{unknownAudioStreamId1}' in relationship 'audioStreams' does not exist."); + + ErrorObject error2 = exception.Result.Errors.ElementAt(1); + error2.Status.Should().Be("404"); + error2.Title.Should().Be("A related resource does not exist."); + error2.Detail.Should().Be($"Related resource of type 'dataStreams' with ID '{unknownAudioStreamId2}' in relationship 'audioStreams' does not exist."); + } +} diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateResourceTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateResourceTests.cs new file mode 100644 index 0000000000..cde8b0413d --- /dev/null +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateResourceTests.cs @@ -0,0 +1,298 @@ +using System.Net; +using FluentAssertions; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using JsonApiDotNetCore.Resources; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using OpenApiNSwagEndToEndTests.RestrictedControllers.GeneratedCode; +using OpenApiTests; +using OpenApiTests.RestrictedControllers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiNSwagEndToEndTests.RestrictedControllers; + +public sealed class UpdateResourceTests : IClassFixture, RestrictionDbContext>> +{ + private readonly IntegrationTestContext, RestrictionDbContext> _testContext; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; + private readonly RestrictionFakers _fakers = new(); + + public UpdateResourceTests(IntegrationTestContext, RestrictionDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); + + testContext.UseController(); + + testContext.ConfigureServices(services => services.AddScoped(typeof(IResourceChangeTracker<>), typeof(NeverSameResourceChangeTracker<>))); + } + + [Fact] + public async Task Can_update_resource_with_includes_and_fieldsets() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.UltraHighDefinitionVideoStream = _fakers.DataStream.Generate(); + existingChannel.AudioStreams = _fakers.DataStream.Generate(2).ToHashSet(); + + DataStream existingVideoStream = _fakers.DataStream.Generate(); + string? newChannelName = _fakers.WriteOnlyChannel.Generate().Name; + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + dbContext.DataStreams.Add(existingVideoStream); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + var requestBody = new WriteOnlyChannelPatchRequestDocument + { + Data = new WriteOnlyChannelDataInPatchRequest + { + Id = existingChannel.StringId!, + Attributes = new WriteOnlyChannelAttributesInPatchRequest + { + Name = newChannelName + }, + Relationships = new WriteOnlyChannelRelationshipsInPatchRequest + { + VideoStream = new ToOneDataStreamInRequest + { + Data = new DataStreamIdentifier + { + Id = existingVideoStream.StringId! + } + }, + UltraHighDefinitionVideoStream = new NullableToOneDataStreamInRequest + { + Data = null + }, + AudioStreams = new ToManyDataStreamInRequest + { + Data = [] + } + } + } + }; + + var queryString = new Dictionary + { + ["include"] = "videoStream,audioStreams", + ["fields[writeOnlyChannels]"] = "name,isCommercial,videoStream,audioStreams", + ["fields[dataStreams]"] = "bytesTransmitted" + }; + + // Act + WriteOnlyChannelPrimaryResponseDocument? response = await ApiResponse.TranslateAsync(async () => + await apiClient.PatchWriteOnlyChannelAsync(existingChannel.StringId!, queryString, requestBody)); + + response.ShouldNotBeNull(); + + response.Data.Id.Should().Be(existingChannel.StringId); + response.Data.Attributes.Name.Should().Be(newChannelName); + response.Data.Attributes.IsCommercial.Should().Be(existingChannel.IsCommercial); + response.Data.Attributes.IsAdultOnly.Should().BeNull(); + response.Data.Relationships.VideoStream.Data.Id.Should().Be(existingVideoStream.StringId); + response.Data.Relationships.UltraHighDefinitionVideoStream.Should().BeNull(); + response.Data.Relationships.AudioStreams.Data.Should().BeEmpty(); + + response.Included.ShouldHaveCount(1); + + DataStreamDataInResponse? videoStream = response.Included.ElementAt(0).Should().BeOfType().Which; + videoStream.Id.Should().Be(existingVideoStream.StringId); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.VideoStream) + .Include(channel => channel.UltraHighDefinitionVideoStream) + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.Name.Should().Be(newChannelName); + channelInDatabase.IsCommercial.Should().Be(existingChannel.IsCommercial); + channelInDatabase.IsAdultOnly.Should().Be(existingChannel.IsAdultOnly); + + channelInDatabase.VideoStream.ShouldNotBeNull(); + channelInDatabase.VideoStream.Id.Should().Be(existingVideoStream.Id); + + channelInDatabase.UltraHighDefinitionVideoStream.Should().BeNull(); + + channelInDatabase.AudioStreams.Should().BeEmpty(); + }); + } + + [Fact] + public async Task Can_update_resource_without_attributes_or_relationships() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + existingChannel.UltraHighDefinitionVideoStream = _fakers.DataStream.Generate(); + existingChannel.AudioStreams = _fakers.DataStream.Generate(2).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + var requestBody = new WriteOnlyChannelPatchRequestDocument + { + Data = new WriteOnlyChannelDataInPatchRequest + { + Id = existingChannel.StringId!, + Attributes = new WriteOnlyChannelAttributesInPatchRequest(), + Relationships = new WriteOnlyChannelRelationshipsInPatchRequest() + } + }; + + // Act + WriteOnlyChannelPrimaryResponseDocument? response = + await ApiResponse.TranslateAsync(async () => await apiClient.PatchWriteOnlyChannelAsync(existingChannel.StringId!, null, requestBody)); + + response.ShouldNotBeNull(); + + response.Data.Id.Should().Be(existingChannel.StringId); + response.Data.Attributes.Name.Should().Be(existingChannel.Name); + response.Data.Attributes.IsCommercial.Should().Be(existingChannel.IsCommercial); + response.Data.Attributes.IsAdultOnly.Should().Be(existingChannel.IsAdultOnly); + response.Data.Relationships.VideoStream.Data.Should().BeNull(); + response.Data.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); + response.Data.Relationships.AudioStreams.Data.Should().BeNull(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + // @formatter:wrap_chained_method_calls chop_always + // @formatter:keep_existing_linebreaks true + + WriteOnlyChannel channelInDatabase = await dbContext.WriteOnlyChannels + .Include(channel => channel.VideoStream) + .Include(channel => channel.UltraHighDefinitionVideoStream) + .Include(channel => channel.AudioStreams) + .FirstWithIdAsync(existingChannel.Id); + + // @formatter:keep_existing_linebreaks restore + // @formatter:wrap_chained_method_calls restore + + channelInDatabase.Name.Should().Be(existingChannel.Name); + channelInDatabase.IsCommercial.Should().Be(existingChannel.IsCommercial); + channelInDatabase.IsAdultOnly.Should().Be(existingChannel.IsAdultOnly); + + channelInDatabase.VideoStream.ShouldNotBeNull(); + channelInDatabase.VideoStream.Id.Should().Be(existingChannel.VideoStream.Id); + + channelInDatabase.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channelInDatabase.UltraHighDefinitionVideoStream.Id.Should().Be(existingChannel.UltraHighDefinitionVideoStream.Id); + + channelInDatabase.AudioStreams.Should().HaveCount(2); + }); + } + + [Fact] + public async Task Cannot_update_resource_for_missing_request_body() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + WriteOnlyChannelPatchRequestDocument requestBody = null!; + + // Act + Func action = async () => _ = await apiClient.PatchWriteOnlyChannelAsync(existingChannel.StringId!, null, requestBody); + + // Assert + await action.Should().ThrowExactlyAsync().WithParameterName("body"); + } + + [Fact] + public async Task Cannot_update_resource_with_unknown_relationship_IDs() + { + // Arrange + WriteOnlyChannel existingChannel = _fakers.WriteOnlyChannel.Generate(); + existingChannel.VideoStream = _fakers.DataStream.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.WriteOnlyChannels.Add(existingChannel); + await dbContext.SaveChangesAsync(); + }); + + string unknownDataStreamId = Unknown.StringId.For(); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new RestrictedControllersClient(httpClient); + + var requestBody = new WriteOnlyChannelPatchRequestDocument + { + Data = new WriteOnlyChannelDataInPatchRequest + { + Id = existingChannel.StringId!, + Relationships = new WriteOnlyChannelRelationshipsInPatchRequest + { + VideoStream = new ToOneDataStreamInRequest + { + Data = new DataStreamIdentifier + { + Id = unknownDataStreamId + } + }, + AudioStreams = new ToManyDataStreamInRequest + { + Data = + [ + new DataStreamIdentifier + { + Id = unknownDataStreamId + } + ] + } + } + } + }; + + // Act + Func action = async () => _ = await apiClient.PatchWriteOnlyChannelAsync(existingChannel.StringId!, null, requestBody); + + // Assert + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be("HTTP 404: The writeOnlyChannel or a related resource does not exist."); + exception.Result.Errors.ShouldHaveCount(2); + + ErrorObject error1 = exception.Result.Errors.ElementAt(0); + error1.Status.Should().Be("404"); + error1.Title.Should().Be("A related resource does not exist."); + error1.Detail.Should().Be($"Related resource of type 'dataStreams' with ID '{unknownDataStreamId}' in relationship 'videoStream' does not exist."); + + ErrorObject error2 = exception.Result.Errors.ElementAt(1); + error2.Status.Should().Be("404"); + error2.Title.Should().Be("A related resource does not exist."); + error2.Detail.Should().Be($"Related resource of type 'dataStreams' with ID '{unknownDataStreamId}' in relationship 'audioStreams' does not exist."); + } +} diff --git a/test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationModesDbContext.cs b/test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationDbContext.cs similarity index 71% rename from test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationModesDbContext.cs rename to test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationDbContext.cs index f346f95bcf..65af7f7e8c 100644 --- a/test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationModesDbContext.cs +++ b/test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationDbContext.cs @@ -5,7 +5,7 @@ namespace OpenApiTests.ClientIdGenerationModes; [UsedImplicitly(ImplicitUseTargetFlags.Members)] -public sealed class ClientIdGenerationModesDbContext(DbContextOptions options) : TestableDbContext(options) +public sealed class ClientIdGenerationDbContext(DbContextOptions options) : TestableDbContext(options) { public DbSet Players => Set(); public DbSet Games => Set(); diff --git a/test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationModesFakers.cs b/test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationFakers.cs similarity index 94% rename from test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationModesFakers.cs rename to test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationFakers.cs index 83c08c8a59..d1ba2335aa 100644 --- a/test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationModesFakers.cs +++ b/test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationFakers.cs @@ -8,7 +8,7 @@ namespace OpenApiTests.ClientIdGenerationModes; [UsedImplicitly(ImplicitUseTargetFlags.Members)] -public sealed class ClientIdGenerationModesFakers : FakerContainer +public sealed class ClientIdGenerationFakers : FakerContainer { private readonly Lazy> _lazyPlayerFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) diff --git a/test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs b/test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationTests.cs similarity index 84% rename from test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs rename to test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationTests.cs index 193455be3c..0550083c2f 100644 --- a/test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs +++ b/test/OpenApiTests/ClientIdGenerationModes/ClientIdGenerationTests.cs @@ -4,12 +4,11 @@ namespace OpenApiTests.ClientIdGenerationModes; -public sealed class ClientIdGenerationModesTests - : IClassFixture, ClientIdGenerationModesDbContext>> +public sealed class ClientIdGenerationTests : IClassFixture, ClientIdGenerationDbContext>> { - private readonly OpenApiTestContext, ClientIdGenerationModesDbContext> _testContext; + private readonly OpenApiTestContext, ClientIdGenerationDbContext> _testContext; - public ClientIdGenerationModesTests(OpenApiTestContext, ClientIdGenerationModesDbContext> testContext) + public ClientIdGenerationTests(OpenApiTestContext, ClientIdGenerationDbContext> testContext) { _testContext = testContext; diff --git a/test/OpenApiTests/ClientIdGenerationModes/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/ClientIdGenerationModes/GeneratedSwagger/swagger.g.json index 0761c0b502..bd633634be 100644 --- a/test/OpenApiTests/ClientIdGenerationModes/GeneratedSwagger/swagger.g.json +++ b/test/OpenApiTests/ClientIdGenerationModes/GeneratedSwagger/swagger.g.json @@ -81,8 +81,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -185,8 +195,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -279,8 +299,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -498,9 +528,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -728,9 +755,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -820,9 +844,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/test/OpenApiTests/DocComments/DocCommentsDbContext.cs b/test/OpenApiTests/DocComments/DocCommentDbContext.cs similarity index 85% rename from test/OpenApiTests/DocComments/DocCommentsDbContext.cs rename to test/OpenApiTests/DocComments/DocCommentDbContext.cs index dbad39a5a4..0f6604cd31 100644 --- a/test/OpenApiTests/DocComments/DocCommentsDbContext.cs +++ b/test/OpenApiTests/DocComments/DocCommentDbContext.cs @@ -7,7 +7,7 @@ namespace OpenApiTests.DocComments; [UsedImplicitly(ImplicitUseTargetFlags.Members)] -public sealed class DocCommentsDbContext(DbContextOptions options) : TestableDbContext(options) +public sealed class DocCommentDbContext(DbContextOptions options) : TestableDbContext(options) { public DbSet Skyscrapers => Set(); public DbSet Elevators => Set(); diff --git a/test/OpenApiTests/DocComments/DocCommentsStartup.cs b/test/OpenApiTests/DocComments/DocCommentStartup.cs similarity index 94% rename from test/OpenApiTests/DocComments/DocCommentsStartup.cs rename to test/OpenApiTests/DocComments/DocCommentStartup.cs index d8c220e1a9..b04a867720 100644 --- a/test/OpenApiTests/DocComments/DocCommentsStartup.cs +++ b/test/OpenApiTests/DocComments/DocCommentStartup.cs @@ -8,7 +8,7 @@ namespace OpenApiTests.DocComments; [UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)] -public sealed class DocCommentsStartup : OpenApiStartup +public sealed class DocCommentStartup : OpenApiStartup where TDbContext : TestableDbContext { protected override void SetJsonApiOptions(JsonApiOptions options) diff --git a/test/OpenApiTests/DocComments/DocCommentsTests.cs b/test/OpenApiTests/DocComments/DocCommentTests.cs similarity index 97% rename from test/OpenApiTests/DocComments/DocCommentsTests.cs rename to test/OpenApiTests/DocComments/DocCommentTests.cs index 768a53decc..92ce75f83a 100644 --- a/test/OpenApiTests/DocComments/DocCommentsTests.cs +++ b/test/OpenApiTests/DocComments/DocCommentTests.cs @@ -6,7 +6,7 @@ namespace OpenApiTests.DocComments; -public sealed class DocCommentsTests : IClassFixture, DocCommentsDbContext>> +public sealed class DocCommentTests : IClassFixture, DocCommentDbContext>> { private const string ResourceTextQueryString = "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters."; @@ -14,9 +14,9 @@ public sealed class DocCommentsTests : IClassFixture, DocCommentsDbContext> _testContext; + private readonly OpenApiTestContext, DocCommentDbContext> _testContext; - public DocCommentsTests(OpenApiTestContext, DocCommentsDbContext> testContext) + public DocCommentTests(OpenApiTestContext, DocCommentDbContext> testContext) { _testContext = testContext; @@ -126,12 +126,13 @@ public async Task Endpoints_are_documented() postElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(5); + responsesElement.EnumerateObject().ShouldHaveCount(6); responsesElement.Should().HaveProperty("201.description", "The skyscraper was successfully created, which resulted in additional changes. The newly created skyscraper is returned."); responsesElement.Should().HaveProperty("201.headers.Location.description", "The URL at which the newly created skyscraper can be retrieved."); responsesElement.Should().HaveProperty("204.description", "The skyscraper was successfully created, which did not result in additional changes."); responsesElement.Should().HaveProperty("400.description", "The query string is invalid or the request body is missing or malformed."); - responsesElement.Should().HaveProperty("409.description", "A resource type in the request body is incompatible."); + responsesElement.Should().HaveProperty("404.description", "A related resource does not exist."); + responsesElement.Should().HaveProperty("409.description", "The request body contains conflicting information or another resource with the same ID already exists."); responsesElement.Should().HaveProperty("422.description", "Validation of the request body failed."); }); }); @@ -383,8 +384,8 @@ public async Task Endpoints_are_documented() responsesElement.EnumerateObject().ShouldHaveCount(4); responsesElement.Should().HaveProperty("204.description", "The elevator relationship was successfully updated, which did not result in additional changes."); responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed."); - responsesElement.Should().HaveProperty("404.description", "The skyscraper does not exist."); - responsesElement.Should().HaveProperty("409.description", "A resource type in the request body is incompatible."); + responsesElement.Should().HaveProperty("404.description", "The skyscraper or a related resource does not exist."); + responsesElement.Should().HaveProperty("409.description", "The request body contains conflicting information or another resource with the same ID already exists."); }); }); }); @@ -528,8 +529,8 @@ public async Task Endpoints_are_documented() responsesElement.EnumerateObject().ShouldHaveCount(4); responsesElement.Should().HaveProperty("204.description", "The spaces were successfully added, which did not result in additional changes."); responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed."); - responsesElement.Should().HaveProperty("404.description", "The skyscraper does not exist."); - responsesElement.Should().HaveProperty("409.description", "A resource type in the request body is incompatible."); + responsesElement.Should().HaveProperty("404.description", "The skyscraper or a related resource does not exist."); + responsesElement.Should().HaveProperty("409.description", "The request body contains conflicting information or another resource with the same ID already exists."); }); }); @@ -551,8 +552,8 @@ public async Task Endpoints_are_documented() responsesElement.EnumerateObject().ShouldHaveCount(4); responsesElement.Should().HaveProperty("204.description", "The spaces relationship was successfully updated, which did not result in additional changes."); responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed."); - responsesElement.Should().HaveProperty("404.description", "The skyscraper does not exist."); - responsesElement.Should().HaveProperty("409.description", "A resource type in the request body is incompatible."); + responsesElement.Should().HaveProperty("404.description", "The skyscraper or a related resource does not exist."); + responsesElement.Should().HaveProperty("409.description", "The request body contains conflicting information or another resource with the same ID already exists."); }); }); @@ -574,8 +575,8 @@ public async Task Endpoints_are_documented() responsesElement.EnumerateObject().ShouldHaveCount(4); responsesElement.Should().HaveProperty("204.description", "The spaces were successfully removed, which did not result in additional changes."); responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed."); - responsesElement.Should().HaveProperty("404.description", "The skyscraper does not exist."); - responsesElement.Should().HaveProperty("409.description", "A resource type in the request body is incompatible."); + responsesElement.Should().HaveProperty("404.description", "The skyscraper or a related resource does not exist."); + responsesElement.Should().HaveProperty("409.description", "The request body contains conflicting information or another resource with the same ID already exists."); }); }); }); diff --git a/test/OpenApiTests/DocComments/ErrorResponseTests.cs b/test/OpenApiTests/DocComments/ErrorResponseTests.cs index 951ad58356..21e5cd5040 100644 --- a/test/OpenApiTests/DocComments/ErrorResponseTests.cs +++ b/test/OpenApiTests/DocComments/ErrorResponseTests.cs @@ -5,13 +5,13 @@ namespace OpenApiTests.DocComments; -public sealed class ErrorResponseTests : IClassFixture, DocCommentsDbContext>> +public sealed class ErrorResponseTests : IClassFixture, DocCommentDbContext>> { private const string EscapedJsonApiMediaType = "['application/vnd.api+json']"; - private readonly OpenApiTestContext, DocCommentsDbContext> _testContext; + private readonly OpenApiTestContext, DocCommentDbContext> _testContext; - public ErrorResponseTests(OpenApiTestContext, DocCommentsDbContext> testContext) + public ErrorResponseTests(OpenApiTestContext, DocCommentDbContext> testContext) { _testContext = testContext; @@ -53,11 +53,12 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp skyscrapersElement.Should().ContainPath("post.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(3); + errorStatusCodeProperties.ShouldHaveCount(4); errorStatusCodeProperties[0].Name.Should().Be("400"); - errorStatusCodeProperties[1].Name.Should().Be("409"); - errorStatusCodeProperties[2].Name.Should().Be("422"); + errorStatusCodeProperties[1].Name.Should().Be("404"); + errorStatusCodeProperties[2].Name.Should().Be("409"); + errorStatusCodeProperties[3].Name.Should().Be("422"); errorStatusCodeProperties.Should().AllSatisfy(property => property.Value.Should().ContainPath($"content.{EscapedJsonApiMediaType}.schema.$ref").ShouldBeSchemaReferenceId("errorResponseDocument")); @@ -282,12 +283,13 @@ public async Task Forbidden_status_is_added_when_client_generated_IDs_are_disabl document.Should().ContainPath("paths./elevators.post.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(4); + errorStatusCodeProperties.ShouldHaveCount(5); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("403"); - errorStatusCodeProperties[2].Name.Should().Be("409"); - errorStatusCodeProperties[3].Name.Should().Be("422"); + errorStatusCodeProperties[2].Name.Should().Be("404"); + errorStatusCodeProperties[3].Name.Should().Be("409"); + errorStatusCodeProperties[4].Name.Should().Be("422"); errorStatusCodeProperties.Should().AllSatisfy(property => property.Value.Should().ContainPath($"content.{EscapedJsonApiMediaType}.schema.$ref").ShouldBeSchemaReferenceId("errorResponseDocument")); diff --git a/test/OpenApiTests/Headers/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/Headers/GeneratedSwagger/swagger.g.json index 224a04110b..e662a9e091 100644 --- a/test/OpenApiTests/Headers/GeneratedSwagger/swagger.g.json +++ b/test/OpenApiTests/Headers/GeneratedSwagger/swagger.g.json @@ -232,8 +232,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -957,7 +967,7 @@ } }, "404": { - "description": "The country does not exist.", + "description": "The country or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -967,7 +977,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1025,7 +1035,7 @@ } }, "404": { - "description": "The country does not exist.", + "description": "The country or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1035,7 +1045,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1093,7 +1103,7 @@ } }, "404": { - "description": "The country does not exist.", + "description": "The country or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1103,7 +1113,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1259,9 +1269,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -1601,9 +1608,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/test/OpenApiTests/Headers/HeadersDbContext.cs b/test/OpenApiTests/Headers/HeaderDbContext.cs similarity index 72% rename from test/OpenApiTests/Headers/HeadersDbContext.cs rename to test/OpenApiTests/Headers/HeaderDbContext.cs index 937ec35d27..4d697816fd 100644 --- a/test/OpenApiTests/Headers/HeadersDbContext.cs +++ b/test/OpenApiTests/Headers/HeaderDbContext.cs @@ -5,7 +5,7 @@ namespace OpenApiTests.Headers; [UsedImplicitly(ImplicitUseTargetFlags.Members)] -public sealed class HeadersDbContext(DbContextOptions options) : TestableDbContext(options) +public sealed class HeaderDbContext(DbContextOptions options) : TestableDbContext(options) { public DbSet Countries => Set(); public DbSet Languages => Set(); diff --git a/test/OpenApiTests/Headers/HeaderTests.cs b/test/OpenApiTests/Headers/HeaderTests.cs index 9da34af6cd..d900092ad2 100644 --- a/test/OpenApiTests/Headers/HeaderTests.cs +++ b/test/OpenApiTests/Headers/HeaderTests.cs @@ -5,11 +5,11 @@ namespace OpenApiTests.Headers; -public sealed class HeaderTests : IClassFixture, HeadersDbContext>> +public sealed class HeaderTests : IClassFixture, HeaderDbContext>> { - private readonly OpenApiTestContext, HeadersDbContext> _testContext; + private readonly OpenApiTestContext, HeaderDbContext> _testContext; - public HeaderTests(OpenApiTestContext, HeadersDbContext> testContext) + public HeaderTests(OpenApiTestContext, HeaderDbContext> testContext) { _testContext = testContext; diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/AircraftKind.cs b/test/OpenApiTests/LegacyOpenApi/AircraftKind.cs similarity index 77% rename from test/OpenApiTests/LegacyOpenApiIntegration/AircraftKind.cs rename to test/OpenApiTests/LegacyOpenApi/AircraftKind.cs index 6babe08323..0b0ceb63e5 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/AircraftKind.cs +++ b/test/OpenApiTests/LegacyOpenApi/AircraftKind.cs @@ -1,6 +1,6 @@ using JetBrains.Annotations; -namespace OpenApiTests.LegacyOpenApiIntegration; +namespace OpenApiTests.LegacyOpenApi; [UsedImplicitly(ImplicitUseTargetFlags.Members)] public enum AircraftKind diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/Airline.cs b/test/OpenApiTests/LegacyOpenApi/Airline.cs similarity index 83% rename from test/OpenApiTests/LegacyOpenApiIntegration/Airline.cs rename to test/OpenApiTests/LegacyOpenApi/Airline.cs index 516d419388..8a49eee69b 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/Airline.cs +++ b/test/OpenApiTests/LegacyOpenApi/Airline.cs @@ -1,6 +1,6 @@ using JetBrains.Annotations; -namespace OpenApiTests.LegacyOpenApiIntegration; +namespace OpenApiTests.LegacyOpenApi; /// /// Lists the various airlines used in this API. diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/Airplane.cs b/test/OpenApiTests/LegacyOpenApi/Airplane.cs similarity index 92% rename from test/OpenApiTests/LegacyOpenApiIntegration/Airplane.cs rename to test/OpenApiTests/LegacyOpenApi/Airplane.cs index 8ecb055c59..aa89d99f61 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/Airplane.cs +++ b/test/OpenApiTests/LegacyOpenApi/Airplane.cs @@ -3,10 +3,10 @@ using JsonApiDotNetCore.Resources; using JsonApiDotNetCore.Resources.Annotations; -namespace OpenApiTests.LegacyOpenApiIntegration; +namespace OpenApiTests.LegacyOpenApi; [UsedImplicitly(ImplicitUseTargetFlags.Members)] -[Resource(ControllerNamespace = "OpenApiTests.LegacyOpenApiIntegration")] +[Resource(ControllerNamespace = "OpenApiTests.LegacyOpenApi")] public sealed class Airplane : Identifiable { [Attr(Capabilities = AttrCapabilities.AllowView | AttrCapabilities.AllowCreate | AttrCapabilities.AllowChange)] diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/CabinArea.cs b/test/OpenApiTests/LegacyOpenApi/CabinArea.cs similarity index 76% rename from test/OpenApiTests/LegacyOpenApiIntegration/CabinArea.cs rename to test/OpenApiTests/LegacyOpenApi/CabinArea.cs index 8119a94aa1..e9c3ec151a 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/CabinArea.cs +++ b/test/OpenApiTests/LegacyOpenApi/CabinArea.cs @@ -1,6 +1,6 @@ using JetBrains.Annotations; -namespace OpenApiTests.LegacyOpenApiIntegration; +namespace OpenApiTests.LegacyOpenApi; [UsedImplicitly(ImplicitUseTargetFlags.Members)] public enum CabinArea diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/Flight.cs b/test/OpenApiTests/LegacyOpenApi/Flight.cs similarity index 91% rename from test/OpenApiTests/LegacyOpenApiIntegration/Flight.cs rename to test/OpenApiTests/LegacyOpenApi/Flight.cs index f216eee497..5baa315523 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/Flight.cs +++ b/test/OpenApiTests/LegacyOpenApi/Flight.cs @@ -4,10 +4,10 @@ using JsonApiDotNetCore.Resources; using JsonApiDotNetCore.Resources.Annotations; -namespace OpenApiTests.LegacyOpenApiIntegration; +namespace OpenApiTests.LegacyOpenApi; [UsedImplicitly(ImplicitUseTargetFlags.Members)] -[Resource(ControllerNamespace = "OpenApiTests.LegacyOpenApiIntegration")] +[Resource(ControllerNamespace = "OpenApiTests.LegacyOpenApi")] public sealed class Flight : Identifiable { [Attr(Capabilities = AttrCapabilities.AllowView | AttrCapabilities.AllowChange)] diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/FlightAttendant.cs b/test/OpenApiTests/LegacyOpenApi/FlightAttendant.cs similarity index 90% rename from test/OpenApiTests/LegacyOpenApiIntegration/FlightAttendant.cs rename to test/OpenApiTests/LegacyOpenApi/FlightAttendant.cs index 26d110ed3c..6eb6872072 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/FlightAttendant.cs +++ b/test/OpenApiTests/LegacyOpenApi/FlightAttendant.cs @@ -3,10 +3,10 @@ using JsonApiDotNetCore.Resources; using JsonApiDotNetCore.Resources.Annotations; -namespace OpenApiTests.LegacyOpenApiIntegration; +namespace OpenApiTests.LegacyOpenApi; [UsedImplicitly(ImplicitUseTargetFlags.Members)] -[Resource(ControllerNamespace = "OpenApiTests.LegacyOpenApiIntegration")] +[Resource(ControllerNamespace = "OpenApiTests.LegacyOpenApi")] public sealed class FlightAttendant : Identifiable { [Attr(Capabilities = AttrCapabilities.AllowView | AttrCapabilities.AllowFilter)] diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/FlightAttendantExpertiseLevel.cs b/test/OpenApiTests/LegacyOpenApi/FlightAttendantExpertiseLevel.cs similarity index 78% rename from test/OpenApiTests/LegacyOpenApiIntegration/FlightAttendantExpertiseLevel.cs rename to test/OpenApiTests/LegacyOpenApi/FlightAttendantExpertiseLevel.cs index b5e799eb4b..cb5f276014 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/FlightAttendantExpertiseLevel.cs +++ b/test/OpenApiTests/LegacyOpenApi/FlightAttendantExpertiseLevel.cs @@ -1,6 +1,6 @@ using JetBrains.Annotations; -namespace OpenApiTests.LegacyOpenApiIntegration; +namespace OpenApiTests.LegacyOpenApi; [UsedImplicitly(ImplicitUseTargetFlags.Members)] public enum FlightAttendantExpertiseLevel diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/LegacyOpenApi/GeneratedSwagger/swagger.g.json similarity index 97% rename from test/OpenApiTests/LegacyOpenApiIntegration/GeneratedSwagger/swagger.g.json rename to test/OpenApiTests/LegacyOpenApi/GeneratedSwagger/swagger.g.json index fb074c86b6..d7fc51f676 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/GeneratedSwagger/swagger.g.json +++ b/test/OpenApiTests/LegacyOpenApi/GeneratedSwagger/swagger.g.json @@ -232,8 +232,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/error-response-document" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -957,7 +967,7 @@ } }, "404": { - "description": "The airplane does not exist.", + "description": "The airplane or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -967,7 +977,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1025,7 +1035,7 @@ } }, "404": { - "description": "The airplane does not exist.", + "description": "The airplane or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1035,7 +1045,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1093,7 +1103,7 @@ } }, "404": { - "description": "The airplane does not exist.", + "description": "The airplane or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1103,7 +1113,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1337,8 +1347,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/error-response-document" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2062,7 +2082,7 @@ } }, "404": { - "description": "The flight-attendant does not exist.", + "description": "The flight-attendant or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2072,7 +2092,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2130,7 +2150,7 @@ } }, "404": { - "description": "The flight-attendant does not exist.", + "description": "The flight-attendant or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2140,7 +2160,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2198,7 +2218,7 @@ } }, "404": { - "description": "The flight-attendant does not exist.", + "description": "The flight-attendant or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2208,7 +2228,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2614,7 +2634,7 @@ } }, "404": { - "description": "The flight-attendant does not exist.", + "description": "The flight-attendant or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2624,7 +2644,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2682,7 +2702,7 @@ } }, "404": { - "description": "The flight-attendant does not exist.", + "description": "The flight-attendant or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2692,7 +2712,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2750,7 +2770,7 @@ } }, "404": { - "description": "The flight-attendant does not exist.", + "description": "The flight-attendant or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2760,7 +2780,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2994,8 +3014,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/error-response-document" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3719,7 +3749,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -3729,7 +3759,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4135,7 +4165,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4145,7 +4175,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4203,7 +4233,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4213,7 +4243,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4271,7 +4301,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4281,7 +4311,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4687,7 +4717,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4697,7 +4727,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4755,7 +4785,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4765,7 +4795,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4823,7 +4853,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4833,7 +4863,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -5239,7 +5269,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -5249,7 +5279,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -5483,8 +5513,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/error-response-document" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -6047,9 +6087,6 @@ "$ref": "#/components/schemas/data-in-response" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -6532,9 +6569,6 @@ "$ref": "#/components/schemas/data-in-response" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -7009,9 +7043,6 @@ "$ref": "#/components/schemas/data-in-response" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -7727,9 +7758,6 @@ "$ref": "#/components/schemas/data-in-response" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/LegacyIntegrationDbContext.cs b/test/OpenApiTests/LegacyOpenApi/LegacyIntegrationDbContext.cs similarity index 95% rename from test/OpenApiTests/LegacyOpenApiIntegration/LegacyIntegrationDbContext.cs rename to test/OpenApiTests/LegacyOpenApi/LegacyIntegrationDbContext.cs index 94d3ed798b..045feae51b 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/LegacyIntegrationDbContext.cs +++ b/test/OpenApiTests/LegacyOpenApi/LegacyIntegrationDbContext.cs @@ -4,7 +4,7 @@ // @formatter:wrap_chained_method_calls chop_always -namespace OpenApiTests.LegacyOpenApiIntegration; +namespace OpenApiTests.LegacyOpenApi; [UsedImplicitly(ImplicitUseTargetFlags.Members)] public sealed class LegacyIntegrationDbContext(DbContextOptions options) : TestableDbContext(options) diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/LegacyOpenApiIntegrationStartup.cs b/test/OpenApiTests/LegacyOpenApi/LegacyStartup.cs similarity index 84% rename from test/OpenApiTests/LegacyOpenApiIntegration/LegacyOpenApiIntegrationStartup.cs rename to test/OpenApiTests/LegacyOpenApi/LegacyStartup.cs index 2cfa28ebf6..0888be0e1c 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/LegacyOpenApiIntegrationStartup.cs +++ b/test/OpenApiTests/LegacyOpenApi/LegacyStartup.cs @@ -2,12 +2,13 @@ using JetBrains.Annotations; using JsonApiDotNetCore.Configuration; using JsonApiDotNetCore.Resources.Annotations; +using OpenApiTests.NamingConventions.KebabCase; using TestBuildingBlocks; -namespace OpenApiTests.LegacyOpenApiIntegration; +namespace OpenApiTests.LegacyOpenApi; [UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)] -public sealed class LegacyOpenApiIntegrationStartup : OpenApiStartup +public sealed class LegacyStartup : OpenApiStartup where TDbContext : TestableDbContext { protected override void SetJsonApiOptions(JsonApiOptions options) diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/LegacyOpenApiIntegrationTests.cs b/test/OpenApiTests/LegacyOpenApi/LegacyTests.cs similarity index 83% rename from test/OpenApiTests/LegacyOpenApiIntegration/LegacyOpenApiIntegrationTests.cs rename to test/OpenApiTests/LegacyOpenApi/LegacyTests.cs index 2a98ceb6b7..6ea752c9e5 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/LegacyOpenApiIntegrationTests.cs +++ b/test/OpenApiTests/LegacyOpenApi/LegacyTests.cs @@ -4,11 +4,11 @@ using TestBuildingBlocks; using Xunit; -namespace OpenApiTests.LegacyOpenApiIntegration; +namespace OpenApiTests.LegacyOpenApi; -public sealed class LegacyOpenApiIntegrationTests : OpenApiTestContext, LegacyIntegrationDbContext> +public sealed class LegacyTests : OpenApiTestContext, LegacyIntegrationDbContext> { - public LegacyOpenApiIntegrationTests() + public LegacyTests() { UseController(); UseController(); @@ -32,7 +32,7 @@ public async Task Retrieved_swagger_document_matches_expected_document() private async Task GetExpectedSwaggerDocumentAsync() { - string embeddedResourceName = $"{GetType().Namespace!.Replace('/', '.')}.swagger.json"; + string embeddedResourceName = $"{GetType().Namespace!.Replace('/', '.')}.expected-swagger.json"; var assembly = Assembly.GetExecutingAssembly(); await using Stream? stream = assembly.GetManifestResourceStream(embeddedResourceName); diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/Passenger.cs b/test/OpenApiTests/LegacyOpenApi/Passenger.cs similarity index 82% rename from test/OpenApiTests/LegacyOpenApiIntegration/Passenger.cs rename to test/OpenApiTests/LegacyOpenApi/Passenger.cs index 2a8e142d41..c939562447 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/Passenger.cs +++ b/test/OpenApiTests/LegacyOpenApi/Passenger.cs @@ -3,10 +3,10 @@ using JsonApiDotNetCore.Resources; using JsonApiDotNetCore.Resources.Annotations; -namespace OpenApiTests.LegacyOpenApiIntegration; +namespace OpenApiTests.LegacyOpenApi; [UsedImplicitly(ImplicitUseTargetFlags.Members)] -[Resource(ControllerNamespace = "OpenApiTests.LegacyOpenApiIntegration")] +[Resource(ControllerNamespace = "OpenApiTests.LegacyOpenApi")] public sealed class Passenger : Identifiable { [Attr(PublicName = "document-number", Capabilities = AttrCapabilities.AllowCreate | AttrCapabilities.AllowChange)] diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json b/test/OpenApiTests/LegacyOpenApi/expected-swagger.json similarity index 97% rename from test/OpenApiTests/LegacyOpenApiIntegration/swagger.json rename to test/OpenApiTests/LegacyOpenApi/expected-swagger.json index fb074c86b6..d7fc51f676 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json +++ b/test/OpenApiTests/LegacyOpenApi/expected-swagger.json @@ -232,8 +232,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/error-response-document" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -957,7 +967,7 @@ } }, "404": { - "description": "The airplane does not exist.", + "description": "The airplane or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -967,7 +977,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1025,7 +1035,7 @@ } }, "404": { - "description": "The airplane does not exist.", + "description": "The airplane or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1035,7 +1045,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1093,7 +1103,7 @@ } }, "404": { - "description": "The airplane does not exist.", + "description": "The airplane or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1103,7 +1113,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1337,8 +1347,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/error-response-document" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2062,7 +2082,7 @@ } }, "404": { - "description": "The flight-attendant does not exist.", + "description": "The flight-attendant or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2072,7 +2092,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2130,7 +2150,7 @@ } }, "404": { - "description": "The flight-attendant does not exist.", + "description": "The flight-attendant or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2140,7 +2160,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2198,7 +2218,7 @@ } }, "404": { - "description": "The flight-attendant does not exist.", + "description": "The flight-attendant or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2208,7 +2228,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2614,7 +2634,7 @@ } }, "404": { - "description": "The flight-attendant does not exist.", + "description": "The flight-attendant or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2624,7 +2644,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2682,7 +2702,7 @@ } }, "404": { - "description": "The flight-attendant does not exist.", + "description": "The flight-attendant or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2692,7 +2712,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2750,7 +2770,7 @@ } }, "404": { - "description": "The flight-attendant does not exist.", + "description": "The flight-attendant or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2760,7 +2780,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2994,8 +3014,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/error-response-document" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3719,7 +3749,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -3729,7 +3759,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4135,7 +4165,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4145,7 +4175,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4203,7 +4233,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4213,7 +4243,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4271,7 +4301,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4281,7 +4311,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4687,7 +4717,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4697,7 +4727,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4755,7 +4785,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4765,7 +4795,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -4823,7 +4853,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -4833,7 +4863,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -5239,7 +5269,7 @@ } }, "404": { - "description": "The flight does not exist.", + "description": "The flight or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -5249,7 +5279,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -5483,8 +5513,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/error-response-document" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -6047,9 +6087,6 @@ "$ref": "#/components/schemas/data-in-response" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -6532,9 +6569,6 @@ "$ref": "#/components/schemas/data-in-response" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -7009,9 +7043,6 @@ "$ref": "#/components/schemas/data-in-response" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -7727,9 +7758,6 @@ "$ref": "#/components/schemas/data-in-response" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/test/OpenApiTests/NamingConventions/CamelCase/CamelCaseTests.cs b/test/OpenApiTests/NamingConventions/CamelCase/CamelCaseTests.cs index 1bb2772a08..12228c8175 100644 --- a/test/OpenApiTests/NamingConventions/CamelCase/CamelCaseTests.cs +++ b/test/OpenApiTests/NamingConventions/CamelCase/CamelCaseTests.cs @@ -4,11 +4,11 @@ namespace OpenApiTests.NamingConventions.CamelCase; -public sealed class CamelCaseTests : IClassFixture, NamingConventionsDbContext>> +public sealed class CamelCaseTests : IClassFixture, NamingConventionDbContext>> { - private readonly OpenApiTestContext, NamingConventionsDbContext> _testContext; + private readonly OpenApiTestContext, NamingConventionDbContext> _testContext; - public CamelCaseTests(OpenApiTestContext, NamingConventionsDbContext> testContext) + public CamelCaseTests(OpenApiTestContext, NamingConventionDbContext> testContext) { _testContext = testContext; diff --git a/test/OpenApiTests/NamingConventions/CamelCase/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/NamingConventions/CamelCase/GeneratedSwagger/swagger.g.json index a00ea9ca73..e401b02fc8 100644 --- a/test/OpenApiTests/NamingConventions/CamelCase/GeneratedSwagger/swagger.g.json +++ b/test/OpenApiTests/NamingConventions/CamelCase/GeneratedSwagger/swagger.g.json @@ -232,8 +232,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -785,8 +795,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1510,7 +1530,7 @@ } }, "404": { - "description": "The supermarket does not exist.", + "description": "The supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1520,7 +1540,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1926,7 +1946,7 @@ } }, "404": { - "description": "The supermarket does not exist.", + "description": "The supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1936,7 +1956,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1994,7 +2014,7 @@ } }, "404": { - "description": "The supermarket does not exist.", + "description": "The supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2004,7 +2024,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2062,7 +2082,7 @@ } }, "404": { - "description": "The supermarket does not exist.", + "description": "The supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2072,7 +2092,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2478,7 +2498,7 @@ } }, "404": { - "description": "The supermarket does not exist.", + "description": "The supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2488,7 +2508,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3083,9 +3103,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -3491,9 +3508,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/test/OpenApiTests/NamingConventions/KebabCase/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/NamingConventions/KebabCase/GeneratedSwagger/swagger.g.json index c320df0472..d2667bfc59 100644 --- a/test/OpenApiTests/NamingConventions/KebabCase/GeneratedSwagger/swagger.g.json +++ b/test/OpenApiTests/NamingConventions/KebabCase/GeneratedSwagger/swagger.g.json @@ -232,8 +232,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/error-response-document" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -785,8 +795,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/error-response-document" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1510,7 +1530,7 @@ } }, "404": { - "description": "The supermarket does not exist.", + "description": "The supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1520,7 +1540,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1926,7 +1946,7 @@ } }, "404": { - "description": "The supermarket does not exist.", + "description": "The supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1936,7 +1956,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1994,7 +2014,7 @@ } }, "404": { - "description": "The supermarket does not exist.", + "description": "The supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2004,7 +2024,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2062,7 +2082,7 @@ } }, "404": { - "description": "The supermarket does not exist.", + "description": "The supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2072,7 +2092,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2478,7 +2498,7 @@ } }, "404": { - "description": "The supermarket does not exist.", + "description": "The supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2488,7 +2508,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3083,9 +3103,6 @@ "$ref": "#/components/schemas/data-in-response" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -3491,9 +3508,6 @@ "$ref": "#/components/schemas/data-in-response" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/JsonKebabCaseNamingPolicy.cs b/test/OpenApiTests/NamingConventions/KebabCase/JsonKebabCaseNamingPolicy.cs similarity index 98% rename from test/OpenApiTests/LegacyOpenApiIntegration/JsonKebabCaseNamingPolicy.cs rename to test/OpenApiTests/NamingConventions/KebabCase/JsonKebabCaseNamingPolicy.cs index 0e0d76afe5..51b059a36d 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/JsonKebabCaseNamingPolicy.cs +++ b/test/OpenApiTests/NamingConventions/KebabCase/JsonKebabCaseNamingPolicy.cs @@ -1,7 +1,7 @@ using System.Text; using System.Text.Json; -namespace OpenApiTests.LegacyOpenApiIntegration; +namespace OpenApiTests.NamingConventions.KebabCase; // Based on https://github.com/J0rgeSerran0/JsonNamingPolicy internal sealed class JsonKebabCaseNamingPolicy : JsonNamingPolicy diff --git a/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseNamingConventionStartup.cs b/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseNamingConventionStartup.cs index b3cba0120b..cacd639813 100644 --- a/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseNamingConventionStartup.cs +++ b/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseNamingConventionStartup.cs @@ -1,7 +1,6 @@ using System.Text.Json.Serialization; using JetBrains.Annotations; using JsonApiDotNetCore.Configuration; -using OpenApiTests.LegacyOpenApiIntegration; using TestBuildingBlocks; namespace OpenApiTests.NamingConventions.KebabCase; diff --git a/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseTests.cs b/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseTests.cs index 95901620d2..9bf498941f 100644 --- a/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseTests.cs +++ b/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseTests.cs @@ -4,11 +4,11 @@ namespace OpenApiTests.NamingConventions.KebabCase; -public sealed class KebabCaseTests : IClassFixture, NamingConventionsDbContext>> +public sealed class KebabCaseTests : IClassFixture, NamingConventionDbContext>> { - private readonly OpenApiTestContext, NamingConventionsDbContext> _testContext; + private readonly OpenApiTestContext, NamingConventionDbContext> _testContext; - public KebabCaseTests(OpenApiTestContext, NamingConventionsDbContext> testContext) + public KebabCaseTests(OpenApiTestContext, NamingConventionDbContext> testContext) { _testContext = testContext; diff --git a/test/OpenApiTests/NamingConventions/NamingConventionsDbContext.cs b/test/OpenApiTests/NamingConventions/NamingConventionDbContext.cs similarity index 66% rename from test/OpenApiTests/NamingConventions/NamingConventionsDbContext.cs rename to test/OpenApiTests/NamingConventions/NamingConventionDbContext.cs index 68d5411da1..1f2dce6bc3 100644 --- a/test/OpenApiTests/NamingConventions/NamingConventionsDbContext.cs +++ b/test/OpenApiTests/NamingConventions/NamingConventionDbContext.cs @@ -5,7 +5,7 @@ namespace OpenApiTests.NamingConventions; [UsedImplicitly(ImplicitUseTargetFlags.Members)] -public sealed class NamingConventionsDbContext(DbContextOptions options) : TestableDbContext(options) +public sealed class NamingConventionDbContext(DbContextOptions options) : TestableDbContext(options) { public DbSet Supermarkets => Set(); } diff --git a/test/OpenApiTests/NamingConventions/PascalCase/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/NamingConventions/PascalCase/GeneratedSwagger/swagger.g.json index e14fb2afb7..525d72722b 100644 --- a/test/OpenApiTests/NamingConventions/PascalCase/GeneratedSwagger/swagger.g.json +++ b/test/OpenApiTests/NamingConventions/PascalCase/GeneratedSwagger/swagger.g.json @@ -232,8 +232,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -785,8 +795,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1510,7 +1530,7 @@ } }, "404": { - "description": "The Supermarket does not exist.", + "description": "The Supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1520,7 +1540,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1926,7 +1946,7 @@ } }, "404": { - "description": "The Supermarket does not exist.", + "description": "The Supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1936,7 +1956,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1994,7 +2014,7 @@ } }, "404": { - "description": "The Supermarket does not exist.", + "description": "The Supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2004,7 +2024,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2062,7 +2082,7 @@ } }, "404": { - "description": "The Supermarket does not exist.", + "description": "The Supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2072,7 +2092,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2478,7 +2498,7 @@ } }, "404": { - "description": "The Supermarket does not exist.", + "description": "The Supermarket or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2488,7 +2508,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3083,9 +3103,6 @@ "$ref": "#/components/schemas/DataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -3491,9 +3508,6 @@ "$ref": "#/components/schemas/DataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/test/OpenApiTests/NamingConventions/PascalCase/PascalCaseTests.cs b/test/OpenApiTests/NamingConventions/PascalCase/PascalCaseTests.cs index 7484ff12c5..f2a26415cd 100644 --- a/test/OpenApiTests/NamingConventions/PascalCase/PascalCaseTests.cs +++ b/test/OpenApiTests/NamingConventions/PascalCase/PascalCaseTests.cs @@ -4,12 +4,11 @@ namespace OpenApiTests.NamingConventions.PascalCase; -public sealed class PascalCaseTests - : IClassFixture, NamingConventionsDbContext>> +public sealed class PascalCaseTests : IClassFixture, NamingConventionDbContext>> { - private readonly OpenApiTestContext, NamingConventionsDbContext> _testContext; + private readonly OpenApiTestContext, NamingConventionDbContext> _testContext; - public PascalCaseTests(OpenApiTestContext, NamingConventionsDbContext> testContext) + public PascalCaseTests(OpenApiTestContext, NamingConventionDbContext> testContext) { _testContext = testContext; diff --git a/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyDbContext.cs b/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyDbContext.cs new file mode 100644 index 0000000000..3cdbca50e1 --- /dev/null +++ b/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyDbContext.cs @@ -0,0 +1,11 @@ +using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore; +using TestBuildingBlocks; + +namespace OpenApiTests.OpenApiGenerationFailures.MissingFromBody; + +[UsedImplicitly(ImplicitUseTargetFlags.Members)] +public sealed class MissingFromBodyDbContext(DbContextOptions options) : TestableDbContext(options) +{ + public DbSet RecycleBins => Set(); +} diff --git a/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyOnPatchController.cs b/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyOnPatchController.cs new file mode 100644 index 0000000000..69f117c619 --- /dev/null +++ b/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyOnPatchController.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; +using JsonApiDotNetCore.Configuration; +using JsonApiDotNetCore.Controllers; +using JsonApiDotNetCore.Services; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace OpenApiTests.OpenApiGenerationFailures.MissingFromBody; + +public sealed class MissingFromBodyOnPatchController( + IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IResourceService resourceService) + : BaseJsonApiController(options, resourceGraph, loggerFactory, resourceService) +{ + // Not overriding the base method, to trigger the error that [FromBody] is missing. + [HttpPatch("{id}")] + public Task AlternatePatchAsync([Required] long id, [Required] RecycleBin resource, CancellationToken cancellationToken) + { + return PatchAsync(id, resource, cancellationToken); + } +} diff --git a/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyOnPatchMethodTests.cs b/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyOnPatchMethodTests.cs new file mode 100644 index 0000000000..b988ebc343 --- /dev/null +++ b/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyOnPatchMethodTests.cs @@ -0,0 +1,27 @@ +using FluentAssertions; +using JsonApiDotNetCore.Errors; +using Xunit; + +namespace OpenApiTests.OpenApiGenerationFailures.MissingFromBody; + +public sealed class MissingFromBodyOnPatchMethodTests : OpenApiTestContext, MissingFromBodyDbContext> +{ + public MissingFromBodyOnPatchMethodTests() + { + UseController(); + } + + [Fact] + public async Task Cannot_use_Patch_controller_action_method_without_FromBody_attribute() + { + // Act + Func action = async () => _ = await GetSwaggerDocumentAsync(); + + // Assert + string? actionMethod = typeof(MissingFromBodyOnPatchController).GetMethod(nameof(MissingFromBodyOnPatchController.AlternatePatchAsync))!.ToString(); + string containingType = typeof(MissingFromBodyOnPatchController).ToString(); + + await action.Should().ThrowExactlyAsync().WithMessage( + $"The action method '{actionMethod}' on type '{containingType}' contains no parameter with a [FromBody] attribute."); + } +} diff --git a/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyOnPostController.cs b/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyOnPostController.cs new file mode 100644 index 0000000000..479d95db40 --- /dev/null +++ b/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyOnPostController.cs @@ -0,0 +1,19 @@ +using JsonApiDotNetCore.Configuration; +using JsonApiDotNetCore.Controllers; +using JsonApiDotNetCore.Services; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace OpenApiTests.OpenApiGenerationFailures.MissingFromBody; + +public sealed class MissingFromBodyOnPostController( + IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IResourceService resourceService) + : BaseJsonApiController(options, resourceGraph, loggerFactory, resourceService) +{ + // Not overriding the base method, to trigger the error that [FromBody] is missing. + [HttpPost] + public Task AlternatePostAsync(RecycleBin resource, CancellationToken cancellationToken) + { + return PostAsync(resource, cancellationToken); + } +} diff --git a/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyOnPostMethodTests.cs b/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyOnPostMethodTests.cs new file mode 100644 index 0000000000..5725cc732f --- /dev/null +++ b/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/MissingFromBodyOnPostMethodTests.cs @@ -0,0 +1,27 @@ +using FluentAssertions; +using JsonApiDotNetCore.Errors; +using Xunit; + +namespace OpenApiTests.OpenApiGenerationFailures.MissingFromBody; + +public sealed class MissingFromBodyOnPostMethodTests : OpenApiTestContext, MissingFromBodyDbContext> +{ + public MissingFromBodyOnPostMethodTests() + { + UseController(); + } + + [Fact] + public async Task Cannot_use_Post_controller_action_method_without_FromBody_attribute() + { + // Act + Func action = async () => _ = await GetSwaggerDocumentAsync(); + + // Assert + string? actionMethod = typeof(MissingFromBodyOnPostController).GetMethod(nameof(MissingFromBodyOnPostController.AlternatePostAsync))!.ToString(); + string containingType = typeof(MissingFromBodyOnPostController).ToString(); + + await action.Should().ThrowExactlyAsync().WithMessage( + $"The action method '{actionMethod}' on type '{containingType}' contains no parameter with a [FromBody] attribute."); + } +} diff --git a/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/RecycleBin.cs b/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/RecycleBin.cs new file mode 100644 index 0000000000..51df92e0da --- /dev/null +++ b/test/OpenApiTests/OpenApiGenerationFailures/MissingFromBody/RecycleBin.cs @@ -0,0 +1,14 @@ +using JetBrains.Annotations; +using JsonApiDotNetCore.Controllers; +using JsonApiDotNetCore.Resources; +using JsonApiDotNetCore.Resources.Annotations; + +namespace OpenApiTests.OpenApiGenerationFailures.MissingFromBody; + +[UsedImplicitly(ImplicitUseTargetFlags.Members)] +[Resource(ControllerNamespace = "OpenApiTests.OpenApiGenerationFailures.MissingFromBody", GenerateControllerEndpoints = JsonApiEndpoints.None)] +public sealed class RecycleBin : Identifiable +{ + [Attr] + public bool IsEmpty { get; set; } +} diff --git a/test/OpenApiTests/OpenApiTestContext.cs b/test/OpenApiTests/OpenApiTestContext.cs index 6406a1a763..6522dfc4e8 100644 --- a/test/OpenApiTests/OpenApiTestContext.cs +++ b/test/OpenApiTests/OpenApiTestContext.cs @@ -19,9 +19,9 @@ public OpenApiTestContext() _lazySwaggerDocument = new Lazy>(CreateSwaggerDocumentAsync, LazyThreadSafetyMode.ExecutionAndPublication); } - internal Task GetSwaggerDocumentAsync() + internal async Task GetSwaggerDocumentAsync() { - return _lazySwaggerDocument.Value; + return await _lazySwaggerDocument.Value; } private async Task CreateSwaggerDocumentAsync() @@ -63,12 +63,12 @@ private static JsonElement ParseSwaggerDocument(string content) return jsonDocument.RootElement.Clone(); } - private static Task WriteToDiskAsync(string path, JsonElement jsonElement) + private static async Task WriteToDiskAsync(string path, JsonElement jsonElement) { string directory = Path.GetDirectoryName(path)!; Directory.CreateDirectory(directory); string contents = jsonElement.ToString(); - return File.WriteAllTextAsync(path, contents); + await File.WriteAllTextAsync(path, contents); } } diff --git a/test/OpenApiTests/OpenApiTests.csproj b/test/OpenApiTests/OpenApiTests.csproj index 0ca411ea1a..111a345368 100644 --- a/test/OpenApiTests/OpenApiTests.csproj +++ b/test/OpenApiTests/OpenApiTests.csproj @@ -8,7 +8,7 @@ - + diff --git a/test/OpenApiTests/QueryStrings/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/QueryStrings/GeneratedSwagger/swagger.g.json index 68a284eaeb..dda7bdd0d4 100644 --- a/test/OpenApiTests/QueryStrings/GeneratedSwagger/swagger.g.json +++ b/test/OpenApiTests/QueryStrings/GeneratedSwagger/swagger.g.json @@ -232,8 +232,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -957,7 +967,7 @@ } }, "404": { - "description": "The nameValuePair does not exist.", + "description": "The nameValuePair or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -967,7 +977,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1201,8 +1211,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1926,7 +1946,7 @@ } }, "404": { - "description": "The node does not exist.", + "description": "The node or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1936,7 +1956,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1994,7 +2014,7 @@ } }, "404": { - "description": "The node does not exist.", + "description": "The node or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2004,7 +2024,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2062,7 +2082,7 @@ } }, "404": { - "description": "The node does not exist.", + "description": "The node or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2072,7 +2092,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2478,7 +2498,7 @@ } }, "404": { - "description": "The node does not exist.", + "description": "The node or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2488,7 +2508,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2894,7 +2914,7 @@ } }, "404": { - "description": "The node does not exist.", + "description": "The node or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2904,7 +2924,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2962,7 +2982,7 @@ } }, "404": { - "description": "The node does not exist.", + "description": "The node or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2972,7 +2992,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3030,7 +3050,7 @@ } }, "404": { - "description": "The node does not exist.", + "description": "The node or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -3040,7 +3060,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3475,9 +3495,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { @@ -3820,9 +3837,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/test/OpenApiTests/QueryStrings/IncludeTests.cs b/test/OpenApiTests/QueryStrings/IncludeTests.cs index 3151562da0..b3f90e0223 100644 --- a/test/OpenApiTests/QueryStrings/IncludeTests.cs +++ b/test/OpenApiTests/QueryStrings/IncludeTests.cs @@ -12,11 +12,11 @@ namespace OpenApiTests.QueryStrings; -public sealed class IncludeTests : IClassFixture, QueryStringsDbContext>> +public sealed class IncludeTests : IClassFixture, QueryStringDbContext>> { - private readonly OpenApiTestContext, QueryStringsDbContext> _testContext; + private readonly OpenApiTestContext, QueryStringDbContext> _testContext; - public IncludeTests(OpenApiTestContext, QueryStringsDbContext> testContext) + public IncludeTests(OpenApiTestContext, QueryStringDbContext> testContext) { _testContext = testContext; diff --git a/test/OpenApiTests/QueryStrings/QueryStringsDbContext.cs b/test/OpenApiTests/QueryStrings/QueryStringDbContext.cs similarity index 65% rename from test/OpenApiTests/QueryStrings/QueryStringsDbContext.cs rename to test/OpenApiTests/QueryStrings/QueryStringDbContext.cs index 89b10e07ae..369b31aac8 100644 --- a/test/OpenApiTests/QueryStrings/QueryStringsDbContext.cs +++ b/test/OpenApiTests/QueryStrings/QueryStringDbContext.cs @@ -5,7 +5,7 @@ namespace OpenApiTests.QueryStrings; [UsedImplicitly(ImplicitUseTargetFlags.Members)] -public sealed class QueryStringsDbContext(DbContextOptions options) : TestableDbContext(options) +public sealed class QueryStringDbContext(DbContextOptions options) : TestableDbContext(options) { public DbSet Nodes => Set(); } diff --git a/test/OpenApiTests/QueryStrings/QueryStringTests.cs b/test/OpenApiTests/QueryStrings/QueryStringTests.cs index 6f1d11f3b9..f26f3833f5 100644 --- a/test/OpenApiTests/QueryStrings/QueryStringTests.cs +++ b/test/OpenApiTests/QueryStrings/QueryStringTests.cs @@ -5,11 +5,11 @@ namespace OpenApiTests.QueryStrings; -public sealed class QueryStringTests : IClassFixture, QueryStringsDbContext>> +public sealed class QueryStringTests : IClassFixture, QueryStringDbContext>> { - private readonly OpenApiTestContext, QueryStringsDbContext> _testContext; + private readonly OpenApiTestContext, QueryStringDbContext> _testContext; - public QueryStringTests(OpenApiTestContext, QueryStringsDbContext> testContext) + public QueryStringTests(OpenApiTestContext, QueryStringDbContext> testContext) { _testContext = testContext; diff --git a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedSwagger/swagger.g.json index 80872daa7a..0b4d36d5cb 100644 --- a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedSwagger/swagger.g.json +++ b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedSwagger/swagger.g.json @@ -232,8 +232,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -957,7 +967,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -967,7 +977,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1025,7 +1035,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1035,7 +1045,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1093,7 +1103,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1103,7 +1113,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1509,7 +1519,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1519,7 +1529,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1925,7 +1935,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1935,7 +1945,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1993,7 +2003,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2003,7 +2013,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2061,7 +2071,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2071,7 +2081,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2477,7 +2487,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2487,7 +2497,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2570,9 +2580,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "links": { @@ -3223,9 +3230,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedSwagger/swagger.g.json index e4ca77d48e..2e672ba839 100644 --- a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedSwagger/swagger.g.json +++ b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedSwagger/swagger.g.json @@ -232,8 +232,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -957,7 +967,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -967,7 +977,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1025,7 +1035,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1035,7 +1045,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1093,7 +1103,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1103,7 +1113,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1509,7 +1519,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1519,7 +1529,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1925,7 +1935,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1935,7 +1945,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1993,7 +2003,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2003,7 +2013,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2061,7 +2071,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2071,7 +2081,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2477,7 +2487,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2487,7 +2497,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2570,9 +2580,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "links": { @@ -3284,9 +3291,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedSwagger/swagger.g.json index 5cc11103e5..9fb09e388e 100644 --- a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedSwagger/swagger.g.json +++ b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedSwagger/swagger.g.json @@ -232,8 +232,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -957,7 +967,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -967,7 +977,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1373,7 +1383,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1383,7 +1393,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1789,7 +1799,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1799,7 +1809,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2205,7 +2215,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2215,7 +2225,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2621,7 +2631,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2631,7 +2641,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2689,7 +2699,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2699,7 +2709,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2757,7 +2767,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2767,7 +2777,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3173,7 +3183,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -3183,7 +3193,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3241,7 +3251,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -3251,7 +3261,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3309,7 +3319,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -3319,7 +3329,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3402,9 +3412,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "links": { @@ -4145,9 +4152,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedSwagger/swagger.g.json index ffe5d36cb9..5e7dc9e510 100644 --- a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedSwagger/swagger.g.json +++ b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedSwagger/swagger.g.json @@ -232,8 +232,18 @@ } } }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -957,7 +967,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -967,7 +977,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1373,7 +1383,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1383,7 +1393,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -1789,7 +1799,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -1799,7 +1809,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2205,7 +2215,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2215,7 +2225,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2621,7 +2631,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2631,7 +2641,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2689,7 +2699,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2699,7 +2709,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -2757,7 +2767,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -2767,7 +2777,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3173,7 +3183,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -3183,7 +3193,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3241,7 +3251,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -3251,7 +3261,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3309,7 +3319,7 @@ } }, "404": { - "description": "The resource does not exist.", + "description": "The resource or a related resource does not exist.", "content": { "application/vnd.api+json": { "schema": { @@ -3319,7 +3329,7 @@ } }, "409": { - "description": "A resource type in the request body is incompatible.", + "description": "The request body contains conflicting information or another resource with the same ID already exists.", "content": { "application/vnd.api+json": { "schema": { @@ -3402,9 +3412,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "links": { @@ -4139,9 +4146,6 @@ "$ref": "#/components/schemas/dataInResponse" }, { - "required": [ - "links" - ], "type": "object", "properties": { "attributes": { diff --git a/test/OpenApiTests/RestrictedControllers/Channel.cs b/test/OpenApiTests/RestrictedControllers/Channel.cs index 870029d218..a91555582d 100644 --- a/test/OpenApiTests/RestrictedControllers/Channel.cs +++ b/test/OpenApiTests/RestrictedControllers/Channel.cs @@ -10,9 +10,18 @@ public abstract class Channel : Identifiable [Attr] public string? Name { get; set; } + [Attr] + public bool? IsCommercial { get; set; } + + [Attr] + public bool? IsAdultOnly { get; set; } + [HasOne] public DataStream VideoStream { get; set; } = null!; + [HasOne] + public DataStream? UltraHighDefinitionVideoStream { get; set; } + [HasMany] public ISet AudioStreams { get; set; } = new HashSet(); } diff --git a/test/OpenApiTests/RestrictedControllers/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/RestrictedControllers/GeneratedSwagger/swagger.g.json new file mode 100644 index 0000000000..1be450439a --- /dev/null +++ b/test/OpenApiTests/RestrictedControllers/GeneratedSwagger/swagger.g.json @@ -0,0 +1,5355 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenApiTests", + "version": "1.0" + }, + "servers": [ + { + "url": "http://localhost" + } + ], + "paths": { + "/dataStreams": { + "get": { + "tags": [ + "dataStreams" + ], + "summary": "Retrieves a collection of dataStreams.", + "operationId": "getDataStreamCollection", + "parameters": [ + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStreams, or an empty array if none were found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/dataStreamCollectionResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "dataStreams" + ], + "summary": "Retrieves a collection of dataStreams without returning them.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headDataStreamCollection", + "parameters": [ + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + } + } + } + }, + "/dataStreams/{id}": { + "get": { + "tags": [ + "dataStreams" + ], + "summary": "Retrieves an individual dataStream by its identifier.", + "operationId": "getDataStream", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the dataStream to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStream.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/dataStreamPrimaryResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The dataStream does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "dataStreams" + ], + "summary": "Retrieves an individual dataStream by its identifier without returning it.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headDataStream", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the dataStream to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The dataStream does not exist." + } + } + } + }, + "/readOnlyChannels": { + "get": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves a collection of readOnlyChannels.", + "operationId": "getReadOnlyChannelCollection", + "parameters": [ + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found readOnlyChannels, or an empty array if none were found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/readOnlyChannelCollectionResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves a collection of readOnlyChannels without returning them.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyChannelCollection", + "parameters": [ + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + } + } + } + }, + "/readOnlyChannels/{id}": { + "get": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves an individual readOnlyChannel by its identifier.", + "operationId": "getReadOnlyChannel", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found readOnlyChannel.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/readOnlyChannelPrimaryResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The readOnlyChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves an individual readOnlyChannel by its identifier without returning it.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyChannel", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The readOnlyChannel does not exist." + } + } + } + }, + "/readOnlyChannels/{id}/audioStreams": { + "get": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves the related dataStreams of an individual readOnlyChannel's audioStreams relationship.", + "operationId": "getReadOnlyChannelAudioStreams", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel whose related dataStreams to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStreams, or an empty array if none were found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/dataStreamCollectionResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The readOnlyChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves the related dataStreams of an individual readOnlyChannel's audioStreams relationship without returning them.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyChannelAudioStreams", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel whose related dataStreams to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The readOnlyChannel does not exist." + } + } + } + }, + "/readOnlyChannels/{id}/relationships/audioStreams": { + "get": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves the related dataStream identities of an individual readOnlyChannel's audioStreams relationship.", + "operationId": "getReadOnlyChannelAudioStreamsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel whose related dataStream identities to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStream identities, or an empty array if none were found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/dataStreamIdentifierCollectionResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The readOnlyChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves the related dataStream identities of an individual readOnlyChannel's audioStreams relationship without returning them.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyChannelAudioStreamsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel whose related dataStream identities to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The readOnlyChannel does not exist." + } + } + } + }, + "/readOnlyChannels/{id}/ultraHighDefinitionVideoStream": { + "get": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves the related dataStream of an individual readOnlyChannel's ultraHighDefinitionVideoStream relationship.", + "operationId": "getReadOnlyChannelUltraHighDefinitionVideoStream", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel whose related dataStream to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStream, or `null` if it was not found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/nullableDataStreamSecondaryResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The readOnlyChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves the related dataStream of an individual readOnlyChannel's ultraHighDefinitionVideoStream relationship without returning it.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyChannelUltraHighDefinitionVideoStream", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel whose related dataStream to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The readOnlyChannel does not exist." + } + } + } + }, + "/readOnlyChannels/{id}/relationships/ultraHighDefinitionVideoStream": { + "get": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves the related dataStream identity of an individual readOnlyChannel's ultraHighDefinitionVideoStream relationship.", + "operationId": "getReadOnlyChannelUltraHighDefinitionVideoStreamRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel whose related dataStream identity to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStream identity, or `null` if it was not found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/nullableDataStreamIdentifierResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The readOnlyChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves the related dataStream identity of an individual readOnlyChannel's ultraHighDefinitionVideoStream relationship without returning it.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyChannelUltraHighDefinitionVideoStreamRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel whose related dataStream identity to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The readOnlyChannel does not exist." + } + } + } + }, + "/readOnlyChannels/{id}/videoStream": { + "get": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves the related dataStream of an individual readOnlyChannel's videoStream relationship.", + "operationId": "getReadOnlyChannelVideoStream", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel whose related dataStream to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStream, or `null` if it was not found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/dataStreamSecondaryResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The readOnlyChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves the related dataStream of an individual readOnlyChannel's videoStream relationship without returning it.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyChannelVideoStream", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel whose related dataStream to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The readOnlyChannel does not exist." + } + } + } + }, + "/readOnlyChannels/{id}/relationships/videoStream": { + "get": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves the related dataStream identity of an individual readOnlyChannel's videoStream relationship.", + "operationId": "getReadOnlyChannelVideoStreamRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel whose related dataStream identity to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStream identity, or `null` if it was not found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/dataStreamIdentifierResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The readOnlyChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyChannels" + ], + "summary": "Retrieves the related dataStream identity of an individual readOnlyChannel's videoStream relationship without returning it.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyChannelVideoStreamRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyChannel whose related dataStream identity to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The readOnlyChannel does not exist." + } + } + } + }, + "/readOnlyResourceChannels": { + "get": { + "tags": [ + "readOnlyResourceChannels" + ], + "summary": "Retrieves a collection of readOnlyResourceChannels.", + "operationId": "getReadOnlyResourceChannelCollection", + "parameters": [ + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found readOnlyResourceChannels, or an empty array if none were found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/readOnlyResourceChannelCollectionResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyResourceChannels" + ], + "summary": "Retrieves a collection of readOnlyResourceChannels without returning them.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyResourceChannelCollection", + "parameters": [ + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + } + } + } + }, + "/readOnlyResourceChannels/{id}": { + "get": { + "tags": [ + "readOnlyResourceChannels" + ], + "summary": "Retrieves an individual readOnlyResourceChannel by its identifier.", + "operationId": "getReadOnlyResourceChannel", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyResourceChannel to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found readOnlyResourceChannel.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/readOnlyResourceChannelPrimaryResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The readOnlyResourceChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyResourceChannels" + ], + "summary": "Retrieves an individual readOnlyResourceChannel by its identifier without returning it.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyResourceChannel", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyResourceChannel to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The readOnlyResourceChannel does not exist." + } + } + } + }, + "/readOnlyResourceChannels/{id}/audioStreams": { + "get": { + "tags": [ + "readOnlyResourceChannels" + ], + "summary": "Retrieves the related dataStreams of an individual readOnlyResourceChannel's audioStreams relationship.", + "operationId": "getReadOnlyResourceChannelAudioStreams", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyResourceChannel whose related dataStreams to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStreams, or an empty array if none were found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/dataStreamCollectionResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The readOnlyResourceChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyResourceChannels" + ], + "summary": "Retrieves the related dataStreams of an individual readOnlyResourceChannel's audioStreams relationship without returning them.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyResourceChannelAudioStreams", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyResourceChannel whose related dataStreams to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The readOnlyResourceChannel does not exist." + } + } + } + }, + "/readOnlyResourceChannels/{id}/ultraHighDefinitionVideoStream": { + "get": { + "tags": [ + "readOnlyResourceChannels" + ], + "summary": "Retrieves the related dataStream of an individual readOnlyResourceChannel's ultraHighDefinitionVideoStream relationship.", + "operationId": "getReadOnlyResourceChannelUltraHighDefinitionVideoStream", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyResourceChannel whose related dataStream to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStream, or `null` if it was not found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/nullableDataStreamSecondaryResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The readOnlyResourceChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyResourceChannels" + ], + "summary": "Retrieves the related dataStream of an individual readOnlyResourceChannel's ultraHighDefinitionVideoStream relationship without returning it.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyResourceChannelUltraHighDefinitionVideoStream", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyResourceChannel whose related dataStream to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The readOnlyResourceChannel does not exist." + } + } + } + }, + "/readOnlyResourceChannels/{id}/videoStream": { + "get": { + "tags": [ + "readOnlyResourceChannels" + ], + "summary": "Retrieves the related dataStream of an individual readOnlyResourceChannel's videoStream relationship.", + "operationId": "getReadOnlyResourceChannelVideoStream", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyResourceChannel whose related dataStream to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStream, or `null` if it was not found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/dataStreamSecondaryResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The readOnlyResourceChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "readOnlyResourceChannels" + ], + "summary": "Retrieves the related dataStream of an individual readOnlyResourceChannel's videoStream relationship without returning it.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headReadOnlyResourceChannelVideoStream", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the readOnlyResourceChannel whose related dataStream to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The readOnlyResourceChannel does not exist." + } + } + } + }, + "/relationshipChannels/{id}/relationships/audioStreams": { + "get": { + "tags": [ + "relationshipChannels" + ], + "summary": "Retrieves the related dataStream identities of an individual relationshipChannel's audioStreams relationship.", + "operationId": "getRelationshipChannelAudioStreamsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the relationshipChannel whose related dataStream identities to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStream identities, or an empty array if none were found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/dataStreamIdentifierCollectionResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The relationshipChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "relationshipChannels" + ], + "summary": "Retrieves the related dataStream identities of an individual relationshipChannel's audioStreams relationship without returning them.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headRelationshipChannelAudioStreamsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the relationshipChannel whose related dataStream identities to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The relationshipChannel does not exist." + } + } + }, + "post": { + "tags": [ + "relationshipChannels" + ], + "summary": "Adds existing dataStreams to the audioStreams relationship of an individual relationshipChannel.", + "operationId": "postRelationshipChannelAudioStreamsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the relationshipChannel to add dataStreams to.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identities of the dataStreams to add to the audioStreams relationship.", + "content": { + "application/vnd.api+json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDataStreamInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The dataStreams were successfully added, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The relationshipChannel or a related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "patch": { + "tags": [ + "relationshipChannels" + ], + "summary": "Assigns existing dataStreams to the audioStreams relationship of an individual relationshipChannel.", + "operationId": "patchRelationshipChannelAudioStreamsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the relationshipChannel whose audioStreams relationship to assign.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identities of the dataStreams to assign to the audioStreams relationship, or an empty array to clear the relationship.", + "content": { + "application/vnd.api+json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDataStreamInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The audioStreams relationship was successfully updated, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The relationshipChannel or a related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "delete": { + "tags": [ + "relationshipChannels" + ], + "summary": "Removes existing dataStreams from the audioStreams relationship of an individual relationshipChannel.", + "operationId": "deleteRelationshipChannelAudioStreamsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the relationshipChannel to remove dataStreams from.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identities of the dataStreams to remove from the audioStreams relationship.", + "content": { + "application/vnd.api+json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDataStreamInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The dataStreams were successfully removed, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The relationshipChannel or a related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/relationshipChannels/{id}/relationships/ultraHighDefinitionVideoStream": { + "get": { + "tags": [ + "relationshipChannels" + ], + "summary": "Retrieves the related dataStream identity of an individual relationshipChannel's ultraHighDefinitionVideoStream relationship.", + "operationId": "getRelationshipChannelUltraHighDefinitionVideoStreamRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the relationshipChannel whose related dataStream identity to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStream identity, or `null` if it was not found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/nullableDataStreamIdentifierResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The relationshipChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "relationshipChannels" + ], + "summary": "Retrieves the related dataStream identity of an individual relationshipChannel's ultraHighDefinitionVideoStream relationship without returning it.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headRelationshipChannelUltraHighDefinitionVideoStreamRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the relationshipChannel whose related dataStream identity to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The relationshipChannel does not exist." + } + } + }, + "patch": { + "tags": [ + "relationshipChannels" + ], + "summary": "Clears or assigns an existing dataStream to the ultraHighDefinitionVideoStream relationship of an individual relationshipChannel.", + "operationId": "patchRelationshipChannelUltraHighDefinitionVideoStreamRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the relationshipChannel whose ultraHighDefinitionVideoStream relationship to assign or clear.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identity of the dataStream to assign to the ultraHighDefinitionVideoStream relationship, or `null` to clear the relationship.", + "content": { + "application/vnd.api+json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneDataStreamInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The ultraHighDefinitionVideoStream relationship was successfully updated, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The relationshipChannel or a related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/relationshipChannels/{id}/relationships/videoStream": { + "get": { + "tags": [ + "relationshipChannels" + ], + "summary": "Retrieves the related dataStream identity of an individual relationshipChannel's videoStream relationship.", + "operationId": "getRelationshipChannelVideoStreamRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the relationshipChannel whose related dataStream identity to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found dataStream identity, or `null` if it was not found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/dataStreamIdentifierResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The relationshipChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "relationshipChannels" + ], + "summary": "Retrieves the related dataStream identity of an individual relationshipChannel's videoStream relationship without returning it.", + "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", + "operationId": "headRelationshipChannelVideoStreamRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the relationshipChannel whose related dataStream identity to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The relationshipChannel does not exist." + } + } + }, + "patch": { + "tags": [ + "relationshipChannels" + ], + "summary": "Assigns an existing dataStream to the videoStream relationship of an individual relationshipChannel.", + "operationId": "patchRelationshipChannelVideoStreamRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the relationshipChannel whose videoStream relationship to assign.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identity of the dataStream to assign to the videoStream relationship.", + "content": { + "application/vnd.api+json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/toOneDataStreamInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The videoStream relationship was successfully updated, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The relationshipChannel or a related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/writeOnlyChannels": { + "post": { + "tags": [ + "writeOnlyChannels" + ], + "summary": "Creates a new writeOnlyChannel.", + "operationId": "postWriteOnlyChannel", + "parameters": [ + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + } + ], + "requestBody": { + "description": "The attributes and relationships of the writeOnlyChannel to create.", + "content": { + "application/vnd.api+json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/writeOnlyChannelPostRequestDocument" + } + ] + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "The writeOnlyChannel was successfully created, which resulted in additional changes. The newly created writeOnlyChannel is returned.", + "headers": { + "Location": { + "description": "The URL at which the newly created writeOnlyChannel can be retrieved.", + "required": true, + "schema": { + "type": "string", + "format": "uri" + } + } + }, + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/writeOnlyChannelPrimaryResponseDocument" + } + } + } + }, + "204": { + "description": "The writeOnlyChannel was successfully created, which did not result in additional changes." + }, + "400": { + "description": "The query string is invalid or the request body is missing or malformed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "403": { + "description": "Client-generated IDs cannot be used at this endpoint.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "422": { + "description": "Validation of the request body failed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/writeOnlyChannels/{id}": { + "patch": { + "tags": [ + "writeOnlyChannels" + ], + "summary": "Updates an existing writeOnlyChannel.", + "operationId": "patchWriteOnlyChannel", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the writeOnlyChannel to update.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + } + ], + "requestBody": { + "description": "The attributes and relationships of the writeOnlyChannel to update. Omitted fields are left unchanged.", + "content": { + "application/vnd.api+json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/writeOnlyChannelPatchRequestDocument" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "The writeOnlyChannel was successfully updated, which resulted in additional changes. The updated writeOnlyChannel is returned.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/writeOnlyChannelPrimaryResponseDocument" + } + } + } + }, + "204": { + "description": "The writeOnlyChannel was successfully updated, which did not result in additional changes." + }, + "400": { + "description": "The query string is invalid or the request body is missing or malformed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The writeOnlyChannel or a related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "A resource type or identifier in the request body is incompatible.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "422": { + "description": "Validation of the request body failed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "delete": { + "tags": [ + "writeOnlyChannels" + ], + "summary": "Deletes an existing writeOnlyChannel by its identifier.", + "operationId": "deleteWriteOnlyChannel", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the writeOnlyChannel to delete.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "The writeOnlyChannel was successfully deleted." + }, + "404": { + "description": "The writeOnlyChannel does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/writeOnlyChannels/{id}/relationships/audioStreams": { + "post": { + "tags": [ + "writeOnlyChannels" + ], + "summary": "Adds existing dataStreams to the audioStreams relationship of an individual writeOnlyChannel.", + "operationId": "postWriteOnlyChannelAudioStreamsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the writeOnlyChannel to add dataStreams to.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identities of the dataStreams to add to the audioStreams relationship.", + "content": { + "application/vnd.api+json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDataStreamInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The dataStreams were successfully added, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The writeOnlyChannel or a related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "patch": { + "tags": [ + "writeOnlyChannels" + ], + "summary": "Assigns existing dataStreams to the audioStreams relationship of an individual writeOnlyChannel.", + "operationId": "patchWriteOnlyChannelAudioStreamsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the writeOnlyChannel whose audioStreams relationship to assign.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identities of the dataStreams to assign to the audioStreams relationship, or an empty array to clear the relationship.", + "content": { + "application/vnd.api+json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDataStreamInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The audioStreams relationship was successfully updated, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The writeOnlyChannel or a related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "delete": { + "tags": [ + "writeOnlyChannels" + ], + "summary": "Removes existing dataStreams from the audioStreams relationship of an individual writeOnlyChannel.", + "operationId": "deleteWriteOnlyChannelAudioStreamsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the writeOnlyChannel to remove dataStreams from.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identities of the dataStreams to remove from the audioStreams relationship.", + "content": { + "application/vnd.api+json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDataStreamInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The dataStreams were successfully removed, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The writeOnlyChannel or a related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/writeOnlyChannels/{id}/relationships/ultraHighDefinitionVideoStream": { + "patch": { + "tags": [ + "writeOnlyChannels" + ], + "summary": "Clears or assigns an existing dataStream to the ultraHighDefinitionVideoStream relationship of an individual writeOnlyChannel.", + "operationId": "patchWriteOnlyChannelUltraHighDefinitionVideoStreamRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the writeOnlyChannel whose ultraHighDefinitionVideoStream relationship to assign or clear.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identity of the dataStream to assign to the ultraHighDefinitionVideoStream relationship, or `null` to clear the relationship.", + "content": { + "application/vnd.api+json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneDataStreamInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The ultraHighDefinitionVideoStream relationship was successfully updated, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The writeOnlyChannel or a related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/writeOnlyChannels/{id}/relationships/videoStream": { + "patch": { + "tags": [ + "writeOnlyChannels" + ], + "summary": "Assigns an existing dataStream to the videoStream relationship of an individual writeOnlyChannel.", + "operationId": "patchWriteOnlyChannelVideoStreamRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the writeOnlyChannel whose videoStream relationship to assign.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identity of the dataStream to assign to the videoStream relationship.", + "content": { + "application/vnd.api+json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/toOneDataStreamInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The videoStream relationship was successfully updated, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The writeOnlyChannel or a related resource does not exist.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "dataInResponse": { + "required": [ + "id", + "type" + ], + "type": "object", + "properties": { + "type": { + "minLength": 1, + "type": "string" + }, + "id": { + "minLength": 1, + "type": "string" + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "type", + "mapping": { + "dataStreams": "#/components/schemas/dataStreamDataInResponse", + "readOnlyChannels": "#/components/schemas/readOnlyChannelDataInResponse", + "readOnlyResourceChannels": "#/components/schemas/readOnlyResourceChannelDataInResponse", + "writeOnlyChannels": "#/components/schemas/writeOnlyChannelDataInResponse" + } + }, + "x-abstract": true + }, + "dataStreamAttributesInResponse": { + "type": "object", + "properties": { + "bytesTransmitted": { + "type": "integer", + "format": "int64" + } + }, + "additionalProperties": false + }, + "dataStreamCollectionResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataStreamDataInResponse" + } + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataInResponse" + } + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "dataStreamDataInResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInResponse" + }, + { + "type": "object", + "properties": { + "attributes": { + "allOf": [ + { + "$ref": "#/components/schemas/dataStreamAttributesInResponse" + } + ] + }, + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceData" + } + ] + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "dataStreamIdentifier": { + "required": [ + "id", + "type" + ], + "type": "object", + "properties": { + "type": { + "$ref": "#/components/schemas/dataStreamResourceType" + }, + "id": { + "minLength": 1, + "type": "string" + } + }, + "additionalProperties": false + }, + "dataStreamIdentifierCollectionResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + } + ] + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataStreamIdentifier" + } + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "dataStreamIdentifierResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataStreamIdentifier" + } + ] + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "dataStreamPrimaryResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataStreamDataInResponse" + } + ] + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataInResponse" + } + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "dataStreamResourceType": { + "enum": [ + "dataStreams" + ], + "type": "string", + "additionalProperties": false + }, + "dataStreamSecondaryResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataStreamDataInResponse" + } + ] + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataInResponse" + } + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "errorLinks": { + "type": "object", + "properties": { + "about": { + "type": "string", + "nullable": true + }, + "type": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "errorObject": { + "type": "object", + "properties": { + "id": { + "type": "string", + "nullable": true + }, + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/errorLinks" + } + ], + "nullable": true + }, + "status": { + "type": "string" + }, + "code": { + "type": "string", + "nullable": true + }, + "title": { + "type": "string", + "nullable": true + }, + "detail": { + "type": "string", + "nullable": true + }, + "source": { + "allOf": [ + { + "$ref": "#/components/schemas/errorSource" + } + ], + "nullable": true + }, + "meta": { + "type": "object", + "additionalProperties": { }, + "nullable": true + } + }, + "additionalProperties": false + }, + "errorResponseDocument": { + "required": [ + "errors", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInErrorDocument" + } + ] + }, + "errors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/errorObject" + } + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "errorSource": { + "type": "object", + "properties": { + "pointer": { + "type": "string", + "nullable": true + }, + "parameter": { + "type": "string", + "nullable": true + }, + "header": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "linksInErrorDocument": { + "required": [ + "self" + ], + "type": "object", + "properties": { + "self": { + "minLength": 1, + "type": "string" + }, + "describedby": { + "type": "string" + } + }, + "additionalProperties": false + }, + "linksInRelationship": { + "required": [ + "related", + "self" + ], + "type": "object", + "properties": { + "self": { + "minLength": 1, + "type": "string" + }, + "related": { + "minLength": 1, + "type": "string" + } + }, + "additionalProperties": false + }, + "linksInResourceCollectionDocument": { + "required": [ + "self" + ], + "type": "object", + "properties": { + "self": { + "minLength": 1, + "type": "string" + }, + "describedby": { + "type": "string" + }, + "first": { + "type": "string" + }, + "last": { + "type": "string" + }, + "prev": { + "type": "string" + }, + "next": { + "type": "string" + } + }, + "additionalProperties": false + }, + "linksInResourceData": { + "required": [ + "self" + ], + "type": "object", + "properties": { + "self": { + "minLength": 1, + "type": "string" + } + }, + "additionalProperties": false + }, + "linksInResourceDocument": { + "required": [ + "self" + ], + "type": "object", + "properties": { + "self": { + "minLength": 1, + "type": "string" + }, + "describedby": { + "type": "string" + } + }, + "additionalProperties": false + }, + "linksInResourceIdentifierCollectionDocument": { + "required": [ + "related", + "self" + ], + "type": "object", + "properties": { + "self": { + "minLength": 1, + "type": "string" + }, + "related": { + "minLength": 1, + "type": "string" + }, + "describedby": { + "type": "string" + }, + "first": { + "type": "string" + }, + "last": { + "type": "string" + }, + "prev": { + "type": "string" + }, + "next": { + "type": "string" + } + }, + "additionalProperties": false + }, + "linksInResourceIdentifierDocument": { + "required": [ + "related", + "self" + ], + "type": "object", + "properties": { + "self": { + "minLength": 1, + "type": "string" + }, + "related": { + "minLength": 1, + "type": "string" + }, + "describedby": { + "type": "string" + } + }, + "additionalProperties": false + }, + "nullableDataStreamIdentifierResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataStreamIdentifier" + } + ], + "nullable": true + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "nullableDataStreamSecondaryResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataStreamDataInResponse" + } + ], + "nullable": true + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataInResponse" + } + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "nullableToOneDataStreamInRequest": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataStreamIdentifier" + } + ], + "nullable": true + } + }, + "additionalProperties": false + }, + "nullableToOneDataStreamInResponse": { + "required": [ + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationship" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataStreamIdentifier" + } + ], + "nullable": true + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "readOnlyChannelAttributesInResponse": { + "type": "object", + "properties": { + "name": { + "type": "string", + "nullable": true + }, + "isCommercial": { + "type": "boolean", + "nullable": true + }, + "isAdultOnly": { + "type": "boolean", + "nullable": true + } + }, + "additionalProperties": false + }, + "readOnlyChannelCollectionResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/readOnlyChannelDataInResponse" + } + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataInResponse" + } + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "readOnlyChannelDataInResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInResponse" + }, + { + "type": "object", + "properties": { + "attributes": { + "allOf": [ + { + "$ref": "#/components/schemas/readOnlyChannelAttributesInResponse" + } + ] + }, + "relationships": { + "allOf": [ + { + "$ref": "#/components/schemas/readOnlyChannelRelationshipsInResponse" + } + ] + }, + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceData" + } + ] + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "readOnlyChannelPrimaryResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/readOnlyChannelDataInResponse" + } + ] + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataInResponse" + } + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "readOnlyChannelRelationshipsInResponse": { + "type": "object", + "properties": { + "videoStream": { + "allOf": [ + { + "$ref": "#/components/schemas/toOneDataStreamInResponse" + } + ] + }, + "ultraHighDefinitionVideoStream": { + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneDataStreamInResponse" + } + ] + }, + "audioStreams": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDataStreamInResponse" + } + ] + } + }, + "additionalProperties": false + }, + "readOnlyResourceChannelAttributesInResponse": { + "type": "object", + "properties": { + "name": { + "type": "string", + "nullable": true + }, + "isCommercial": { + "type": "boolean", + "nullable": true + }, + "isAdultOnly": { + "type": "boolean", + "nullable": true + } + }, + "additionalProperties": false + }, + "readOnlyResourceChannelCollectionResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + } + ] + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/readOnlyResourceChannelDataInResponse" + } + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataInResponse" + } + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "readOnlyResourceChannelDataInResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInResponse" + }, + { + "type": "object", + "properties": { + "attributes": { + "allOf": [ + { + "$ref": "#/components/schemas/readOnlyResourceChannelAttributesInResponse" + } + ] + }, + "relationships": { + "allOf": [ + { + "$ref": "#/components/schemas/readOnlyResourceChannelRelationshipsInResponse" + } + ] + }, + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceData" + } + ] + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "readOnlyResourceChannelPrimaryResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/readOnlyResourceChannelDataInResponse" + } + ] + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataInResponse" + } + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "readOnlyResourceChannelRelationshipsInResponse": { + "type": "object", + "properties": { + "videoStream": { + "allOf": [ + { + "$ref": "#/components/schemas/toOneDataStreamInResponse" + } + ] + }, + "ultraHighDefinitionVideoStream": { + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneDataStreamInResponse" + } + ] + }, + "audioStreams": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDataStreamInResponse" + } + ] + } + }, + "additionalProperties": false + }, + "toManyDataStreamInRequest": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataStreamIdentifier" + } + } + }, + "additionalProperties": false + }, + "toManyDataStreamInResponse": { + "required": [ + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationship" + } + ] + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataStreamIdentifier" + } + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "toOneDataStreamInRequest": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataStreamIdentifier" + } + ] + } + }, + "additionalProperties": false + }, + "toOneDataStreamInResponse": { + "required": [ + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInRelationship" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataStreamIdentifier" + } + ] + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "writeOnlyChannelAttributesInPatchRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "nullable": true + }, + "isCommercial": { + "type": "boolean", + "nullable": true + }, + "isAdultOnly": { + "type": "boolean", + "nullable": true + } + }, + "additionalProperties": false + }, + "writeOnlyChannelAttributesInPostRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "nullable": true + }, + "isCommercial": { + "type": "boolean", + "nullable": true + }, + "isAdultOnly": { + "type": "boolean", + "nullable": true + } + }, + "additionalProperties": false + }, + "writeOnlyChannelAttributesInResponse": { + "type": "object", + "properties": { + "name": { + "type": "string", + "nullable": true + }, + "isCommercial": { + "type": "boolean", + "nullable": true + }, + "isAdultOnly": { + "type": "boolean", + "nullable": true + } + }, + "additionalProperties": false + }, + "writeOnlyChannelDataInPatchRequest": { + "required": [ + "id", + "type" + ], + "type": "object", + "properties": { + "type": { + "$ref": "#/components/schemas/writeOnlyChannelResourceType" + }, + "id": { + "minLength": 1, + "type": "string" + }, + "attributes": { + "allOf": [ + { + "$ref": "#/components/schemas/writeOnlyChannelAttributesInPatchRequest" + } + ] + }, + "relationships": { + "allOf": [ + { + "$ref": "#/components/schemas/writeOnlyChannelRelationshipsInPatchRequest" + } + ] + } + }, + "additionalProperties": false + }, + "writeOnlyChannelDataInPostRequest": { + "required": [ + "type" + ], + "type": "object", + "properties": { + "type": { + "$ref": "#/components/schemas/writeOnlyChannelResourceType" + }, + "attributes": { + "allOf": [ + { + "$ref": "#/components/schemas/writeOnlyChannelAttributesInPostRequest" + } + ] + }, + "relationships": { + "allOf": [ + { + "$ref": "#/components/schemas/writeOnlyChannelRelationshipsInPostRequest" + } + ] + } + }, + "additionalProperties": false + }, + "writeOnlyChannelDataInResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInResponse" + }, + { + "type": "object", + "properties": { + "attributes": { + "allOf": [ + { + "$ref": "#/components/schemas/writeOnlyChannelAttributesInResponse" + } + ] + }, + "relationships": { + "allOf": [ + { + "$ref": "#/components/schemas/writeOnlyChannelRelationshipsInResponse" + } + ] + }, + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceData" + } + ] + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "writeOnlyChannelPatchRequestDocument": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/writeOnlyChannelDataInPatchRequest" + } + ] + } + }, + "additionalProperties": false + }, + "writeOnlyChannelPostRequestDocument": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/writeOnlyChannelDataInPostRequest" + } + ] + } + }, + "additionalProperties": false + }, + "writeOnlyChannelPrimaryResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/linksInResourceDocument" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/writeOnlyChannelDataInResponse" + } + ] + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataInResponse" + } + }, + "meta": { + "type": "object", + "additionalProperties": { + "type": "object", + "nullable": true + } + } + }, + "additionalProperties": false + }, + "writeOnlyChannelRelationshipsInPatchRequest": { + "type": "object", + "properties": { + "videoStream": { + "allOf": [ + { + "$ref": "#/components/schemas/toOneDataStreamInRequest" + } + ] + }, + "ultraHighDefinitionVideoStream": { + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneDataStreamInRequest" + } + ] + }, + "audioStreams": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDataStreamInRequest" + } + ] + } + }, + "additionalProperties": false + }, + "writeOnlyChannelRelationshipsInPostRequest": { + "required": [ + "videoStream" + ], + "type": "object", + "properties": { + "videoStream": { + "allOf": [ + { + "$ref": "#/components/schemas/toOneDataStreamInRequest" + } + ] + }, + "ultraHighDefinitionVideoStream": { + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneDataStreamInRequest" + } + ] + }, + "audioStreams": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDataStreamInRequest" + } + ] + } + }, + "additionalProperties": false + }, + "writeOnlyChannelRelationshipsInResponse": { + "type": "object", + "properties": { + "videoStream": { + "allOf": [ + { + "$ref": "#/components/schemas/toOneDataStreamInResponse" + } + ] + }, + "ultraHighDefinitionVideoStream": { + "allOf": [ + { + "$ref": "#/components/schemas/nullableToOneDataStreamInResponse" + } + ] + }, + "audioStreams": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDataStreamInResponse" + } + ] + } + }, + "additionalProperties": false + }, + "writeOnlyChannelResourceType": { + "enum": [ + "writeOnlyChannels" + ], + "type": "string", + "additionalProperties": false + } + } + } +} \ No newline at end of file diff --git a/test/OpenApiTests/RestrictedControllers/RestrictionFakers.cs b/test/OpenApiTests/RestrictedControllers/RestrictionFakers.cs index bd94c5046c..6ab9e56409 100644 --- a/test/OpenApiTests/RestrictedControllers/RestrictionFakers.cs +++ b/test/OpenApiTests/RestrictedControllers/RestrictionFakers.cs @@ -10,25 +10,40 @@ namespace OpenApiTests.RestrictedControllers; [UsedImplicitly(ImplicitUseTargetFlags.Members)] public sealed class RestrictionFakers : FakerContainer { + private static readonly IList NullableBooleanValues = + [ + true, + false, + null + ]; + private readonly Lazy> _lazyDataStreamFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) - .RuleFor(stream => stream.BytesTransmitted, faker => faker.Random.ULong())); + .RuleFor(stream => stream.BytesTransmitted, faker => (ulong)faker.Random.Long(0))); private readonly Lazy> _lazyReadOnlyChannelFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) - .RuleFor(channel => channel.Name, faker => faker.Lorem.Word())); + .RuleFor(channel => channel.Name, faker => faker.Lorem.Word()) + .RuleFor(channel => channel.IsCommercial, faker => faker.PickRandom(NullableBooleanValues)) + .RuleFor(channel => channel.IsAdultOnly, faker => faker.PickRandom(NullableBooleanValues))); private readonly Lazy> _lazyWriteOnlyChannelFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) - .RuleFor(channel => channel.Name, faker => faker.Lorem.Word())); + .RuleFor(channel => channel.Name, faker => faker.Lorem.Word()) + .RuleFor(channel => channel.IsCommercial, faker => faker.PickRandom(NullableBooleanValues)) + .RuleFor(channel => channel.IsAdultOnly, faker => faker.PickRandom(NullableBooleanValues))); private readonly Lazy> _lazyRelationshipChannelFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) - .RuleFor(channel => channel.Name, faker => faker.Lorem.Word())); + .RuleFor(channel => channel.Name, faker => faker.Lorem.Word()) + .RuleFor(channel => channel.IsCommercial, faker => faker.PickRandom(NullableBooleanValues)) + .RuleFor(channel => channel.IsAdultOnly, faker => faker.PickRandom(NullableBooleanValues))); private readonly Lazy> _lazyReadOnlyResourceChannelFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) - .RuleFor(channel => channel.Name, faker => faker.Lorem.Word())); + .RuleFor(channel => channel.Name, faker => faker.Lorem.Word()) + .RuleFor(channel => channel.IsCommercial, faker => faker.PickRandom(NullableBooleanValues)) + .RuleFor(channel => channel.IsAdultOnly, faker => faker.PickRandom(NullableBooleanValues))); public Faker DataStream => _lazyDataStreamFaker.Value; public Faker ReadOnlyChannel => _lazyReadOnlyChannelFaker.Value; diff --git a/test/OpenApiTests/RestrictedControllers/RestrictionTests.cs b/test/OpenApiTests/RestrictedControllers/RestrictionTests.cs index 467d8d6171..ef52a5529e 100644 --- a/test/OpenApiTests/RestrictedControllers/RestrictionTests.cs +++ b/test/OpenApiTests/RestrictedControllers/RestrictionTests.cs @@ -35,6 +35,8 @@ public RestrictionTests(OpenApiTestContext, testContext.UseController(); testContext.UseController(); testContext.UseController(); + + testContext.SwaggerDocumentOutputDirectory = $"{GetType().Namespace!.Replace('.', '/')}/GeneratedSwagger"; } [Theory] @@ -64,6 +66,8 @@ public async Task Only_expected_endpoints_are_exposed(Type resourceClrType, Json [ $"/{resourceName}/{{id}}/audioStreams.get", $"/{resourceName}/{{id}}/audioStreams.head", + $"/{resourceName}/{{id}}/ultraHighDefinitionVideoStream.get", + $"/{resourceName}/{{id}}/ultraHighDefinitionVideoStream.head", $"/{resourceName}/{{id}}/videoStream.get", $"/{resourceName}/{{id}}/videoStream.head" ], @@ -71,6 +75,8 @@ public async Task Only_expected_endpoints_are_exposed(Type resourceClrType, Json [ $"/{resourceName}/{{id}}/relationships/audioStreams.get", $"/{resourceName}/{{id}}/relationships/audioStreams.head", + $"/{resourceName}/{{id}}/relationships/ultraHighDefinitionVideoStream.get", + $"/{resourceName}/{{id}}/relationships/ultraHighDefinitionVideoStream.head", $"/{resourceName}/{{id}}/relationships/videoStream.get", $"/{resourceName}/{{id}}/relationships/videoStream.head" ], @@ -80,6 +86,7 @@ public async Task Only_expected_endpoints_are_exposed(Type resourceClrType, Json [JsonApiEndpoints.PatchRelationship] = [ $"/{resourceName}/{{id}}/relationships/audioStreams.patch", + $"/{resourceName}/{{id}}/relationships/ultraHighDefinitionVideoStream.patch", $"/{resourceName}/{{id}}/relationships/videoStream.patch" ], [JsonApiEndpoints.Delete] = [$"/{resourceName}/{{id}}.delete"],