0

I have been trying to create a client stub for my front-end client using swagger-codegen. Following is the command that I've been using:

java -jar swagger-codegen-cli-2.2.2.jar generate -i "docs-endpoint" -l nodejs-server -o retrofit/ -c config.json

And following is the config :

{
  "apiPackage": "com.xyz.api",
  "modelPackage": "com.xyz.model",
  "groupId":"com.xyz.prototype",
  "artifactVersion":"1.0-SNAPSHOT",
  "artifactId":"xyz-api",
  "library":"retrofit"
}

But I am getting the following error :

Exception in thread "main" java.lang.RuntimeException: unknown library: retrofit
    at io.swagger.codegen.DefaultCodegen.setLibrary(DefaultCodegen.java:3159)
    at io.swagger.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:409)
    at io.swagger.codegen.cmd.Generate.run(Generate.java:232)
    at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:41)

If I remove the library from the config, it's working fine.Could someone please tell what am I doing wrong?

rcde0
  • 4,192
  • 3
  • 21
  • 31
  • Just FYI, `-l nodejs-server` generates a server stub, not a client stub. The client languages are listed here: https://generator.swagger.io/api/gen/clients – Helen Jun 25 '17 at 13:26

1 Answers1

0

I think you want to generate a Java API client instead and here is the command:

java -jar swagger-codegen-cli-2.2.2.jar generate -i "docs-endpoint" -ljava -o retrofit/ -c config.json

I would suggest retrofit2 instead of retrofit as retrofit is no longer actively maintained.

You may want build the Swagger Codegen CLI JAR from the latest master, which contains a lot of enhancements and bug fixes.

William Cheng
  • 10,137
  • 5
  • 54
  • 79