Swagger-codegen: Can麓t use custom codegen

Created on 11 Jul 2016  路  6Comments  路  Source: swagger-api/swagger-codegen

Description

I麓m trying to create a custom codegen, I managed to make it work by putting the files inside of the codegen project but I want it to work like this.
I haven麓t modified the autogenerated project at all but I keep getting:
Error: Could not find or load main class io.swagger.codegen.SwaggerCodegen

Swagger-codegen version

2.1.6

Command line used for generation

java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar:swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation

Steps to reproduce

I got the jar from here

  1. Run java -jar swagger-codegen-cli-2.1.6.jar meta \ -o output/myLibrary -n myClientCodegen -p com.my.company.codegen to create costume codegen
  2. Run mvn package in output/myLibrary
  3. Run java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar:swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation in the folder that contains both swagger-codege-cli-2.1.6.jar and the output folder

Most helpful comment

I found the problem: If you are on Windows use a semi-colon instead of a colon in your classpath like so:

java -cp  "yourLib/target/yourLib-swagger-codegen-1.0.0.jar;modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" io.swagger.codegen.SwaggerCodegen

Can you verify whether that works for you?

All 6 comments

I am also experiencing this with 2.2.2-SNAPSHOT.

Same here with 2.2.2-SNAPSHOT.

Any solutions yet?

I found the problem: If you are on Windows use a semi-colon instead of a colon in your classpath like so:

java -cp  "yourLib/target/yourLib-swagger-codegen-1.0.0.jar;modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" io.swagger.codegen.SwaggerCodegen

Can you verify whether that works for you?

@fischerman It didn't worked for me, I keep getting the same error with the semi-colon
I tried it with 2.2.1, the last stable release

I tried with @fischerman solution once again and it worked, the semi-colon and quotation marks fixed it.
Thanks!

Thanks @fischerman for the tips and @lsarni for verifying.

I've updated the README accordingly: https://github.com/swagger-api/swagger-codegen/blob/master/README.md#making-your-own-codegen-modules

Was this page helpful?
0 / 5 - 0 ratings