Skip to content

[REQ] [C#] Deserialize JSON empty array associated with additionalProperties #7418

Open
@wondergarance

Description

@wondergarance

Is your feature request related to a problem? Please describe.

I use openapi-generator 4.3.1 to generate a C# client from a yaml file (OpenAPI V3) with additionalProperties inside. A Dictionary<Tkey, Tvalue> is created with an ojbect as Tvalue.
eg:
yml:

debug-item-bean:
        tokens:
          type: object
          description: tokens
          additionalProperties:
            type: object
            description: debug-item-bean tokens dictionary
            properties:
              key:
                type: string
              value:
                type: array
                items:
                  type: string

C#:
Dictionary<string, DebugItemBeanTokens>

If the response of the endpoint has "tokens": [], I recevie an error:
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Tokens' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
So I should modify
Dictionary<string, DebugItemBeanTokens>
to
Dictionary<string, List<string>>

Describe the solution you'd like

I want to have an option to control empty arrays [] in openapi-generator, for class created from additionalProperties.

Has this issues done in the version 5.0.0?

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