diff --git a/README.md b/README.md index 14444427943..f02e4bc981b 100644 --- a/README.md +++ b/README.md @@ -17,30 +17,20 @@ You need the following installed and available in your $PATH: You also need to add the scala binary to your PATH. -### To build the codegen library - -This will create the swagger-codegen library in your build folder. - -
-mvn package
-
- - ### To generate a sample client library You can build a client against Wordnik's [petstore](http://petstore.swagger.wordnik.com) API as follows: -
+```
 ./bin/scala-petstore.sh
-
+``` This will run the script in `src/main/scala/ScalaPetstoreCodegen.scala` and create the client. You can then compile and run the client, as well as unit tests against it: -
+```
 cd samples/petstore/scala
-
 mvn package
-
+``` Do the same for `java` by running `./bin/java-petstore.sh` @@ -49,18 +39,41 @@ Do the same for `java` by running `./bin/java-petstore.sh` If you don't want to call your server, you can save the swagger spec files into a directory and pass an argument to the code generator like this: -
+```
 -DfileMap=/path/to/files
-
+``` Or for example: -
+```
 ./bin/java-petstore-filemap.sh
-
+``` Which simple passes `-DfileMap=src/test/resources/petstore` as an argument +### Validating your swagger spec +You can use the validation tool to see that your server is creating a proper spec file. If you want to learn +more about the spec file and format, please see [swagger-core](https://github.com/wordnik/swagger-core/wiki). This +tool will read the server and generate a report of any violations of the spec. If there are violations, the +client codegen and ui may not work correctly. + +To validate an api and write output to ./swagger-errors.html: + +``` +./bin/validate.sh http://petstore.swagger.wordnik.com/api/resources.json "" ./swagger-errors.html +``` + +### To build the codegen library + +This will create the swagger-codegen library from source. + +``` +mvn package +``` + +Note! The templates are included in the library generated. If you want to modify the templates, you'll need to +either repackage the library OR modify your codegen script to use a file path! + License ------- diff --git a/bin/validate.sh b/bin/validate.sh new file mode 100755 index 00000000000..f230c53ab23 --- /dev/null +++ b/bin/validate.sh @@ -0,0 +1,6 @@ +#!/bin/bash +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*" +export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" +scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH com.wordnik.swagger.codegen.spec.Validator "$@" diff --git a/src/main/resources/validator/index.mustache b/src/main/resources/validator/index.mustache new file mode 100644 index 00000000000..24ac8de38ef --- /dev/null +++ b/src/main/resources/validator/index.mustache @@ -0,0 +1,262 @@ + + + + + Swagger Spec Validator + + + + + + + + + +
+
+
+ Validation Results +
+
+ {{host}} +
+
+
+ +
+ +
base path: {{basePath}}
+
api version: {{apiVersion}}
+
swagger version: {{swaggerVersion}}
+ + + + + + + + + + + + {{#messages}} + + + + + + + {{/messages}} + +
LevelTypeElementMessage
{{level}}{{elementType}}{{elementId}}{{message}}
+
+ + + \ No newline at end of file