forked from launchdarkly/ld-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (39 loc) · 1.46 KB
/
Makefile
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
SHELL = /bin/bash
VERSION = 2.0.0
TARGETS = \
bash \
go \
csharp-dotnet2 \
java \
python \
javascript \
nodejs-server \
typescript-node \
php \
ruby \
rails5
PREFIX = api-client
TARGETS_PATH ?= ./targets
LASTHASH := $(shell git rev-parse --short HEAD)
all: $(TARGETS)
$(TARGETS_PATH):
mkdir -p $@
$(TARGETS): spec
$(eval TEMP_DIR := $(shell mktemp -d))
rm -rf $(TARGETS_PATH)/$(PREFIX)-$@
mkdir -p $(TARGETS_PATH)/$(PREFIX)-$@
cp $(TARGETS_PATH)/swagger.yaml $(TEMP_DIR)/swagger.yaml
if [ -e "./scripts/[email protected]" ]; then ./scripts/[email protected] $(TEMP_DIR)/swagger.yaml; fi
swagger-codegen generate `cat ./config/params-$@ || true` --artifact-version $(VERSION) -i $(TEMP_DIR)/swagger.yaml -l $@ -o $(TARGETS_PATH)/$(PREFIX)-$@
cp ./LICENSE.txt $(TARGETS_PATH)/$(PREFIX)-$@/LICENSE.txt
mv $(TARGETS_PATH)/$(PREFIX)-$@/README.md $(TARGETS_PATH)/$(PREFIX)-$@/README-ORIGINAL.md || touch $(TARGETS_PATH)/$(PREFIX)-$@/README-ORIGINAL.md
cat ./README-PREFIX.md $(TARGETS_PATH)/$(PREFIX)-$@/README-ORIGINAL.md > $(TARGETS_PATH)/$(PREFIX)-$@/README.md
rm $(TARGETS_PATH)/$(PREFIX)-$@/README-ORIGINAL.md
rm -rf $(TEMP_DIR)
spec: $(TARGETS_PATH)
./node_modules/.bin/multi-file-swagger ./index.yaml > $(TARGETS_PATH)/swagger.json
./node_modules/.bin/multi-file-swagger -o yaml ./index.yaml > $(TARGETS_PATH)/swagger.yaml
./node_modules/.bin/swagger validate $(TARGETS_PATH)/swagger.yaml
clean:
rm -rf $(TARGETS_PATH)
.PHONY: $(TARGETS) all spec clean