diff --git a/src/Kiota.Builder/KiotaBuilder.cs b/src/Kiota.Builder/KiotaBuilder.cs index 3315cbb576..d1d73eea5f 100644 --- a/src/Kiota.Builder/KiotaBuilder.cs +++ b/src/Kiota.Builder/KiotaBuilder.cs @@ -1101,11 +1101,11 @@ codeType.TypeDefinition is CodeClass codeClass && } } } - private CodeTypeBase? GetExecutorMethodReturnType(OpenApiUrlTreeNode currentNode, OpenApiSchema? schema, OpenApiOperation operation, CodeClass parentClass) + private CodeTypeBase? GetExecutorMethodReturnType(OpenApiUrlTreeNode currentNode, OpenApiSchema? schema, OpenApiOperation operation, CodeClass parentClass, OperationType operationType) { if (schema != null) { - return CreateModelDeclarations(currentNode, schema, operation, parentClass, "Response"); + return CreateModelDeclarations(currentNode, schema, operation, parentClass, $"{operationType}Response"); } else { @@ -1152,7 +1152,7 @@ private void CreateOperationMethods(OpenApiUrlTreeNode currentNode, OperationTyp operation.Summary) .CleanupDescription(), }, - ReturnType = GetExecutorMethodReturnType(currentNode, schema, operation, parentClass) ?? throw new InvalidSchemaException(), + ReturnType = GetExecutorMethodReturnType(currentNode, schema, operation, parentClass, operationType) ?? throw new InvalidSchemaException(), Deprecation = deprecationInformation, }; diff --git a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs index f9c38fabb8..6e265af61c 100644 --- a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs +++ b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs @@ -932,7 +932,7 @@ public void Object_Arrays_are_supported() var codeModel = builder.CreateSourceModel(node); var userClass = codeModel.FindNamespaceByName("ApiSdk.models").FindChildByName("user"); Assert.NotNull(userClass); - var userResponseClass = codeModel.FindNamespaceByName("ApiSdk.users.item").FindChildByName("UsersResponse", false); + var userResponseClass = codeModel.FindNamespaceByName("ApiSdk.users.item").FindChildByName("UsersGetResponse", false); Assert.NotNull(userResponseClass); var valueProp = userResponseClass.FindChildByName("value", false); Assert.NotNull(valueProp); @@ -1433,9 +1433,9 @@ public void Inline_Property_Inheritance_Is_Supported() var codeModel = builder.CreateSourceModel(node); var resourceClass = codeModel.FindNamespaceByName("ApiSdk.models").FindChildByName("resource"); var itemsNS = codeModel.FindNamespaceByName("ApiSdk.resource.item"); - var responseClass = itemsNS.FindChildByName("ResourceResponse"); - var derivedResourceClass = itemsNS.FindChildByName("ResourceResponse_derivedResource"); - var derivedResourceInfoClass = itemsNS.FindChildByName("ResourceResponse_derivedResource_info"); + var responseClass = itemsNS.FindChildByName("ResourceGetResponse"); + var derivedResourceClass = itemsNS.FindChildByName("ResourceGetResponse_derivedResource"); + var derivedResourceInfoClass = itemsNS.FindChildByName("ResourceGetResponse_derivedResource_info"); Assert.NotNull(resourceClass); @@ -3128,7 +3128,7 @@ public void UnionOfInlineSchemasWorks() Assert.Equal(2, executorReturnType.Types.Count()); var typeNames = executorReturnType.Types.Select(x => x.Name).ToHashSet(StringComparer.OrdinalIgnoreCase); Assert.Contains("simpleObject", typeNames); - Assert.Contains("unionTypeResponseMember1", typeNames); + Assert.Contains("unionTypeGetResponseMember1", typeNames); } [Fact] public void IntersectionOfPrimitiveTypesWorks() @@ -3287,7 +3287,7 @@ public void IntersectionOfInlineSchemasWorks() Assert.Equal(2, executorReturnType.Types.Count()); var typeNames = executorReturnType.Types.Select(x => x.Name).ToHashSet(StringComparer.OrdinalIgnoreCase); Assert.Contains("simpleObject", typeNames); - Assert.Contains("unionTypeResponseMember1", typeNames); + Assert.Contains("unionTypeGetResponseMember1", typeNames); } [Fact] public void InheritedTypeWithInlineSchemaWorks() @@ -5822,7 +5822,7 @@ await File.WriteAllTextAsync(tempFilePath, @$"openapi: 3.0.1 var codeModel = builder.CreateSourceModel(node); var rootNS = codeModel.FindNamespaceByName("ApiSdk"); Assert.NotNull(rootNS); - var inlineType = rootNS.FindChildByName($"enumerationResponse_{expected}", true); + var inlineType = rootNS.FindChildByName($"enumerationGetResponse_{expected}", true); Assert.NotNull(inlineType); } [Fact] @@ -5970,7 +5970,7 @@ public async Task MergesIntersectionTypes() var document = await builder.CreateOpenApiDocumentAsync(fs); var node = builder.CreateUriSpace(document); var codeModel = builder.CreateSourceModel(node); - var resultClass = codeModel.FindChildByName("DirectoryObjectResponse"); + var resultClass = codeModel.FindChildByName("DirectoryObjectGetResponse"); Assert.NotNull(resultClass); Assert.Equal(4, resultClass.Properties.Where(static x => x.IsOfKind(CodePropertyKind.Custom)).Count()); } @@ -6010,7 +6010,7 @@ public async Task SkipsInvalidItemsProperties() var document = await builder.CreateOpenApiDocumentAsync(fs); var node = builder.CreateUriSpace(document); var codeModel = builder.CreateSourceModel(node); - var resultClass = codeModel.FindChildByName("DirectoryObjectResponse"); + var resultClass = codeModel.FindChildByName("DirectoryObjectGetResponse"); Assert.NotNull(resultClass); var keysToCheck = new HashSet(StringComparer.OrdinalIgnoreCase) { "datasets", "datakeys", "datainfo" }; Assert.Empty(resultClass.Properties.Where(x => x.IsOfKind(CodePropertyKind.Custom) && keysToCheck.Contains(x.Name)));