Azure / Azure/azure-rest-api-specs
c# validation nullable value
- Dominant language
- TypeSpec
- Stars
- 3.1k
- Forks
- 5.9k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 444
Description
Hi,
We have a swagger spec with a value that is conditional/optional i.e. can be null with some validation constraints ("multipleOf": 0.001) this is presented like so:
```
"totalThroughputMibps": {
"type": "number",
"x-nullable": true,
"description": "Total throughput of pool in Mibps",
"example": 164.221,
"readOnly": true,
"multipleOf": 0.001
}
```
This causes issues with c# generated SDK where the validation code does not allow null values.
```
public double? TotalThroughputMibps { get; private set; }
.
.
.
.
.
if (TotalThroughputMibps % 0.001 != 0)
{
throw new ValidationException(ValidationRules.MultipleOf, "TotalThroughputMibps", 0.001);
}
```
Is it possible to present this in the swagger so that the validation in the generated code handles null values correctly?
ps I asked this in autorest repo as well but not getting any response there
https://github.com/Azure/autorest/issues/3585
Contributor guide
Assessment
This issue has not been assessed yet.