-
Notifications
You must be signed in to change notification settings - Fork 1
/
documentation.gradle
56 lines (49 loc) · 1.51 KB
/
documentation.gradle
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import org.apache.tools.ant.filters.ReplaceTokens
def ramlToCopy = copySpec {
from('src/main/resources') {
include 'api-definition.yaml'
rename { 'api-definition-swagger.yaml' }
filter(ReplaceTokens, tokens: [
baseUrl: "http://localhost",
version: version])
filter{
line -> line.replaceAll("\"schemas(.*).json\"","\"#/schemas\$1\"")
}
}
from('src/main/resources') {
include 'api-definition.yaml'
rename { 'api-definition-raml.yaml' }
filter(ReplaceTokens, tokens: [
baseUrl: "http://localhost",
version: version])
}
from('src/main/resources/schemas') {
include '*.json'
into 'schemas'
}
}
def ramlHtmlToCopy = copySpec {
from 'src/main/resources'
include 'api-definition.html'
}
task copyRamlToBuild(type:Copy) {
with ramlToCopy
into 'build/resources/main'
}
// Generate live documentation
task ramlToSwagger(type: Exec) {
description = 'Convert RAML to Swagger'
commandLine 'npm', 'run', 'runApiSpecConverter'
}
ramlToSwagger.dependsOn(npm_install, copyRamlToBuild)
// Generate static (offline) documentation
task ramlToHtml(type: Exec) {
description = 'Convert RAML to HTML document'
commandLine 'npm', 'run', 'runApiHtmlConverter'
}
ramlToHtml.dependsOn(npm_install, copyRamlToBuild)
task copyRamlHtmlToBuild(type:Copy) {
with ramlHtmlToCopy
into 'build/resources/main'
}
copyRamlHtmlToBuild.dependsOn ramlToHtml