generate-open-api.sh 1.1 KB

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. function mobile {
  3. rm -rf ../mobile/openapi
  4. cd ./openapi-generator/templates/mobile/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/mobile
  9. }
  10. function web {
  11. rm -rf ../web/src/api/open-api
  12. cd ./openapi-generator/templates/web
  13. wget -O apiInner.mustache https://raw.githubusercontent.com/OpenAPITools/openapi-generator/v6.0.1/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache
  14. patch -u apiInner.mustache < apiInner.mustache.patch
  15. cd ../../..
  16. npx openapi-generator-cli generate -g typescript-axios -i ./immich-openapi-specs.json -o ../web/src/api/open-api -t ./openapi-generator/templates/web
  17. }
  18. if [[ $1 == 'mobile' ]]; then
  19. mobile
  20. elif [[ $1 == 'web' ]]; then
  21. web
  22. else
  23. mobile
  24. web
  25. fi