Reputation: 1172
I'm trying to compile server code using swagger-codegen, however I'm hitting an error with my file that won't generate.
I'm running on Ubuntu.
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
git clone https://github.com/swagger-api/swagger-codegen.git
Swagger generate command is copied largely from the ./bin
#!/bin/sh
SCRIPT="$0"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/trustmile-consumer-small.json -l nodejs -o samples/server/trustmile/nodejs"
java $JAVA_OPTS -Dservice -jar $executable $ags
Here's the error in condensed form:
ERROR io.swagger.models.properties.PropertyBuilder - no property for null, null
java.lang.NullPointerException
at io.swagger.codegen.DefaultCodegen.fromParameter(DefaultCodegen.java:995)
at io.swagger.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:816)
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:351)
at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:324)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:153)
at io.swagger.codegen.cmd.Generate.run(Generate.java:124)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
And the spec here: https://gist.githubusercontent.com/jorourke/79897a93e15bf4d20eab/raw/87e520e1d79d721b5471a5009546b58f2131e891/Swagger%2520API%2520Spec
I am somewhat at a loss as the swagger spec works in Swagger Editor
Any help greatly appreciated.
Upvotes: 4
Views: 3716
Reputation: 10817
swagger-codegen does not support inline schema at the moment. The issue is track here.
To workaround the issue, you can define the parameter schema with a proper model in "definitions" section instead.
UPDATE (2016/06/28): Swagger Codegen now supports inline schema. Please pull the latest master to generate API clients, server stubs or documentation (https://github.com/swagger-api/swagger-codegen#getting-started)
Upvotes: 1