Repository: microsoft/kiota (csharp)

Issue:
Kiota will ignore circular reference/anyof/allof property without any warnings
### What are you generating using Kiota, clients or plugins?

Kiota plugin

### In what context or format are you using Kiota?

Nuget tool

### Client library/SDK language

None

### Describe the bug

When generate API copilot plugin file, the generated result will ignore circular reference/anyof/allof properties inside OpenAPI spec file without any warnings.

### Expected behavior

It should show warnings or proper handle these special properties properties

### How to reproduce

Below are testing OpenAPI spec file:

OpenAPI spec file with circular reference:
https://github.com/SLdragon/example-openapi-spec/blob/main/circular-reference.yaml

OpenAPI spec file with anyof/allof properties:
https://github.com/SLdragon/example-openapi-spec/blob/main/contain-anyof.json

### Open API description file

_No response_

### Kiota Version

1.15.0+98ed4dae66ab4c06cb490b05bf9180db132791b8

### Latest Kiota version known to work for scenario above?(Not required)

_No response_

### Known Workarounds

_No response_

### Configuration

_No response_

### Debug output

<details><summary>Click to expand log</summary>
```


<log output here>

```
</details>


### Other information

_No response_

Pull request:
Closes https://github.com/microsoft/kiota/issues/4945

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1a95bf545b..7b1a04d161 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Changed
 
+- Reverts modification of responses in output openApi file when generating plugings [#4945](https://github.com/microsoft/kiota/issues/4945)
+
 ## [1.17.0] - 2024-08-09
 
 ### Added
diff --git a/src/Kiota.Builder/Plugins/OpenApiPluginWalker.cs b/src/Kiota.Builder/Plugins/OpenApiPluginWalker.cs
index b89d65d3e9..245dd014ac 100644
--- a/src/Kiota.Builder/Plugins/OpenApiPluginWalker.cs
+++ b/src/Kiota.Builder/Plugins/OpenApiPluginWalker.cs
@@ -25,39 +25,16 @@ public override void Visit(IOpenApiExtensible openApiExtensible)
         }
     }
     /// <summary>
-    /// Visits the operations.
+    /// Visits the OpenAPI response.
     /// </summary>
-    public override void Visit(IDictionary<OperationType, OpenApiOperation> operations)
+    public override void Visit(OpenApiResponses response)
     {
-        ArgumentNullException.ThrowIfNull(operations);
+        ArgumentNullException.ThrowIfNull(response);
 
-        // Cleanup responses for the operation
-        foreach (var operation in operations.Values)
+        // Ensure description strings are not empty strings.
+        foreach (var responseItem in response.Where(static res => string.IsNullOrEmpty(res.Value.Description)))
         {
-            var responseDescription = operation.Responses.Values.Select(static response => response.Description)
-                .FirstOrDefault(static desc => !string.IsNullOrEmpty(desc)) ?? "Api Response";
-
-            operation.Responses = new OpenApiResponses()
-            {
-                {
-                    "2XX",new OpenApiResponse
-                    {
-                        Description = responseDescription,
-                        Content = new Dictionary<string, OpenApiMediaType>
-                        {
-                            {
-                                "text/plain", new OpenApiMediaType
-                                {
-                                    Schema = new OpenApiSchema
-                                    {
-                                        Type = "string"
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            };
+            responseItem.Value.Description = "Api Response";
         }
     }
 }


Test patch:
diff --git a/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs b/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs
index b08f4636ee..451f054589 100644
--- a/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs
+++ b/tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs
@@ -712,7 +712,7 @@ public async Task GeneratesManifestAndCleansUpInputDescription()
           format: int32
       responses:
         '200':
-          description: test
+          description:
         '500':
           description: api error response
 components:
@@ -789,11 +789,11 @@ public async Task GeneratesManifestAndCleansUpInputDescription()
         Assert.Empty(resultDocument.Components.Schemas);// no schema is referenced. so ensure they are all removed
         Assert.Empty(resultDocument.Extensions); // no extension at root (unsupported extension is removed)
         Assert.Equal(2, resultDocument.Paths.Count); // document has only two paths
-        Assert.Single(resultDocument.Paths["/test"].Operations[OperationType.Get].Responses); // other responses are removed from the document
-        Assert.NotEmpty(resultDocument.Paths["/test"].Operations[OperationType.Get].Responses["2XX"].Description); // response description string is not empty
+        Assert.Equal(originalDocument.Paths["/test"].Operations[OperationType.Get].Responses.Count, resultDocument.Paths["/test"].Operations[OperationType.Get].Responses.Count); // Responses are still intact.
+        Assert.NotEmpty(resultDocument.Paths["/test"].Operations[OperationType.Get].Responses["200"].Description); // response description string is not empty
         Assert.Empty(resultDocument.Paths["/test"].Operations[OperationType.Get].Extensions); // NO UNsupported extension
-        Assert.Single(resultDocument.Paths["/test/{id}"].Operations[OperationType.Get].Responses); // 2 responses originally
-        Assert.NotEmpty(resultDocument.Paths["/test/{id}"].Operations[OperationType.Get].Responses["2XX"].Description);// response description string is not empty
+        Assert.Equal(originalDocument.Paths["/test/{id}"].Operations[OperationType.Get].Responses.Count, resultDocument.Paths["/test/{id}"].Operations[OperationType.Get].Responses.Count); // Responses are still intact.
+        Assert.NotEmpty(resultDocument.Paths["/test/{id}"].Operations[OperationType.Get].Responses["200"].Description);// response description string is not empty
         Assert.Single(resultDocument.Paths["/test/{id}"].Operations[OperationType.Get].Extensions); // 1 supported extension still present in operation
     }
 }