Skip to content

Array of enums in a request generates code (C#) that produces a compile error #578

@hervala

Description

@hervala

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

With an OpenAPI description that has a route with request body of enum array. Kiota will generate a C# client that has a compile error:

Error CS1061 : 'RequestInformation' does not contain a definition for 'SetContentFromEnumCollection' and no accessible extension method 'SetContentFromEnumCollection' accepting a first argument of type 'RequestInformation' could be found (are you missing a using directive or an assembly reference?)

RequestInformation type has a method SetContentFromEnum but not the needed SetContentFromEnumCollection

Expected behavior

Kiota should generate code that compiles.

How to reproduce

Problem can be reproduced by generating a C# client with the provided Open API description. Command used to generate the client was:

dotnet kiota generate -l CSharp -c Client -n ConsoleApp1 --openapi example.yaml -o ./Client

Open API description file

openapi: 3.0.4
info:
  title: WebApplication1 | v1
  version: 1.0.0
paths:
  /:
    put:
      tags:
        - WebApplication1
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/Status'
        required: true
      responses:
        '200':
          description: OK
components:
  schemas:
    Status:
      enum:
        - Active
        - Inactive
        - Pending

Kiota Version

1.28.0+57130b1b1db3bc5c060498682f41e20c8ae089f2

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

1.27.0

Known Workarounds

None

Configuration

  • Ubuntu 24.04.3 LTS
  • x64

Debug output

Click to expand log

dbug: Kiota.Builder.KiotaBuilder[0]
kiota version 1.28.0
info: Kiota.Builder.KiotaBuilder[0]
loaded description from local source
dbug: Kiota.Builder.KiotaBuilder[0]
step 1 - reading the stream - took 00:00:00.0083332
dbug: Kiota.Builder.KiotaBuilder[0]
step 2 - parsing the document - took 00:00:00.0841337
dbug: Kiota.Builder.KiotaBuilder[0]
step 3 - updating generation configuration from kiota extension - took 00:00:00.0001318
dbug: Kiota.Builder.KiotaBuilder[0]
step 4 - filtering API paths with patterns - took 00:00:00.0065592
warn: Kiota.Builder.KiotaBuilder[0]
No server url found in the OpenAPI document. The base url will need to be set when using the client.
dbug: Kiota.Builder.KiotaBuilder[0]
step 5 - checking whether the output should be updated - took 00:00:00.0346000
dbug: Kiota.Builder.KiotaBuilder[0]
step 6 - create uri space - took 00:00:00.0027734
dbug: Kiota.Builder.KiotaBuilder[0]
InitializeInheritanceIndex 00:00:00.0108185
dbug: Kiota.Builder.KiotaBuilder[0]
CreateRequestBuilderClass 00:00:00
dbug: Kiota.Builder.KiotaBuilder[0]
MapTypeDefinitions 00:00:00.0033737
dbug: Kiota.Builder.KiotaBuilder[0]
TrimInheritedModels 00:00:00
dbug: Kiota.Builder.KiotaBuilder[0]
CleanUpInternalState 00:00:00
dbug: Kiota.Builder.KiotaBuilder[0]
step 7 - create source model - took 00:00:00.0653511
dbug: Kiota.Builder.KiotaBuilder[0]
20ms: Language refinement applied
dbug: Kiota.Builder.KiotaBuilder[0]
step 8 - refine by language - took 00:00:00.0206971
dbug: Kiota.Builder.KiotaBuilder[0]
step 9 - writing files - took 00:00:00.0207780
info: Kiota.Builder.KiotaBuilder[0]
loaded description from local source
dbug: Kiota.Builder.KiotaBuilder[0]
step 10 - writing lock file - took 00:00:00.0069393
Generation completed successfully

Other information

The problem might have been introduced here: microsoft/kiota@51d995b

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status
Done ✔️

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions