Repository: microsoft/kiota (csharp)

Issue:
Error: The type does not contain any information
### What are you generating using Kiota, clients or plugins?

API Client/SDK

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

Nuget tool

### Client library/SDK language

Csharp

### Describe the bug

When I try to generate an SDK I get this error:
2024-10-31 14:29:34.644 [error] error generating the client: One or more errors occurred. (One or more errors occurred. (The type does not contain any information Path: \orders\v1, Reference Id: UserId))

![Image](https://github.com/user-attachments/assets/35f605f9-5f56-4049-9f91-080e10dd1400)


### Expected behavior

That I didn't get the error and the SDK was generated. 

### How to reproduce

Create a .yaml file and insert the example below. Use Kiota to generate an SDK. In this simple example it doesn't make sense to have multi nesting references, but the company I work for has a pretty complex API where something like this makes more sense.

**This fails:**

```YAML
openapi: 3.0.3
info:
  title: Simple API
  description: A simple API to demonstrate OpenAPI 3.0.3
  version: 1.0.0
  x-bundled: true
  contact:
    name: API Support
    url: 'http://www.example.com/support'
servers:
  - url: https://api.example.com/v1
tags:
  - name: orders
    description: Operations about orders
paths:
  /orders/v1:
    get:
      summary: List all orders
      operationId: orders
      description: Returns a list of orders.
      tags:
        - orders
      responses:
        '200':
          description: A list of orders
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Order'
components:
  schemas:
    Order:
      title: Order
      description: Object representing an Order.
      type: object
      properties:
        TraderId:
          $ref: '#/components/schemas/TraderId'
    TraderId:
      title: Trader Id
      description: >-
        The ID of the authorized dealer who placed the trade. If the application
        uses a system user, this will be the user responsible for overseeing the
        application.
      allOf:
        - $ref: '#/components/schemas/UserId'
    UserId:
      title: User Id
      description: Unique identifier of a User.
      type: string
      pattern: ^[1-9][0-9]*$
      example: '16371609'
```

**This works:**

```YAML
openapi: 3.0.3
info:
  title: Simple API
  description: A simple API to demonstrate OpenAPI 3.0.3
  version: 1.0.0
  x-bundled: true
  contact:
    name: API Support
    url: 'http://www.example.com/support'
servers:
  - url: https://api.example.com/v1
tags:
  - name: orders
    description: Operations about orders
paths:
  /orders/v1:
    get:
      summary: List all orders
      operationId: orders
      description: Returns a list of orders.
      tags:
        - orders
      responses:
        '200':
          description: A list of orders
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Order'
components:
  schemas:
    Order:
      title: Order
      description: Object representing an Order.
      type: object
      properties:
        TraderId:
          $ref: '#/components/schemas/TraderId'
    TraderId:
      title: Trader Id
      description: >-
        The ID of the authorized dealer who placed the trade. If the application
        uses a system user, this will be the user responsible for overseeing the
        application.
      type: string
      pattern: ^[1-9][0-9]*$
      example: '16371609'
```

### Open API description file

_No response_

### Kiota Version

1.19.1

### 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 #5701 

In the scenario for generating the models for inheritance, it won't make sense for a schema to inherit from a primitive. 

This changes in this PR ensure that the meaningful schemas used by the `IsInherited` are of the object type (if specified) so that generation can be done using models that are part of the code DOM (given that primitives are externally defined, "inheriting" from primitives would also cause failures at later generation stages in the builder)

Using the sample in the issue at #5701, the generated model(Order) should have the TraderId property correctly generated as a string as well.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a89c897ab..9be682ff28 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
 
+- Fixed a bug in generation when a referenced schema in an allOf was a primitive [#5701](https://github.com/microsoft/kiota/issues/5701).
+
 ## [1.21.0] - 2024-12-05
 
 ### Added
diff --git a/src/Kiota.Builder/Extensions/OpenApiSchemaExtensions.cs b/src/Kiota.Builder/Extensions/OpenApiSchemaExtensions.cs
index 28774211e4..cec1a3cf2b 100644
--- a/src/Kiota.Builder/Extensions/OpenApiSchemaExtensions.cs
+++ b/src/Kiota.Builder/Extensions/OpenApiSchemaExtensions.cs
@@ -77,7 +77,11 @@ public static bool IsInclusiveUnion(this OpenApiSchema? schema, uint exclusiveMi
     public static bool IsInherited(this OpenApiSchema? schema)
     {
         if (schema is null) return false;
-        var meaningfulMemberSchemas = schema.AllOf.FlattenSchemaIfRequired(static x => x.AllOf).Where(static x => x.IsSemanticallyMeaningful(ignoreEnums: true, ignoreArrays: true, ignoreType: true)).ToArray();
+        var meaningfulMemberSchemas = schema.AllOf.FlattenSchemaIfRequired(static x => x.AllOf)
+                                                                .Where(static x => x.IsSemanticallyMeaningful(ignoreEnums: true, ignoreArrays: true, ignoreType: true))
+                                                                // the next line ensures the meaningful schema are objects as it won't make sense inheriting from a primitive despite it being meaningful.
+                                                                .Where(static x => string.IsNullOrEmpty(x.Reference?.Id) || string.IsNullOrEmpty(x.Type) || "object".Equals(x.Type, StringComparison.OrdinalIgnoreCase))
+                                                                .ToArray();
         var isRootSchemaMeaningful = schema.IsSemanticallyMeaningful(ignoreEnums: true, ignoreArrays: true, ignoreType: true);
         return meaningfulMemberSchemas.Count(static x => !string.IsNullOrEmpty(x.Reference?.Id)) == 1 &&
             (meaningfulMemberSchemas.Count(static x => string.IsNullOrEmpty(x.Reference?.Id)) == 1 ||


Test patch:
diff --git a/tests/Kiota.Builder.Tests/Extensions/OpenApiSchemaExtensionsTests.cs b/tests/Kiota.Builder.Tests/Extensions/OpenApiSchemaExtensionsTests.cs
index 800a449504..6ca611be28 100644
--- a/tests/Kiota.Builder.Tests/Extensions/OpenApiSchemaExtensionsTests.cs
+++ b/tests/Kiota.Builder.Tests/Extensions/OpenApiSchemaExtensionsTests.cs
@@ -567,6 +567,32 @@ public void IsIntersection()
         };
         Assert.False(schema.IsInherited());
         Assert.False(schema.IsIntersection());
+
+        schema = new OpenApiSchema
+        {
+            Title = "Trader Id",
+            AllOf = new List<OpenApiSchema> {
+                new ()
+                {
+                    Title = "UserId",
+                    Description = "unique identifier",
+                    Type = "string",
+                    Pattern = "^[1-9][0-9]*$",
+                    Example = new OpenApiString("1323232"),
+                    Reference = new OpenApiReference
+                    {
+                        Id = "UserId" // This property makes the schema "meaningful"
+                    }
+                }
+            },
+            Reference = new OpenApiReference
+            {
+                Id = "TraderId" // This property makes the schema "meaningful"
+            }
+        };
+
+        Assert.False(schema.IsInherited());
+        Assert.False(schema.IsIntersection());
     }
     [Fact]
     public void MergesIntersection()