swagger-api / swagger-api/swagger-codegen
Swagger codegen generates a nullable integer as method return value in SDK for operation that returns an integer
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I have an operation which returns an integer, and when I generate a C# SDK using codegen, the method associated with the operation returns a nullable integer instead of an integer. I tried to set the produced response schema as required using an operation filter and setting the default value as 0 but it had no effect.
Here is the definition of my operation responses:
"responses":{
"200":{
"description":"Success",
"schema":{
"format":"int32",
"default":0,
"required":[
"200"
],
"type":"integer"
}
}
}
Thank you for any insight
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 reproducing C# SDK generation in Swagger codegen with the provided response schema, then inspect the generated operation method and the C# generation templates involved. Done means an operation returning a required integer produces a non-nullable integer return value rather than a nullable integer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100