Closed doublefint closed 1 year ago
@doublefint perhaps you can provide a bit more context about what you want to have.
Obviously there is a bug here because of the type mismatch and we should fix thus, but i am wondering what the use case of integer enums is? If you have a list of 5 integers that are allowed, you probably can't use any of the natural properties of integers then.
For future posterity, can you help document why and make sure we don't forget the use case.
@LucasRoesler Thank you very much for the quick response!
There are many areas of human activity in which well-known numbers are used. Right now I can give the following examples: In IT, powers of 2 are widely used - 1024, 2048, 4096. When estimating time costs for developing functionality, it is recommended to use the Fibonacci number sequence. In the production of building materials, you will have your own number series for sizes, depending on the parameters of your equipment - 1.5x, 2x, 3x. In trading goods, the quantity of goods in various packages.
Therefore, when developing software for one of these industries, you will need a way to limit the value for a numeric property by selecting from such a "well-known in this area" numerical series.
BTW, the bug is not only with the incorrect type, but also with the sorting of values - see comments in the generated code.
Sounds good.
I am on a break this week, so i can take a look and patch it next week (or this weekend)
@doublefint PR #98 should resolve this now
I didn't change anything with the sorting because it isn't clear why it would be an issue, the the order in which they are defined in the file doesn't change anything about how the types will work or how the validation will work. Please let me know if an actual Go error that can occur because they are sorted in a different order.
Hi, Contiamo! Input:
Output:
https://github.com/contiamo/openapi-generator-go/blob/master/pkg/generators/models/models.go#L774 https://github.com/contiamo/openapi-generator-go/blob/master/pkg/generators/models/models.go#L779