Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
Herrick19 opened this issue Nov 5, 2022 · 0 comments · Fixed by #16315
Closed
4 tasks done

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

Herrick19 opened this issue Nov 5, 2022 · 0 comments · Fixed by #16315

Comments

@Herrick19
Copy link
Contributor

Herrick19 commented Nov 5, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant