forked from loic911/Rest-api-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRestApiDoc.groovy
33 lines (20 loc) · 975 Bytes
/
RestApiDoc.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import grails.converters.JSON
includeTargets << grailsScript('_GrailsPackage')
includeTargets << grailsScript("_GrailsBootstrap")
target(restApiDoc: "Build Rest Api Doc in a JSON file") {
depends(compile,configureProxy, packageApp, classpath, loadApp, configureApp)
def apiUtils = classLoader.loadClass('org.restapidoc.APIUtils')
def jsonUtils = classLoader.loadClass('org.restapidoc.JSONUtils')
try {
println("Start build JSON doc ${grailsApp.mergedConfig.grails.plugins.restapidoc.outputFileGeneration}...")
jsonUtils.registerMarshallers ()
def result = apiUtils.buildApiRegistry(grailsApp)
File docFile = new File(grailsApp.mergedConfig.grails.plugins.restapidoc.outputFileGeneration)
println("Write in file " + docFile.absolutePath+"...")
docFile.write((result as JSON).toString(true))
} catch(Exception e) {
println e
e.printStackTrace()
}
}
setDefaultTarget(restApiDoc)