aboutsummaryrefslogtreecommitdiffstats
path: root/bin/regen-ynab-api
blob: 2f7c8ac97d82e805bb2fc6e87ff744c1d6053278 (plain) (blame)
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
#!/bin/sh
set -eu

metadata=$(cat <<'EOF'
authors = ["Jesse Luehrs <doy@tozt.net>", "You Need A Budget, LLC"]
description = "OpenAPI-generated API bindings for the YNAB API"
repository = "https://git.tozt.net/ynab-api"
license = "Apache-2.0"
EOF
)

extra_readme=$(cat <<'EOF'
Jesse Luehrs <doy@tozt.net>

Based on the OpenAPI spec found at https://github.com/ynab/ynab-sdk-js/blob/master/spec-v1-swagger.json by You Need A Budget, LLC
EOF
)

cd "$(dirname "$0")/.."

rm -rf src docs

openapi-generator-cli \
    generate \
    -g rust \
    --library reqwest \
    -i data/spec-v1-swagger.json \
    -c data/openapi.yaml \
    --package-name ynab-api

echo "$metadata" | perl -i -nlE'/^author/ ? print <STDIN> : print' Cargo.toml
echo "$extra_readme" >> README.md