[BUG] [CSharp-netcore] model.vars.dataType is not equivalent to model.vars.items.dataType when you have a List of Dictionary
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator (example)?
- [ ] Have you tested with the latest master to confirm the issue still exists?
- [x] Have you searched for related issues/PRs?
- [x] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When I have a model with a property that is a List of Dictionary<x,y> the generated code is public List<Dictionary> MyProperty {get; set;} instead of public List<Dictionary<x,y>> MyProperty {get;set;} causing compilation issues (Using the generic type 'Dictionary<TKey, TValue>' requires 2 type arguments) . I have debugged the model and I noticed that model.vars.dataType is incorrect but model.vars.items.dataType is correct:
...
"name" : "ApplicationLayout",
"classname" : "ApplicationLayout",
"classVarName" : "ApplicationLayout",
"modelJson" : "{\r\n \"type\" : \"object\",\r\n \"properties\" : {\r\n \"elements\" : {\r\n \"type\" : \"array\",\r\n \"items\" : {\r\n \"$ref\" : \"#/components/schemas/ApplicationLayoutElements\"\r\n }\r\n },\r\n \"label\" : {\r\n \"type\" : \"string\"\r\n },\r\n \"options\" : {\r\n \"type\" : \"object\",\r\n \"additionalProperties\" : { }\r\n },\r\n \"rule\" : {\r\n \"$ref\" : \"#/components/schemas/ApplicationLayout_rule\"\r\n },\r\n \"scope\" : {\r\n \"type\" : \"string\"\r\n },\r\n \"type\" : {\r\n \"type\" : \"string\"\r\n }\r\n }\r\n}",
"dataType" : "Object",
"classFilename" : "ApplicationLayout",
"isAlias" : false,
"isString" : false,
"isInteger" : false,
"isLong" : false,
"isNumber" : false,
"isNumeric" : false,
"isFloat" : false,
"isDouble" : false,
"isDate" : false,
"isDateTime" : false,
"isDecimal" : false,
"isShort" : false,
"isUnboundedInteger" : false,
"isPrimitiveType" : false,
"isBoolean" : false,
"additionalPropertiesIsAnyType" : false,
"vars" : [ {
"openApiType" : "array",
"baseName" : "elements",
"getter" : "getElements",
"setter" : "setElements",
"dataType" : "List<Dictionary>", <-- INCORRECT
"datatypeWithEnum" : "List<Dictionary>", <-- INCORRECT
"name" : "Elements",
"defaultValueWithParam" : " = data.elements;",
"baseType" : "List",
"containerType" : "array",
"jsonSchema" : "{\r\n \"type\" : \"array\",\r\n \"items\" : {\r\n \"$ref\" : \"#/components/schemas/ApplicationLayoutElements\"\r\n }\r\n}",
"exclusiveMinimum" : false,
"exclusiveMaximum" : false,
"required" : false,
"deprecated" : false,
"hasMoreNonReadOnly" : false,
"isPrimitiveType" : true,
"isModel" : false,
"isContainer" : true,
"isString" : false,
"isNumeric" : false,
"isInteger" : false,
"isShort" : false,
"isLong" : false,
"isUnboundedInteger" : false,
"isNumber" : false,
"isFloat" : false,
"isDouble" : false,
"isDecimal" : false,
"isByteArray" : false,
"isBinary" : false,
"isFile" : false,
"isBoolean" : false,
"isDate" : false,
"isDateTime" : false,
"isUuid" : false,
"isUri" : false,
"isEmail" : false,
"isNull" : false,
"isFreeFormObject" : false,
"isAnyType" : false,
"isArray" : true,
"isMap" : false,
"isEnum" : false,
"isReadOnly" : false,
"isWriteOnly" : false,
"isNullable" : false,
"isSelfReference" : false,
"isCircularReference" : false,
"isDiscriminator" : false,
"items" : {
"openApiType" : "object",
"baseName" : "Elements",
"getter" : "getElements",
"setter" : "setElements",
"dataType" : "Dictionary<string, Object>", <-- CORRECT
"datatypeWithEnum" : "Dictionary<string, Object>", <-- CORRECT
"name" : "Elements",
"defaultValueWithParam" : " = data.Elements;",
"baseType" : "Dictionary",
"containerType" : "map",
"jsonSchema" : "{\r\n \"type\" : \"object\",\r\n \"additionalProperties\" : true\r\n}",
...
openapi-generator version
6.2.0
OpenAPI declaration file content or url
Generation Details
openapi-generator-cli generate -g csharp-netcore -i input.yaml
Steps to reproduce
1- Use the spec provided above
2- Run openapi-generator-cli generate -g csharp-netcore -i input.yaml
3- Verify the generated code
Related issues/PRs
Suggest a fix
It seems that model.vars.items.dataType looks fine so I'd suggest porting the same logic to model.vars.dataType