Swagger Enum handling in Swagger-Core and Swagger-Codegen

1,279 views
Skip to first unread message

Michael P

unread,
Apr 22, 2016, 11:28:08 AM4/22/16
to Swagger
We're currently using Swagger-Core with Jersey to document our REST API. A large part of our API is used to expose out a legacy (non-RESTful) API with 400-some API's. This API uses a lot of enums in model classes, and has some particularly large enums that are used for responses. 

The current method of treating enums like a set of String values instead of a first-class, top-level model means that every instance of our enum is duplicated wherever it is present in the Swagger Spec for our API. 

I'd like to see enums treated as a top-level model class. Is this something that would be incredibly difficult or impossible to add into Swagger-Core? I could potentially look into making these changes myself, if it's doable. 

Thanks,

Michael

John Creps

unread,
Apr 22, 2016, 12:24:45 PM4/22/16
to swagger-sw...@googlegroups.com

I believe this is something I could use as well.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

tony tam

unread,
Apr 22, 2016, 4:27:10 PM4/22/16
to swagger-sw...@googlegroups.com
Can you please make sure an issue is opened on swagger-core for this?

parris...@ascom.com

unread,
May 4, 2016, 11:04:48 AM5/4/16
to Swagger
 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

  • Generic Extensions for Enum
  • Implement of Enum
  • Solution path to transition from Swagger Extension to first class member of Swagger 2.x schema

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 Swagger API discussion around ENUMs for C-Sharp


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…
Reply all
Reply to author
Forward
0 new messages