-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathRakefile
More file actions
62 lines (50 loc) · 2.16 KB
/
Rakefile
File metadata and controls
62 lines (50 loc) · 2.16 KB
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
57
58
59
60
61
62
# Rake tasks for morpheus-openapi repository
PROJECT_ROOT = `git rev-parse --show-toplevel`.strip
BUILD_DIR = File.join(PROJECT_ROOT, "build")
desc "Test that the openapi schema is valid by executing lint commands via docker"
task :test => ["docker:lint"]
desc "Builds bundled.yaml with redocly via docker "
task :build => ["docker:build"]
desc "Generates a Go client with OpenAPI Generator via docker"
task :generate => ["docker:generate"]
namespace "docker" do
# Ensure docker is installed
task :is_installed do
sh "which docker", verbose: false do |ok, status|
unless ok
fail "System command `docker` was not found.\nCommand failed with status (#{status.exitstatus}): [which docker]"
end
end
end
#desc "Validate the openapi schema with both redocly and spectral"
task :lint => [:redocly_lint, :spectral_lint]
#desc "Executes `redocly/cli lint` using docker"
task :redocly_lint => [:is_installed] do
cd PROJECT_ROOT, verbose: false do
sh("docker run --rm -v $PWD:/spec redocly/cli lint openapi.yaml --skip-rule no-invalid-media-type-examples")
end
end
#desc "Executes `stoplight/spectral lint` using docker"
task :spectral_lint => [:is_installed, :build] do
cd PROJECT_ROOT, verbose: false do
sh("docker run --rm -v $PWD:/tmp -it stoplight/spectral lint -v -F error \"/tmp/bundled.yaml\" --ruleset \"/tmp/.spectral.json\"")
end
end
#desc "Executes `redocly/cli bundle` using docker"
task :build => [:is_installed] do
cd PROJECT_ROOT, verbose: false do
sh("docker run --rm -v $PWD:/spec redocly/cli bundle --dereferenced openapi.yaml > bundled.yaml")
end
end
# desc "Executes openapitools/openapi-generator-cli using docker"
task :generate => [:is_installed, :build] do
cd PROJECT_ROOT, verbose: false do
sh("mkdir -p generated/client-go && \
cp .openapi-generator/.openapi-generator-ignore generated/client-go && \
docker run -v $PWD:/spec -it \
-e JAVA_OPTS=-DmaxYamlCodePoints=999999999 \
openapitools/openapi-generator-cli \
generate -g go -i /spec/bundled.yaml -t /spec/.openapi-generator/go/templates -o /spec/generated/client-go")
end
end
end