This repository has been archived by the owner on Jul 21, 2023. It is now read-only.
forked from qase-tms/specs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile
executable file
·91 lines (74 loc) · 2.04 KB
/
Taskfile
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
set -o nounset
set -o pipefail
### shortcut
function build() {
npm run build
}
function preview() {
npm run preview
}
function publish() {
npm run publish
local key=${1:-${README_TOKEN:-}}
if [ -n "${key}" ]; then
npx rdme openapi ./api.yaml --id=6172e1f931427d3f983e34ff --key="${key}"
fi
}
function validate() {
npm run validate
}
### npm
function update() {
local packages=("${@}")
if [ ${#packages[@]} = 0 ]; then
IFS=' ' read -r -a packages <<<"$(npm ls --depth=0 --prod --json |
jq -r '.dependencies | keys | join(" ")')"
fi
for pkg in "${packages[@]}"; do
npm install "${pkg}"@latest
done
}
### codegen
function go() {
rm -rf examples/sdk/go/*
openapi generate -i /specs/api.yaml -g go -o /sdk/go -c /sdk/go.yml
goimports -ungroup -local qase -w examples/sdk/go/
}
function php() {
rm -rf examples/sdk/php/*
mkdir examples/sdk/php
cp examples/sdk/php-openapi-generator-ignore examples/sdk/php/.openapi-generator-ignore
openapi generate -i /specs/api.yaml -g php -o /sdk/php -c /sdk/php.yml
# TODO:extend add formatting
}
function typescript() {
rm -rf examples/sdk/ts/*
mkdir examples/sdk/ts
cp examples/sdk/ts-openapi-generator-ignore examples/sdk/ts/.openapi-generator-ignore
openapi generate -i /specs/api.yaml -g typescript-axios -t /sdk/templates/axios -o /sdk/ts -c /sdk/ts.yml
# TODO:extend add formatting
}
function ui() {
docker run --rm -it \
-e SWAGGER_JSON=/specs/api.yaml \
-p 8080:8080 \
-v "$(pwd)"/api.yaml:/specs/api.yaml \
swaggerapi/swagger-ui:v4.1.3
}
openapi() {
# https://github.com/OpenAPITools/openapi-generator-cli
docker run --rm -it \
-v "$(pwd)"/api.yaml:/specs/api.yaml \
-v "$(pwd)"/examples/sdk:/sdk \
openapitools/openapi-generator-cli:v6.0.0 "${@}"
}
swagger() {
# https://github.com/swagger-api/swagger-codegen
docker run --rm -it \
-v "$(pwd)"/api.yaml:/specs/api.yaml \
-v "$(pwd)"/examples/sdk:/sdk \
swaggerapi/swagger-codegen-cli-v3:3.0.31 "${@}"
}
__default() { help; }
"${@:-__default}"