From 15ce529c09c8af6d79be9d6830819d8bf7736f9d Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 9 Dec 2021 18:51:26 +0100 Subject: [PATCH] Added swagger validation to CI pipeline --- .github/workflows/ci.yml | 21 ++----------------- .gitignore | 1 + composer.json | 5 +++++ .../paths/{shortCode}_qr-code_{size}.json | 2 +- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1db3f3eb..4645e0b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,29 +8,12 @@ on: - develop jobs: - lint: - runs-on: ubuntu-20.04 - strategy: - matrix: - php-version: ['8.0'] - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Use PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - tools: composer - extensions: openswoole-4.8.1 - coverage: none - - run: composer install --no-interaction --prefer-dist - - run: composer cs - static-analysis: runs-on: ubuntu-20.04 strategy: matrix: php-version: ['8.0'] + command: ['cs', 'stan', 'swagger:validate'] steps: - name: Checkout code uses: actions/checkout@v2 @@ -42,7 +25,7 @@ jobs: extensions: openswoole-4.8.1 coverage: none - run: composer install --no-interaction --prefer-dist - - run: composer stan + - run: composer ${{ matrix.command }} unit-tests: runs-on: ubuntu-20.04 diff --git a/.gitignore b/.gitignore index 32942a29..933c25ee 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ docs/swagger-ui* docs/mercure.html docker-compose.override.yml .phpunit.result.cache +docs/swagger/swagger-inlined.json diff --git a/composer.json b/composer.json index 2926a1af..fedb863f 100644 --- a/composer.json +++ b/composer.json @@ -61,6 +61,7 @@ "symfony/string": "^5.4" }, "require-dev": { + "cebe/php-openapi": "^1.5", "devster/ubench": "^2.1", "dms/phpunit-arraysubset-asserts": "^0.3.0", "eaglewu/swoole-ide-helper": "dev-master", @@ -145,6 +146,8 @@ "@parallel test:unit:ci test:db:sqlite:ci", "@infect:ci" ], + "swagger:validate": "php-openapi validate docs/swagger/swagger.json", + "swagger:inline": "php-openapi inline docs/swagger/swagger.json docs/swagger/swagger-inlined.json", "clean:dev": "rm -f data/database.sqlite && rm -f config/params/generated_config.php" }, "scripts-descriptions": { @@ -170,6 +173,8 @@ "infect:ci:unit": "Checks unit tests quality applying mutation testing with existing reports and logs", "infect:ci:db": "Checks db tests quality applying mutation testing with existing reports and logs", "infect:test": "Runs unit and db tests, then checks tests quality applying mutation testing", + "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": { diff --git a/docs/swagger/paths/{shortCode}_qr-code_{size}.json b/docs/swagger/paths/{shortCode}_qr-code_{size}.json index fb5dd33e..54c5152e 100644 --- a/docs/swagger/paths/{shortCode}_qr-code_{size}.json +++ b/docs/swagger/paths/{shortCode}_qr-code_{size}.json @@ -21,7 +21,7 @@ "name": "size", "in": "path", "description": "The size of the image to be returned.", - "required": false, + "required": true, "schema": { "type": "integer", "minimum": 50,