Skip to content

[BUG][C#] Compile error in csharp when array of object #13924

@Herrick19

Description

@Herrick19

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

Using the csharp generator with an array of objects produce code that cannot be compiled.

I have provided a minimal file to reproduce the problem and an example of the generated code that doesn't compile.

I have also provided the manual fix I need to do everytime I generate code

basically, it's just a minor fix to change:
List<Dictionary>
to
List<Dictionary<string, object>>

OpenAPI declaration file content or url
openapi: 3.0.3
info:
    title: Test
    version: 1.0.0.0
servers:
    -
        url: 'https://www.example.com'
paths:
    /test:
        get:
            responses:
                '200':
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/notificationtest-getElements-v1-Response-mPayload'
                    description: Successful response
            operationId: Test
            summary: Retrieve an existing Notificationtest's Elements
components:
    schemas:
        Custom-Variableobject-Response:
            description: A Variable object without predefined property names
            type: object
            additionalProperties: true
        Field-pkiNotificationtestID:
            type: integer
        notificationtest-getElements-v1-Response-mPayload:
            required:
                - pkiNotificationtestID
                - a_objVariableobject
            type: object
            properties:
                pkiNotificationtestID:
                    $ref: '#/components/schemas/Field-pkiNotificationtestID'
                a_objVariableobject:
                    type: array
                    items:
                        $ref: '#/components/schemas/Custom-Variableobject-Response'
Steps to reproduce
Suggest a fix

The generated code is like this:

        public NotificationtestGetElementsV1ResponseMPayload(int pkiNotificationtestID = default(int), List<Dictionary> aObjVariableobject = default(List<Dictionary>))

It should be like this:

        public NotificationtestGetElementsV1ResponseMPayload(int pkiNotificationtestID = default(int), List<Dictionary<string, object>> aObjVariableobject = default(List<Dictionary<string, object>>))

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions