Ask a Question

Codegen feature not working

alex-estela
New Contributor

Codegen feature not working

Hi all,

 

I am trying to use the "Codegen" feature of SwaggerHub. However it always results in a "SwaggerHub Error".

 

The spec of my API is valid according to the SwaggerHub parser. I also configured the generation feature using the "Edit Codegen Options" window. I tried different types of generation (client, server, different languages) but it still results in an error.

 

Are there other attention points I could have missed ? Any advice on how to debug this issue ?

 

Thanks in advance for your support.

Alex

5 REPLIES 5
fehguy
Staff

Hi Alex,

 

Sorry to hear! Is your definition public?  If so I'd be happy to look at it to see what is putting the codegen in a tizzy.  Also what language/target are you building?

-----
Tony Tam
SmartBear VP of Swagger Products

Hi Tony,

 

Yes, the definition is public : https://swaggerhub.com/api/estela/piframe/0.0.3

 

I am using Java, and tried to generate Inflector-based Server-side sources.

 

Alex

 

Hi, thanks for sharing.  I've found a couple things:

 

* The swagger-parser (used by codegen) doesn't seem to like having an "allOf" item with just one value.  I've logged that and we'll get it fixed in SwaggerHub as well as OSS.

* The codegen seems to like having the $ref as the first array item.  It shouldn't care, so that's a bug.  To work around it, just move the $ref to the first item

 

With that, here's your definition updated and working for java client and inflector.  Note that for the allOf constructs with one item, I just made it a simple model.  You may need to change that if you're going to extend them.

 

https://swaggerhub.com/api/fehguy/piframe/0.0.3

 

Let me know when you have pulled the changes into your version and I'll delete my fork.

-----
Tony Tam
SmartBear VP of Swagger Products

Tony,

 

Thanks a lot for your support. Glad it also helped to identify these bugs in Swagger-parser and Swagger-codegen. Great pieces of software that you have been building, btw.

 

I understood and copied your changes in my own API definition, so you can safely delete your fork.

 

Alex

 

 

Great, and thanks for the follow-up!

-----
Tony Tam
SmartBear VP of Swagger Products
cancel
Showing results for 
Search instead for 
Did you mean: