swagger-api / swagger-api/swagger-codegen
[C#] API body parameter with Map/Dictionary Properties converting to object instead of Dictionary.
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
API body parameter with Map/Dictionary Properties converting to object instead of Dictionary.
Response with Map/Dictionary Properties converting to Dictionary. we are expecting same behavior in parameters also. below spec generates "ResourceApi.cs" file
Methods:
Dictionary<string, Resource> GetResource (Object resourceParameters);
ApiResponse<Dictionary<string, Resource>> GetResourceWithHttpInfo (Object resourceParameters);
System.Threading.Tasks.Task<Dictionary<string, Resource>> GetResourceAsync (Object resourceParameters);
System.Threading.Tasks.Task<ApiResponse<Dictionary<string, Resource>>> GetResourceAsyncWithHttpInfo (Object resourceParameters);
In above methods instead of Object we are expecting Dictionary<string, ResourceParameters>
Swagger-codegen version
Swagger-codegen version
Swagger Editor
Swagger declaration file content or url
{
"swagger": "2.0",
"info": {
"description": "sample",
"version": "1.0.0",
"title": "Swagger sample",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "test@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "test.swagger.io",
"basePath": "/v2",
"tags": [
{
"name": "Resource",
"description": "Everything about resource"
}
],
"schemes": [
"http"
],
"paths": {
"/Resources": {
"get": {
"tags": [
"Resource"
],
"summary": "Find Resource",
"description": "",
"operationId": "getResource",
"produces": [
"application/json"
],
"parameters": [
{
"name": "ResourceParameters",
"in": "body",
"description": "ResourceParameters object that needs to be added",
"required": true,
"schema": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/ResourceParameters"
}
}
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Resource"
}
}
},
"400": {
"description": "Invalid status value"
}
}
}
}
},
"definitions": {
"Resource": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"username": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"email": {
"type": "string"
},
"password": {
"type": "string"
},
"phone": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string"
},
"userStatus": {
"type": "integer",
"format": "int32",
"description": "User Status"
}
}
},
"ResourceParameters": {
"properties": {
"firstName": {
"type": "string",
"description": "firstName"
},
"lastName": {
"type": "string",
"description": "lastName"
},
"skip": {
"type": "integer",
"description": "skip"
},
"top": {
"type": "integer",
"description": "top"
}
}
}
}
}
Command line used for generation
Steps to reproduce
Related issues
Suggest a Fix
API body parameter with Map/Dictionary Properties converting to object instead of Dictionary.
Response with Map/Dictionary Properties converting to Dictionary. we are expecting same behavior in parameters also.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied Swagger 2.0 declaration and the generated ResourceApi.cs signatures. Trace how the body parameter schema with additionalProperties is mapped for C# parameters, comparing it with the response mapping. Done means the generated parameter uses Dictionary<string, ResourceParameters> rather than Object, with the behavior covered by an appropriate generator test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100