最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

json - NSwag SwaggerUI suggests "string" as input for a byte array member - Stack Overflow

programmeradmin2浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论