From 85c4c09afac2e91a4d297e81352cd864c85adeea Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 6 Dec 2024 11:36:47 +0100 Subject: [PATCH] Use the openapi terminology over swagger --- .github/workflows/ci.yml | 2 +- ...gger-spec.yml => publish-openapi-spec.yml} | 8 ++-- .gitignore | 3 +- composer.json | 42 ++++++------------- .../CLI/src/GeoLite/GeolocationDbUpdater.php | 6 +-- 5 files changed, 21 insertions(+), 40 deletions(-) rename .github/workflows/{publish-swagger-spec.yml => publish-openapi-spec.yml} (83%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a93559cb3..f2bc57d2f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: strategy: matrix: php-version: ['8.3'] - command: ['cs', 'stan', 'swagger:validate'] + command: ['cs', 'stan', 'openapi:validate'] steps: - uses: actions/checkout@v4 - uses: './.github/actions/ci-setup' diff --git a/.github/workflows/publish-swagger-spec.yml b/.github/workflows/publish-openapi-spec.yml similarity index 83% rename from .github/workflows/publish-swagger-spec.yml rename to .github/workflows/publish-openapi-spec.yml index 95692294c..6195ce90d 100644 --- a/.github/workflows/publish-swagger-spec.yml +++ b/.github/workflows/publish-openapi-spec.yml @@ -1,4 +1,4 @@ -name: Publish swagger spec +name: Publish openapi spec on: push: @@ -20,10 +20,10 @@ jobs: - uses: './.github/actions/ci-setup' with: php-version: ${{ matrix.php-version }} - extensions-cache-key: publish-swagger-spec-extensions-${{ matrix.php-version }} - - run: composer swagger:inline + extensions-cache-key: publish-openapi-spec-extensions-${{ matrix.php-version }} + - run: composer openapi:inline - run: mkdir ${{ steps.determine_version.outputs.version }} - - run: mv docs/swagger/swagger-inlined.json ${{ steps.determine_version.outputs.version }}/open-api-spec.json + - run: mv docs/swagger/openapi-inlined.json ${{ steps.determine_version.outputs.version }}/open-api-spec.json - name: Publish spec uses: JamesIves/github-pages-deploy-action@v4 with: diff --git a/.gitignore b/.gitignore index 9353d40c9..4061960bb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ data/database.sqlite data/shlink-tests.db data/GeoLite2-City.* data/infra/matomo -docs/swagger-ui* docs/mercure.html .phpunit.result.cache -docs/swagger/swagger-inlined.json +docs/swagger/openapi-inlined.json diff --git a/composer.json b/composer.json index bc81820e2..9fe15aeac 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,7 @@ "symfony/string": "^7.1" }, "require-dev": { - "devizzent/cebe-php-openapi": "^1.0.1", + "devizzent/cebe-php-openapi": "^1.1.1", "devster/ubench": "^2.1", "phpstan/phpstan": "^2.0", "phpstan/phpstan-doctrine": "^2.0", @@ -108,7 +108,7 @@ }, "scripts": { "ci": [ - "@parallel cs stan swagger:validate test:unit:ci test:db:sqlite:ci test:db:postgres test:db:mysql test:db:maria test:db:ms", + "@parallel cs stan openapi:validate test:unit:ci test:db:sqlite:ci test:db:postgres test:db:mysql test:db:maria test:db:ms", "@parallel test:api:ci test:cli:ci" ], "cs": "phpcs -s", @@ -154,36 +154,18 @@ "@test:cli", "phpcov merge build/coverage-cli --html build/coverage-cli/coverage-html && rm build/coverage-cli/*.cov" ], - "swagger:validate": "@php -d error_reporting=\"E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED\" vendor/bin/php-openapi validate docs/swagger/swagger.json", - "swagger:inline": "@php -d error_reporting=\"E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED\" vendor/bin/php-openapi inline docs/swagger/swagger.json docs/swagger/swagger-inlined.json", + "openapi:validate": "@php -d error_reporting=\"E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED\" vendor/bin/php-openapi validate docs/swagger/swagger.json", + "openapi:inline": "@php -d error_reporting=\"E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED\" vendor/bin/php-openapi inline docs/swagger/swagger.json docs/swagger/openapi-inlined.json", + "swagger:validate": [ + "echo \"This command is deprecated. Use openapi:validate instead\"", + "@openapi:validate" + ], + "swagger:inline": [ + "echo \"This command is deprecated. Use openapi:inline instead\"", + "@openapi:inline" + ], "clean:dev": "rm -f data/database.sqlite && rm -f config/params/generated_config.php" }, - "scripts-descriptions": { - "ci": "Alias for \"cs\", \"stan\", \"swagger:validate\" and \"test:ci\"", - "cs": "Checks coding styles", - "cs:fix": "Fixes coding styles, when possible", - "stan": "Inspects code with phpstan", - "test": "Runs all test suites", - "test:unit": "Runs unit test suites", - "test:unit:ci": "Runs unit test suites, generating all needed reports and logs for CI envs", - "test:unit:pretty": "Runs unit test suites and generates an HTML code coverage report", - "test:db": "Runs database test suites on a SQLite, MySQL, MariaDB, PostgreSQL and MsSQL", - "test:db:sqlite": "Runs database test suites on a SQLite database", - "test:db:sqlite:ci": "Runs database test suites on a SQLite database, generating all needed reports and logs for CI envs", - "test:db:mysql": "Runs database test suites on a MySQL database", - "test:db:maria": "Runs database test suites on a MariaDB database", - "test:db:postgres": "Runs database test suites on a PostgreSQL database", - "test:db:ms": "Runs database test suites on a Microsoft SQL Server database", - "test:api": "Runs API test suites", - "test:api:ci": "Runs API test suites, and generates code coverage for CI", - "test:api:pretty": "Runs API test suites, and generates code coverage in HTML format", - "test:cli": "Runs CLI test suites", - "test:cli:ci": "Runs CLI test suites, and generates code coverage for CI", - "test:cli:pretty": "Runs CLI test suites, and generates code coverage in HTML format", - "swagger:validate": "Validates the swagger docs, making sure they fulfil the spec", - "swagger:inline": "Inlines swagger docs in a single file", - "clean:dev": "Deletes artifacts which are gitignored and could affect dev env" - }, "config": { "sort-packages": true, "platform-check": false, diff --git a/module/CLI/src/GeoLite/GeolocationDbUpdater.php b/module/CLI/src/GeoLite/GeolocationDbUpdater.php index 7bdf8150e..0d3d96db4 100644 --- a/module/CLI/src/GeoLite/GeolocationDbUpdater.php +++ b/module/CLI/src/GeoLite/GeolocationDbUpdater.php @@ -64,12 +64,12 @@ public function checkDbUpdate( private function downloadIfNeeded(callable|null $beforeDownload, callable|null $handleProgress): GeolocationResult { if (! $this->dbUpdater->databaseFileExists()) { - return $this->downloadNewDb(false, $beforeDownload, $handleProgress); + return $this->downloadNewDb($beforeDownload, $handleProgress, olderDbExists: false); } $meta = ($this->geoLiteDbReaderFactory)()->metadata(); if ($this->buildIsTooOld($meta)) { - return $this->downloadNewDb(true, $beforeDownload, $handleProgress); + return $this->downloadNewDb($beforeDownload, $handleProgress, olderDbExists: true); } return GeolocationResult::DB_IS_UP_TO_DATE; @@ -106,9 +106,9 @@ private function resolveBuildTimestamp(Metadata $meta): int * @throws GeolocationDbUpdateFailedException */ private function downloadNewDb( - bool $olderDbExists, callable|null $beforeDownload, callable|null $handleProgress, + bool $olderDbExists, ): GeolocationResult { if ($beforeDownload !== null) { $beforeDownload($olderDbExists);