-
Notifications
You must be signed in to change notification settings - Fork 6k
C# - Lists of enums not properly generated #2714
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
Comments
@JoshuaWhatley thanks for reporting the issue. We've a fix here: #2508 Do you mind performing a fix to see if it works for you? Also we welcome PR on top of #2508 to make it better. |
One remaining issue after applying the fix in #2508 Expected
Actual
I'll take a look at it. |
@JoshuaWhatley thanks (I'll do a rebase on the latest master later today) |
I believe this issue is present for Dictionaries as well. Expected
Actual
Swagger doc:
|
Right, I don't think I've done anything specified to Array or Dictionary yet. |
Understood, I thought it should be mentioned. Great work by the way, this is a super cool project. |
@JoshuaWhatley thanks for the positive feedback :) It's worth mentioning to you that you can also generate ASP.NET5 server stub using Swagger Codegen given the OpenAPI/Swagger spec. |
@JoshuaWhatley I've merged #2508 into master. We'll work on enum support for array and dictionary later this week or early next week. |
Novice: Our very small two cents ;-) We currently develop solutions in two worlds… LoopBack/Node.js & WebApi/Asp.net We would love to have a solution that complements each others interpretation of the concepts around
We currently use swagger to generate both client/server code for LoopBack & .NET, and client code in Java and PHP. When it comes to Enum and Additional Properties we have to deal with exceptions because like HTML specs each community is interpreting the specifications a little differently rather than each community discussing the discrepancy to improve the understanding and interpreting of the Swagger Specs. Here is StrongLooop / Loopback discussion around Enums Here is how AutoRest community is currently dealing with Enums with AutoRest
We still need to investigate where the StrongLoops/ IBM thoughts on implementing Enum, and we plan to review shortly. We just propose that all participants in providing a Swagger Code Generators to deal with Enum to converge on a solution rather than have a lot of silo implementations of swagger generic extensions for Enum. We have investigated the following code generators to date. Non have a consist implementation to deal with Additional Properties or Enum Appreciate feedback, concerns and issues with our thoughts… |
I haven't looked at the issue at hand with Enums, Lists, or Dictionaries. @wing328 did you make any progress on this issue? @aws-na-ss-usplu Since you've put a lot of research into your comment, I wanted to address it somewhat in depth.
The Loopback issue you pointed to is more about implementing enum support correctly in the datasource abstraction and emitting the swagger definition correctly against the JSON Schema enum specification (http://json-schema.org/latest/json-schema-validation.html#anchor76). Your first link to Autorest highlights the main problem. There can be no standard representation across all languages for an enum, because not all languages support enums and those that do don't support them in exactly the same way. For example, these are all valid enums in C#:
And this is a valid Java enum:
To support a universal definition of an enum would be complex. I'll touch on this briefly, since you asked for some feedback. I'm assuming this complexity is why Microsoft has prefixed their vendor extensions with At this point, most languages will be able to support the enum definition natively, even if it's quite a bit of code. Now if you try to support Then, you have an example of a valid enum in Java.
At this point, you'd need to indicate that That last example brings it back around to the Loopback example. Their implementation may have additional metadata applied to the enum. It may result in an object representation rather than an enum. |
UPDATE: For dictionary property/member (enum or not), there's a fundamental issue that I'm working on. |
Awesome. Thanks for the update. |
@JoshuaWhatley @jimschubert UPDATE: I've filed #3199 to support array/map (any dimensions) of enum in C#. |
That's exciting! I'll take a look. Thanks for looking into this, it is very appreciated! |
@jimschubert, The question is not how to get disparities between software implementers to agree on how they should implement enumerated types. If that was possible then world peace is achievable and global warming would not be a discussion. 😆 Similar issue existed a long time ago (10+ years ago) when XML/XSD /SOAP/WSDL where the cool kids 😎 on the block. The XML Schema Pattern defined Common Data Structures so that the concept of an enumeration is usable by all code generators. These tools still exist and allow Java solutions to communicate with .NET solutions or Loopback solutions using the enumerated types defined in the schema. Mea Culpa, it appears that my question was not clear. The concern is will each faction work towards a consensus with usage of JSON, JSON Schema, and Swagger / OPEN API so the code generators interpret an Enum is an Enum regardless of the underling implementation by each interested party. My intention is to raise a concern so that each group can provide input into shaping the use of JSON so that it is as meaningful as XML yet hopeful without all of the bloat and verboseness. We just had a industry accord on Swagger vs WADL vs RAML vs (the others) since this past winter that OPEN API (Swagger) is leading the pack. |
@JoshuaWhatley @jimschubert PR merged into master. |
@JoshuaWhatley closing this issue for the time being. Let us know if you've any questions. @aws-na-ss-usplu I would suggest you to open a ticket for |
SwashBuckle will generate a swagger json similar to the following for List. The generated client code contains a couple mistakes.
Swagger Doc:
I have a fix, but it is leveraging a hack written by a previous contributor. I'll submit a pull request so that we can discuss.
The text was updated successfully, but these errors were encountered: