forked from podengo-project/idmsvc-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (54 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
srcdir = .
PYTHON = python3
VENV = $(srcdir)/.venv
PYTHON_VENV = $(VENV)/bin/python
VALIDATOR = $(VENV)/bin/openapi-spec-validator
NODE_BIN = node_modules/.bin
BIN = bin
TMP = tmp
OAPI_CODEGEN_VERSION ?= v1.14.0
SWAGGER_CONTAINER = swagger-editor
.PHONY: all
all:
$(MAKE) openapi-sort
$(MAKE) validate
$(MAKE) vacuum
$(MAKE) generate-json
.PHONY: clean
clean:
rm -rf $(VENV) $(BIN) $(TMP)
$(PYTHON_VENV):
$(PYTHON) -m venv $(VENV)
$(PYTHON_VENV) -m pip install -U pip
$(PYTHON_VENV) -m pip install -r requirements-dev.txt
$(VALIDATOR): $(PYTHON_VENV)
$(NODE_BIN)/%: package.json package-lock.json
npm install
touch $(NODE_BIN)/*
.PHONY: validate
validate: $(VALIDATOR)
$(VALIDATOR) public.openapi.yaml
$(VALIDATOR) internal.openapi.yaml
.PHONY: openapi-sort
openapi-sort: $(PYTHON_VENV)
$(PYTHON_VENV) yamlsort.py *.openapi.yaml
.PHONY: vacuum
vacuum: $(NODE_BIN)/vacuum
npm run vacuum:lint public.openapi.yaml
npm run vacuum:lint internal.openapi.yaml
.PHONY: swagger-editor
swagger-editor:
podman run --rm --detach \
-p 8080:8080 \
-v $(shell pwd):/api:ro,Z \
--name $(SWAGGER_CONTAINER) \
-e SWAGGER_FILE=/api/public.openapi.yaml \
docker.io/swaggerapi/swagger-editor
xdg-open http://localhost:8080
.PHONY: swagger-editor-stop
swagger-editor-stop:
podman stop $(SWAGGER_CONTAINER)
.PHONY: generate-json
generate-json: public.openapi.json internal.openapi.json
%.openapi.json: %.openapi.yaml $(PYTHON_VENV)
$(PYTHON_VENV) yaml2json.py $< $@