generate-open-api.sh 1.0 KB

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bash
  2. function mobile {
  3. rm -rf ../mobile/openapi
  4. cd ./openapi-generator/templates/serialization/native
  5. 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
  6. patch -u native_class.mustache <native_class.mustache.patch
  7. cd ../../../..
  8. npx openapi-generator-cli generate -g dart -i ./immich-openapi-specs.json -o ../mobile/openapi -t ./openapi-generator/templates
  9. # Post generate patches
  10. patch --no-backup-if-mismatch -u ../mobile/openapi/lib/api_client.dart <./openapi-generator/patch/api_client.dart.patch
  11. patch --no-backup-if-mismatch -u ../mobile/openapi/lib/api.dart <./openapi-generator/patch/api.dart.patch
  12. }
  13. function web {
  14. rm -rf ../web/src/api/open-api
  15. npx openapi-generator-cli generate -g typescript-axios -i ./immich-openapi-specs.json -o ../web/src/api/open-api
  16. }
  17. if [[ $1 == 'mobile' ]]; then
  18. mobile
  19. elif [[ $1 == 'web' ]]; then
  20. web
  21. else
  22. mobile
  23. web
  24. fi