We have an API using NSwag and its SwaggerUI. Our API includes enpoints with byte array members:
class SomeData
{
public int someField { get; set; } //Muse be a property otherwise it's not serialized
public byte[] someByteArray { get; set; }
}
Unfortunately, in SwaggerUI, the "suggested input" looks like this:
{
someField: 0,
someByteArray: "string",
}
"string"
is not valid base64 input (whereas "string=="
is).
And if we click Try it out, the JSON serialization silently fails and the API receives null
as input (for the entire input, not just the byte array) so we're left wondering which field is invalid until we find it's someByteArray
.
Is there a way to make someByteArray
default to a more reasonable value, like null
, "string=="
or ""
?
Also is there a way to make the JSON serialization failure non-silent?