【问题标题】:How should mulitiple query string parameters be presented in swaggers?多个查询字符串参数应该如何swaggers呈现?
【发布时间】:2019-05-17 20:42:11
【问题描述】:

我希望api能够接受多个查询字符串,例如:

GET /{id}?expand=property1,property2

我将 api 定义为:

public Task<IActionResult> GetAsync([FromRoute] string id, [FromQuery] Expandable expand)

并将Flag Enum Epandable定义为:

        [Flags]
        [JsonConverter(typeof(StringEnumConverter))]
        public enum Expandable
        {
            None = 0x0,
            Property1= 0x1,
            Property2 = 0x2,
            Property3 = 0x3
        }

而参数“expand”的招摇生成为

          {
            "name": "$expand",
            "in": "query",
            "description": "",
            "required": true,
            "type": "string",
            "default": "None",
            "enum": [
              "none",
              "property1",
              "property2",
              "property3"
            ]
          },

但是有了这个招摇,自动生成客户端接受一个字符串,我不确定应该如何呈现招摇,所以自动生成的客户端也会接受一个标志枚举?

【问题讨论】:

标签: c# swagger query-string autogen


【解决方案1】:

你应该使expand参数Expandable[]你的标志被错误地声明What does the [Flags] Enum Attribute mean in C#?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-17
    • 2014-12-28
    • 1970-01-01
    • 2018-04-14
    • 1970-01-01
    相关资源
    最近更新 更多