swagger-ui
swagger-ui copied to clipboard
Nullable int is with a default value of null is still getting POST with Zero
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?
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?
Please post the generated swagger json.
I cannot post my swagger or code on here, the company I work for is extremely sensitive about this. On the hand we are allowed to use tools like Postman /shrug
I can say when I import swagger openapi.json into Postman the models are correctly displayed. For example: if I open one of the POST actions to add a new entity then "MyAttrid" : null and not zero. This works as expected. I have recommended to the tester that they 'test' via Postman and not via the swagger UI. thanks
Could you share just the part of the generated schema with only the number in it. Or look at the schema and create a minimal reproduction schema definition.