2023-02-12 05:37:48 +02:00
|
|
|
#!/usr/bin/env bash
|
2023-01-10 06:08:45 +02:00
|
|
|
|
|
|
|
function mobile {
|
|
|
|
rm -rf ../mobile/openapi
|
2023-02-12 07:54:07 +02:00
|
|
|
cd ./openapi-generator/templates/mobile/serialization/native
|
2023-01-10 06:08:45 +02:00
|
|
|
wget -O native_class.mustache https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache
|
|
|
|
patch -u native_class.mustache <native_class.mustache.patch
|
2023-02-12 07:54:07 +02:00
|
|
|
cd ../../../../..
|
2023-04-29 04:28:35 +02:00
|
|
|
npx --yes @openapitools/openapi-generator-cli generate -g dart -i ./immich-openapi-specs.json -o ../mobile/openapi -t ./openapi-generator/templates/mobile
|
2023-02-12 05:37:48 +02:00
|
|
|
|
|
|
|
# Post generate patches
|
|
|
|
patch --no-backup-if-mismatch -u ../mobile/openapi/lib/api_client.dart <./openapi-generator/patch/api_client.dart.patch
|
|
|
|
patch --no-backup-if-mismatch -u ../mobile/openapi/lib/api.dart <./openapi-generator/patch/api.dart.patch
|
2023-05-12 16:21:13 +02:00
|
|
|
sed -i 's/0.17.0/0.18.0/g' ../mobile/openapi/pubspec.yaml
|
2023-01-10 06:08:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function web {
|
|
|
|
rm -rf ../web/src/api/open-api
|
2023-02-12 07:54:07 +02:00
|
|
|
cd ./openapi-generator/templates/web
|
|
|
|
wget -O apiInner.mustache https://raw.githubusercontent.com/OpenAPITools/openapi-generator/v6.0.1/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache
|
|
|
|
patch -u apiInner.mustache < apiInner.mustache.patch
|
|
|
|
cd ../../..
|
2023-05-28 03:52:22 +02:00
|
|
|
npx --yes @openapitools/openapi-generator-cli generate -g typescript-axios -i ./immich-openapi-specs.json -o ../web/src/api/open-api -t ./openapi-generator/templates/web --additional-properties=useSingleRequestParameter=true
|
2023-01-10 06:08:45 +02:00
|
|
|
}
|
|
|
|
|
2023-07-06 16:37:47 +02:00
|
|
|
function cli {
|
|
|
|
rm -rf ../cli/src/api/open-api
|
|
|
|
cd ./openapi-generator/templates/cli
|
|
|
|
wget -O apiInner.mustache https://raw.githubusercontent.com/OpenAPITools/openapi-generator/v6.6.0/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache
|
|
|
|
patch -u apiInner.mustache < apiInner.mustache.patch
|
|
|
|
cd ../../..
|
|
|
|
npx --yes @openapitools/openapi-generator-cli generate -g typescript-axios -i ./immich-openapi-specs.json -o ../cli/src/api/open-api -t ./openapi-generator/templates/cli --additional-properties=useSingleRequestParameter=true
|
|
|
|
}
|
|
|
|
|
2023-01-10 06:08:45 +02:00
|
|
|
if [[ $1 == 'mobile' ]]; then
|
|
|
|
mobile
|
|
|
|
elif [[ $1 == 'web' ]]; then
|
|
|
|
web
|
2023-07-06 16:37:47 +02:00
|
|
|
elif [[ $1 == 'cli' ]]; then
|
|
|
|
cli
|
2023-01-10 06:08:45 +02:00
|
|
|
else
|
|
|
|
mobile
|
|
|
|
web
|
2023-07-06 16:37:47 +02:00
|
|
|
cli
|
2023-01-10 06:08:45 +02:00
|
|
|
fi
|