小编Rak*_*tha的帖子

如何使用 Swashbuckle 在 Swagger 中将复杂对象作为查询字符串传递

我有一个复杂的对象要在 ASP.Net Core 3.2 中作为查询字符串传递。

public class Customer
{
    public string Firstname { get; set; }
    public List<Address> Addresses { get; set; }
}

public class Address
{
    public string Home_Address { get; set; }
    public string Office_Address { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

它在 Postman 中的工作方式如下:

http://localhost:52100/v1/Customer?Addresses[0].Home_Address=123HomeStreet&Addresses[0].Office_Address=123OfficeStreet
Run Code Online (Sandbox Code Playgroud)

但是,如何在地址类型为“array[object](查询)”的 Swagger 文档中传递值 http://localhost:52100/v1/swagger-ui/index.html

我在我的项目中添加了 Swashbuckle.AspNetCore 5.4.1、Swashbuckle.AspNetCore.Annotations 5.4.1、Swashbuckle.AspNetCore.Filters 5.1.1 引用

c# http-get swagger swashbuckle asp.net-core

5
推荐指数
1
解决办法
1764
查看次数

标签 统计

asp.net-core ×1

c# ×1

http-get ×1

swagger ×1

swashbuckle ×1