-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate-api.sh
executable file
·44 lines (34 loc) · 1.55 KB
/
generate-api.sh
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
#! /bin/sh
# Generate the API documentation.
# https://github.com/swagger-api/swagger-codegen/tree/3.0.0
# clear generated files
rm -rf ./src/app/core/api/generated
# download the swagger codegen jar from maven if needed. (it is in gitignore)
if [ ! -f ./swagger-codegen-cli.jar ]; then
curl -fL\
-o swagger-codegen-cli.jar \
http://search.maven.org/remotecontent?filepath=io/swagger/codegen/v3/swagger-codegen-cli/3.0.33/swagger-codegen-cli-3.0.33.jar
fi
# generate using custom template. We are overriding just one file. Default template is here: https://github.com/swagger-api/swagger-codegen-generators/tree/master/src/main/resources/handlebars/typescript-angular
java -jar \
swagger-codegen-cli.jar \
generate \
-i https://backenddev.playngo.it/playandgo/v3/api-docs \
-l typescript-angular \
--template-dir ./src/app/core/api/templates/ \
-o ./src/app/core/api/generated \
--type-mappings Date=number \
# clean unwanted files
rm ./src/app/core/api/generated/*.*
rm ./src/app/core/api/generated/.gitignore
rm ./src/app/core/api/generated/.npmignore
rm -rf ./src/app/core/api/generated/.swagger-codegen/
rm ./src/app/core/api/generated/api/api.ts
rm ./src/app/core/api/generated/model/models.ts
# this file can be used if we want to keep some changes in generated files
rm ./src/app/core/api/generated/.swagger-codegen-ignore
# better folder name
mv ./src/app/core/api/generated/api ./src/app/core/api/generated/controllers
# formatting
npm run prettier ./src/app/core/api/generated/ -- --write
#npm run eslint ./src/app/core/api/generated/ -- --fix