aboutsummaryrefslogtreecommitdiffstats
path: root/python_client/codegen_python_client.sh
blob: 5ab0ff92e8cf4db9c777d87f6d12133ae9857cd2 (plain)
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
#!/bin/bash

# This script re-generates the fatcat API client (fatcat_client) from the
# swagger/openapi2 spec file, using automated tools ("codegen")

set -exu
set -o pipefail

OUTPUT=`pwd`/codegen-out
mkdir -p $OUTPUT
# Strip tags, so entire API is under a single class
cat ../fatcat-openapi2.yml | grep -v "TAGLINE$" > $OUTPUT/api.yml

docker run \
    -v $OUTPUT:/tmp/swagger/ \
    swaggerapi/swagger-codegen-cli:v2.3.1 \
    generate \
    --lang python \
    --input-spec /tmp/swagger/api.yml \
    --output /tmp/swagger/ \
    -DpackageName=fatcat_client

sudo chown -R `whoami`:`whoami` $OUTPUT
mkdir -p fatcat_client
cp -r $OUTPUT/fatcat_client/* fatcat_client
cp $OUTPUT/README.md README.md

# these tests are basically no-ops
mkdir -p tests/codegen
cp -r $OUTPUT/test/* tests/codegen

# ooo, this makes me nervous
rm -rf $OUTPUT