generate static swagger documentation or client stubs with codgen and gradle (with JavaExec)

Swagger ist a possible language independent solution to describe your REST based services. I use it currently together with spring-boot to provide my mobile json api.

To generate docs and client stubs with gradle I resort to:
task genSwagger(type: JavaExec) {
    description "generate swagger doc or clients via codgen package and gradle"
    // needing buildscript dependency  classpath "com.wordnik:swagger-codegen:2.1.2-M1"
    classpath = buildscript.configurations.classpath
    args  = ["-i", "http://localhost:8080/........-rest-api", "-o", "${buildDir}/docs/rest-api", "-l", "android"]
    main      = "com.wordnik.swagger.codegen.Codegen"
}
run with "gradlew genSwagger"

As of today to my knowledge no stable gradle plugin exists for codegen (maven only), so starting it's Main class from gradle is my solution for now.

see also:
http://swagger.io/
https://github.com/springdox/springdox
https://github.com/swagger-api/swagger-codegen
http://gradle.org

Kommentare

Beliebte Posts aus diesem Blog

Powershell snippet to send messages to telegram

using the birt runtime with spring boot and gradle to generate PDF from a Report Design File