From ac2ec6e659713decc5a4ea13cb9905dd8dc54b6b Mon Sep 17 00:00:00 2001 From: eko Date: Sun, 12 Apr 2026 22:06:46 +0700 Subject: [PATCH] add swagger --- .gitignore | 3 ++- composer.json | 3 ++- entrypoint.sh | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 16a44469..d1b989de 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ yarn-error.log /storage/framework/views/* /public/modules/* .qodo -.camel-jbang \ No newline at end of file +.camel-jbang +dump/ \ No newline at end of file diff --git a/composer.json b/composer.json index 3ce74d57..cc01eb3a 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,8 @@ "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.0", "phpunit/phpunit": "^10.1", - "spatie/laravel-ignition": "^2.0" + "spatie/laravel-ignition": "^2.0", + "knuckleswtf/scribe": "5.9.0" }, "autoload": { "psr-4": { diff --git a/entrypoint.sh b/entrypoint.sh index b451467d..8bc4e44f 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -84,6 +84,42 @@ echo "Verifying and synchronizing Composer dependencies..." # Run composer install to physically ensure all files (like laravel/prompts) are present in the volume composer install --no-interaction --optimize-autoloader +# Add after the "composer install --no-interaction --optimize-autoloader" line + +# Install and publish Scribe assets +echo "Setting up Scribe/OpenAPI documentation..." + +# Publish Scribe config (if not already published) +if [ ! -f config/scribe.php ]; then + echo "Publishing Scribe configuration..." + php artisan vendor:publish --tag=scribe-config --force +fi + +# Generate OpenAPI/Swagger documentation +if [ "$APP_ENV" != "production" ] || [ "$AUTO_GENERATE_API_DOCS" = "true" ]; then + echo "Generating API documentation..." + + # Generate Scribe documentation + php artisan scribe:generate --no-interaction || echo "⚠️ Scribe generation failed, check your API routes" + + # For OpenAPI/Swagger UI specifically + if [ -f public/docs/openapi.yaml ] || [ -f public/docs/collection.json ]; then + echo "✅ Documentation generated successfully" + echo "📚 Swagger UI available at: /docs (if configured)" + echo "📄 OpenAPI spec available at: /docs/openapi.yaml" + else + echo "⚠️ Documentation files not found after generation" + fi +fi + +# Create symbolic link for Scribe assets if needed +if [ -d vendor/knuckleswtf/scribe/dist ]; then + echo "Creating Scribe assets symlink..." + mkdir -p public/vendor/scribe + cp -r vendor/knuckleswtf/scribe/dist/* public/vendor/scribe/ 2>/dev/null || \ + ln -sf ../vendor/knuckleswtf/scribe/dist public/vendor/scribe 2>/dev/null || true +fi + # FIX: Ensure all generated/downloaded files are fully readable and executable echo "Setting correct ownership for web server..." chown -R www-data:www-data vendor