0

I want the api to be able to accept multiple query strings, for example:

GET /{id}?expand=property1,property2

I have the api defined as:

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

And Flag Enum Epandable defined as:

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

And the swagger for parameter "expand" generated as

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

But with this swagger, the auto-gen client takes in a string, I am not sure how the swagger should be presented so the auto-generated client would also take in a Flag Enum?

Yituo
  • 1,458
  • 4
  • 17
  • 26
  • 1
    you should make `expand` parameter `Expandable[]` also your flag is declared incorrectly https://stackoverflow.com/questions/8447/what-does-the-flags-enum-attribute-mean-in-c – Greg May 17 '19 at 20:54

1 Answers1

0

you should make expand parameter Expandable[] also your flag is declared incorrectly What does the [Flags] Enum Attribute mean in C#?

Greg
  • 346
  • 1
  • 10