swagger-api / swagger-api/swagger-ui
Nullable int is with a default value of null is still getting POST with Zero
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
In my model I have the following definied:
[DefaultValue(null)]
public int? MyAttrId { get; set; }
When swagger is opened the generated json shows as "MyAttrid" : 0
I had expected "MyAttrid" : null
The Post to my endpoint controller has default Zero when Null was expected.
Is there a setting or another attribute available to fix this?
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
No repository file, test, or entry point is named. First determine whether the payload is generated by Swagger UI or by the C# server serializer, then establish a repository-level reproduction and expected null behavior; done requires a maintainer-confirmed fix or confirmation that the behavior is outside Swagger UI.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100