-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (39 loc) · 1.46 KB
/
Makefile
File metadata and controls
47 lines (39 loc) · 1.46 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
.DEFAULT_GOAL := generate
OPENAPI_JSON=openapi.json
OPENAPI_URL=http://localhost:4202/api-doc/openapi.json
RUST_CLIENT_OUT=./sysinspect-client
PROJECT_NAME=syswebclient
GENERATOR_BIN=.bin
GENERATOR_JAR=$(GENERATOR_BIN)/openapi-generator-cli.jar
GENERATOR_VERSION=7.14.0
DOCS_MD=$(wildcard $(RUST_CLIENT_OUT)/docs/*.md)
DOCS_HTML=$(patsubst %.md,%.html,$(DOCS_MD))
.PHONY: generate clean ensure_codegen docs
generate: $(OPENAPI_JSON) ensure_codegen
jq '.info.license.identifier = "Apache-2.0"' $(OPENAPI_JSON) > $(OPENAPI_JSON).patched
mv $(OPENAPI_JSON).patched $(OPENAPI_JSON)
java -jar $(GENERATOR_JAR) generate \
-i $(OPENAPI_JSON) \
-g rust \
-o $(RUST_CLIENT_OUT) \
--skip-validate-spec \
--additional-properties packageName=$(PROJECT_NAME)
cd $(RUST_CLIENT_OUT) && cargo clippy --fix --allow-dirty -- -Dwarnings
$(MAKE) docs
$(OPENAPI_JSON):
curl -fsSL $(OPENAPI_URL) -o $(OPENAPI_JSON)
ensure_codegen:
@if [ ! -d $(GENERATOR_BIN) ]; then \
mkdir -p $(GENERATOR_BIN); \
fi
@if [ ! -f $(GENERATOR_JAR) ]; then \
echo "Downloading openapi-generator-cli.jar..."; \
curl -L "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$(GENERATOR_VERSION)/openapi-generator-cli-$(GENERATOR_VERSION).jar" -o $(GENERATOR_JAR); \
fi
docs:
python3 -m venv .venv && \
.venv/bin/pip install --upgrade pip && \
.venv/bin/pip install mkdocs mkdocs-material && \
.venv/bin/mkdocs build --site-dir ./html-docs
clean:
rm -rf html-docs .venv .bin *json