OpenAPITools / OpenAPITools/openapi-generator
Invalid conversion from runtime type String to Integer
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Generated test classes fails with below error.
Error:
"System.TypeException: Invalid conversion from runtime type String to Integer"
Api where failure happens: -> 'propertyId' => (Integer) params.get('id')
public Attributes getAttributes(Map<String, Object> params) {
client.assertNotNull(params.get('id'), 'propertyId');
List<OAS.Param> query = new List<OAS.Param>();
List<OAS.Param> form = new List<OAS.Param>();
return (Attributes) client.invoke(
'GET', '/{id}/attributes', '',
query, form,
new Map<String, Object>{
'propertyId' => (Integer) params.get('id')
},
Api test where failure happens:
Map<String, Object> params = new Map<String, Object>{
'id' => ''
};
Doc:
"parameters": [
{
"name": "id",
"in": "path",
"description": "The unique identifier.",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
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 from the generated getAttributes method and its corresponding generated API test, then compare the OpenAPI path parameter schema with the value placed in params. Reproduce the String-to-Integer failure and identify the generator entry point responsible for this parameter conversion. Done means the generated test no longer raises the reported TypeException for the documented integer parameter.
Written by the indexing model from the issue text.
Assessment
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100