Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enums as ints #2498

Closed
langdonx opened this issue Apr 5, 2016 · 8 comments
Closed

Enums as ints #2498

langdonx opened this issue Apr 5, 2016 · 8 comments

Comments

@langdonx
Copy link

langdonx commented Apr 5, 2016

Update: Enums as strings seem to work fine. Enums as ints used to work fine (they would generate as int?, I'm using csharp), but in master now, they throw the following error:

Exception in thread "main" java.lang.RuntimeException: Could not process model 'IncidentByLocationReportRequest'
    at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:244)
    at io.swagger.codegen.cmd.Generate.run(Generate.java:223)
    at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:36)
Caused by: java.lang.ArrayStoreException
    at java.lang.System.arraycopy(Native Method)
    at java.util.ArrayList.toArray(Unknown Source)
    at io.swagger.codegen.languages.CSharpClientCodegen.findCommonPrefixOfVars(CSharpClientCodegen.java:422)
    at io.swagger.codegen.languages.CSharpClientCodegen.postProcessModels(CSharpClientCodegen.java:317)
    at io.swagger.codegen.DefaultGenerator.processModels(DefaultGenerator.java:833)
    at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:237)
    ... 2 more

The spec for that particular type:

IncidentByLocationReportRequest:{  
  type:"object",
  properties:{  
    endDate:{  
      format:"date-time",
      type:"string"
    },
    startDate:{  
      format:"date-time",
      type:"string"
    },
    incidentCategoryId:{  
      format:"int32",
      type:"integer"
    },
    clientLocationIds:{  
      type:"array",
      items:{  
    format:"int32",
    type:"integer"
      }
    },
    reportType:{  
      format:"int32",
      enum:[  
    0,
    1,
    2,
    3
      ],
      type:"integer"
    },
    severityLevel:{  
      format:"int32",
      type:"integer"
    }
  }
},
@langdonx langdonx changed the title Enumeration property -- could not process model error, without a lot of detail Enums as ints Apr 5, 2016
@wing328
Copy link
Contributor

wing328 commented Apr 5, 2016

@langdonx I've something ready to address the issue and will submit the fix after the v2.1.6 stable relese due today/tomorrow.

@wing328
Copy link
Contributor

wing328 commented Apr 6, 2016

@langdonx I've submitted #2508.

I wonder if you can give it a try to confirm it addresses the issue for your case.

@langdonx
Copy link
Author

langdonx commented Apr 6, 2016

Works again, thanks! It's back to doing int? which makes sense since the names aren't available in the spec.

@jimschubert
Copy link
Contributor

@langdonx What was the fix for this? Did you generate against master?

@langdonx
Copy link
Author

langdonx commented May 2, 2016

@jimschubert yes, master. should be fixed in 2.2.0.

@langdonx
Copy link
Author

langdonx commented May 2, 2016

@jimschubert Oops, you know what, I actually pulled down wing's fork and branch from the pull request.

@jimschubert
Copy link
Contributor

@langdonx sorry, when I commented yesterday @wing328's messages weren't visible. I guess github has a limit on how actively you can contribute and rate limited him ;)

@wing328
Copy link
Contributor

wing328 commented May 3, 2016

@langdonx I've merged #2508 into master. I wonder if you can pull the latest master and give it a try.

@wing328 wing328 closed this as completed May 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants