title: Autorest + Swagger does not generate ENUMs properly
body: <p>I have two applications <strong>A</strong> and <strong>B</strong>. On <strong>A</strong> I use swagger for describing an API. On <strong>A</strong> I have also the definitions of classes with some enums properties.
  I want to generate a client API on <strong>B</strong>. For this I use Autorest. Everything works fine except one thing - enums. For some reason the enums are not generated properly and a type of properties (which were originally enum) are type of string or int (depends on the use of <em>DescribeAllEnumsAsStrings()</em>. I used it in example below so it is string in this case).</p>
  
  <p>Enum definition generated JSON by swagger:</p>
  
  <pre><code>        "Car": {
          "properties": {
              "color": {
                  "enum": [
                      "Red",
                      "Blue",
                      "Green"
                  ],
                  "type": "string"
              }
          },
          "type": "object"
      }
  </code></pre>
  
  <p>Swagger registraion in Startup.cs</p>
  
  <pre><code>// Register the Swagger generator, defining one or more Swagger documents
          services.AddSwaggerGen(c =&gt;
          {
              c.SwaggerDoc("v1", new Info { Title = "Car API", Version = "v1" });
              c.AddSecurityDefinition("Bearer", new ApiKeyScheme { In = "header", Description = "description", Name = "Authorization", Type = "apiKey" });
              c.DescribeAllEnumsAsStrings();
          });
  </code></pre>
  
  <p>Autorest command:</p>
  
  <pre><code>autorest --input-file=http://localhost:55448/swagger/v1/swagger.json --csharp --namespace=Online.Integrations.Api.Service.Car --output-folder=. 
  </code></pre>
  
  <p>Generated class (string instead of enum):</p>
  
  <pre><code>    public partial class Car
  {
      /// &lt;summary&gt;
      /// Initializes a new instance of the Car class.
      /// &lt;/summary&gt;
      public Car()
      {
        CustomInit();
      }
  
      /// &lt;summary&gt;
      /// Initializes a new instance of the Car class.
      /// &lt;/summary&gt;
      /// &lt;param name="application"&gt;Possible values include: 'Any', 'Web'
      /// ...
      /// &lt;/param&gt;
      public Car(string color = default(string))
      {
          Color = color;
      }
  
      /// &lt;summary&gt;
      /// An initialization method that performs custom operations like setting defaults
      /// &lt;/summary&gt;
      partial void CustomInit();
  
      /// &lt;summary&gt;
      /// &lt;/summary&gt;
      [JsonProperty(PropertyName = "color")]
      public string Color { get; set; }
  }
  </code></pre>
  
  <p>I found this: <a href="https://github.com/Azure/autorest/tree/master/docs/extensions#x-ms-enum" rel="noreferrer">https://github.com/Azure/autorest/tree/master/docs/extensions#x-ms-enum</a> </p>
  
  <p>there is some x-ms-enum extension but i have no idea how use it. I tryed edit JSON definition manually (what i did in example below) but it was also unsuccessful. Generated class contains <em>object color = default(object)</em> instead of string as in first example, not enum.</p>
  
  <pre><code>    "color": {
              "type": "string",
              "enum": [
                  "Red",
                  "Blue",
                  "Green"
              ],
              "x-ms-enum": {
                  "name": "Color",
                  "modelAsString": false
       },
  </code></pre>
  
  <p>I'll be glad for any help. Thanks!</p>
  
  <p>Edit: 
  <strong>1) Full Swagger definition (result type : Sting):</strong></p>
  
  <p><em>In swagger def. is "type": "string" right after enum definition</em></p>
  
  <pre><code> {"swagger":"2.0","info":{"version":"v1","title":"Audit Overseer API"},"basePath":"/","paths":{"/api/Audit":{"get":{"tags":["Audit"],"operationId":"ApiAuditGet","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"Id","in":"query","required":false,"type":"string"},{"name":"Application","in":"query","required":false,"type":"string","enum":["Any","Alfa","Beta"]},{"name":"DatabaseName","in":"query","required":false,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"type":"array","items":{"$ref":"#/definitions/Transaction"}}}}}}},"definitions":{"Transaction":{"type":"object","properties":{"callId":{"type":"string"},"actionName":{"type":"string"},"application":{"enum":["Any","Alfa","Beta"],"type":"string"},"httpStatusCode":{"type":"string"},"dateTime":{"format":"date-time","type":"string"}}}},"securityDefinitions":{"Bearer":{"name":"Authorization","in":"header","type":"apiKey","description":"Please insert JWT with Bearer into field"}}}
  </code></pre>
  
  <p>autorest execution:</p>
  
  <p><a href="https://i.stack.imgur.com/KszOa.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KszOa.png" alt="autorest execution"></a>
  result:</p>
  
  <p><a href="https://i.stack.imgur.com/y6Vy4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/y6Vy4.png" alt="result"></a></p>
  
  <p><strong>2) Full Swagger definition (result type : Object):</strong></p>
  
  <p><em>In swagger def. my experiment with "x-ms-enum" right after enum definition</em></p>
  
  <pre><code>{"basePath":"/","definitions":{"Transaction":{"properties":{"actionName":{"type":"string"},"application":{"enum":["Any","Alfa","Beta"],"x-ms-enum":{"modelAsString":false,"name":"Application"}},"callId":{"type":"string"},"dateTime":{"format":"date-time","type":"string"},"httpStatusCode":{"type":"string"}},"type":"object"}},"info":{"title":"Audit Overseer API","version":"v1"},"paths":{"/api/Audit":{"get":{"consumes":[],"operationId":"ApiAuditGet","parameters":[{"in":"query","name":"Id","required":false,"type":"string"},{"enum":["Any","Alfa","Beta"],"in":"query","name":"Application","required":false,"type":"string"},{"in":"query","name":"DatabaseName","required":false,"type":"string"}],"produces":["text/plain","application/json","text/json"],"responses":{"200":{"description":"Success","schema":{"items":{"$ref":"#/definitions/Transaction"},"type":"array"}}},"tags":["Audit"]}}},"securityDefinitions":{"Bearer":{"description":"Please insert JWT with Bearer into field","in":"header","name":"Authorization","type":"apiKey"}},"swagger":"2.0"}
  </code></pre>
  
  <p><em>...or I can keep it empty. Result is same</em></p>
  
  <pre><code>{"basePath":"/","definitions":{"Transaction":{"properties":{"actionName":{"type":"string"},"application":{"enum":["Any","Alfa","Beta"]},"callId":{"type":"string"},"dateTime":{"format":"date-time","type":"string"},"httpStatusCode":{"type":"string"}},"type":"object"}},"info":{"title":"Audit Overseer API","version":"v1"},"paths":{"/api/Audit":{"get":{"consumes":[],"operationId":"ApiAuditGet","parameters":[{"in":"query","name":"Id","required":false,"type":"string"},{"enum":["Any","Alfa","Beta"],"in":"query","name":"Application","required":false,"type":"string"},{"in":"query","name":"DatabaseName","required":false,"type":"string"}],"produces":["text/plain","application/json","text/json"],"responses":{"200":{"description":"Success","schema":{"items":{"$ref":"#/definitions/Transaction"},"type":"array"}}},"tags":["Audit"]}}},"securityDefinitions":{"Bearer":{"description":"Please insert JWT with Bearer into field","in":"header","name":"Authorization","type":"apiKey"}},"swagger":"2.0"}
  </code></pre>
  
  <p><em>(now lets execute same autorest command as before)</em></p>
  
  <p>and result is:</p>
  
  <p><a href="https://i.stack.imgur.com/lSIIU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lSIIU.png" alt="enter image description here"></a></p>