OpenAPI spec does not work with swagger-codegen

(theduke) #1

It’s awesome that there is a official OpenAPI spec at

BUT swagger-codegen, the goto tool for generating API clients, does not work with the spec.

It errors out with

"Exception in thread "main" java.lang.RuntimeException: missing swagger input or config!
at io.swagger.codegen.DefaultGenerator.generate(
at io.swagger.codegen.SwaggerCodegen.main("

This seems to be an indicator of a invalid spec (java.lang.RuntimeException: missing swagger input or config! (parse error?) · Issue #1351 · swagger-api/swagger-codegen · GitHub) or otherwise a bug in swagger, but probably the former.

(Andrew Duncan) #2

Hey theduke,

I ran into this same problem. I don’t have a fix, but I’m working my way to my own solution. I’ll post my findings here in hopes that it helps someone else, or if someone else finds a better way.

If you put the spec in the Swagger Editor (, it will show you the errors.

There are quite a lot. If you only need a subset of those endpoints, you could remove all endpoints from the swagger.json you do not need and use the remaining with swagger codegen. For example, I only am interested in the endpoints for creating topics, so I only include the one.

Note that a lot of the errors this shows are not the actual errors. There may be some true errors within the endpoint that cause an error, which is giving these false errors. Fixing these true errors will get rid of these false errors. Luckily the errors are somewhat consistent between endpoints, so solving one error will solve a few others.

It will require a basic understanding of swagger, I recommend looking at discourse/ at master · discourse/discourse · GitHub.

Authentication doesn’t seem to work out of the box, you’ll need to play around to get it to work. Also you may run into CSRF errors if you are testing your mutated spec with swagger UI, which unfortunately I do not have a solution for yet.