OpenAPITools / OpenAPITools/openapi-generator
[BUG][CSHARP-NETCORE] uint32 type is generating int types, which is out of range
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
Attempting to generate C# models for the Bungie API, using their openapi spec. Once generated and I deserialize the JSON, I get the following error: JSON integer 3612906877 is too large or small for an Int32

Upon investigation, the openapi file defines seasonHashes as
"seasonHashes": {
"description": "...",
"type": "array",
"items": {
"format": "uint32",
"type": "integer"
},
"x-mapped-definition": {
"$ref": "#/definitions/Destiny.Definitions.Seasons.DestinySeasonDefinition"
}
}
Note the uint32. The generated code however, defines SeasonHashes as int, which is a smaller range of values, which does not fit the value coming from the API
// BungieNetApi\Model\DestinyEntitiesProfilesDestinyProfileComponent.cs
[DataMember(Name="seasonHashes", EmitDefaultValue=false)]
public List<int> SeasonHashes { get; set; }
If I manually change, in the generated C# code, these types to longs, everything works.
It appears the generator incorrectly generates uint32 types as int.
openapi-generator version
4.3.0
OpenAPI declaration file content or url
https://raw.githubusercontent.com/Bungie-net/api/master/openapi-2.json
Command line used for generation
openapi-generator generate -i https://raw.githubusercontent.com/Bungie-net/api/master/openapi-2.json -g csharp-netcore -o ./csharp-netcore --skip-validate-spec -c ./config.json
// ./config.json
{
"packageName": "BungieNetApi"
}
Steps to reproduce
Related issues/PRs
Suggest a fix
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 by running the provided openapi-generator command against the Bungie openapi-2.json spec, then inspect BungieNetApi\Model\DestinyEntitiesProfilesDestinyProfileComponent.cs. Trace the uint32 mapping in the csharp-netcore generator and verify that the generated SeasonHashes type can deserialize the reported value 3612906877 without an Int32 range error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100