Auto download openapi spec
This commit is contained in:
parent
557ede6095
commit
976d464ef8
5
.gitignore
vendored
5
.gitignore
vendored
@ -30,6 +30,7 @@ _testmain.go
|
||||
/.swagger-codegen-ignore
|
||||
/.swagger-codegen/VERSION
|
||||
/.travis.yml
|
||||
/git_push.sh
|
||||
|
||||
# Firefly III YAML files
|
||||
/firefly-*.yaml
|
||||
# Swagger schema files
|
||||
/openapi.yaml
|
||||
|
38
generate.sh
38
generate.sh
@ -2,24 +2,27 @@
|
||||
|
||||
swagger_codegen_jar=~/.local/bin/swagger-codegen-cli-3.0.54.jar
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 <swagger-spec-file>"
|
||||
exit 1
|
||||
fi
|
||||
swagger_spec="openapi.yaml"
|
||||
|
||||
swagger_spec=$1
|
||||
|
||||
if [ ! -f "$swagger_spec" ]; then
|
||||
echo "Swagger spec file not found: $swagger_spec"
|
||||
exit 1
|
||||
fi
|
||||
# download api spec
|
||||
url=$(curl -s https://api-docs.firefly-iii.org | grep -oP '(?<=url: ")[^"]*v1[^"]*' | head -n 1)
|
||||
url="${url#./}"
|
||||
echo $url
|
||||
full_url="https://api-docs.firefly-iii.org/$url"
|
||||
echo $full_url
|
||||
curl -o openapi.yaml "$full_url"
|
||||
|
||||
# rm old files
|
||||
rm *.go
|
||||
rm git_push.sh
|
||||
rm README.md
|
||||
rm -R docs
|
||||
rm -R api
|
||||
rm -R\
|
||||
*.go \
|
||||
git_push.sh \
|
||||
README.md \
|
||||
.swagger-codegen-ignore \
|
||||
.travis.yml \
|
||||
docs \
|
||||
api \
|
||||
test \
|
||||
.swagger-codegen
|
||||
|
||||
# generate new spec
|
||||
java -jar "$swagger_codegen_jar" generate -i "$swagger_spec" -l go -o .
|
||||
@ -58,9 +61,10 @@ cat >> .gitignore << EOL
|
||||
/.swagger-codegen-ignore
|
||||
/.swagger-codegen/VERSION
|
||||
/.travis.yml
|
||||
/git_push.sh
|
||||
|
||||
# Firefly III YAML files
|
||||
/firefly-*.yaml
|
||||
# Swagger schema files
|
||||
/$swagger_spec
|
||||
EOL
|
||||
|
||||
# add info to README.md
|
||||
|
2
go.mod
2
go.mod
@ -4,5 +4,5 @@ go 1.22.2
|
||||
|
||||
require (
|
||||
github.com/antihax/optional v1.0.0
|
||||
golang.org/x/oauth2 v0.19.0
|
||||
golang.org/x/oauth2 v0.20.0
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@ -2,5 +2,5 @@ github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwc
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg=
|
||||
golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8=
|
||||
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
|
||||
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
|
Loading…
x
Reference in New Issue
Block a user