autorest icon indicating copy to clipboard operation
autorest copied to clipboard

Can't specify non-nullable enums

Open emgerner-msft opened this issue 10 years ago • 3 comments

I'm trying to require users to send an enum value as a parameter. I create an enum like the following and make it required. I was hoping this would make it not nullable. However, it still makes the enum settable to null (Kind? instead of Kind) which to users looks like they can send null. That is absolutely not true at least in this case. I'd assume requiring an enum means it shouldn't be nullable, but if we want to default to that, it would still be nice to have a property to specify that.

    "kind": {
      "type": "string",
      "enum": [
        "Xyz",
        "Abc"
      ],
      "x-ms-enum": {
        "name": "Kind",
        "modelAsString": false
      }
    }

emgerner-msft avatar Mar 25 '16 00:03 emgerner-msft

Related issue: https://github.com/Azure/autorest/issues/375

Looks like the enum case was missed in that fix.

bitsforthought avatar Apr 05 '16 19:04 bitsforthought

@emgerner-msft I've fixed the underlying issue in a branch (so Enums aren't getting nullable if it's a required field.) What you experienced was a side effect of something else.

If you'd like to test that I can send you private bits.

fearthecowboy avatar Sep 28 '16 19:09 fearthecowboy

Fix promoted to master

fearthecowboy avatar Nov 08 '16 03:11 fearthecowboy