From 007714c3b544e8c66b7a20c2e6bcd8b25b2e5e0c Mon Sep 17 00:00:00 2001 From: janhendrik hausner Date: Fri, 7 Apr 2023 09:44:18 +0200 Subject: [PATCH 1/3] added spectral #patch --- .github/workflows/build.yaml | 8 ++++++ config/spectral/.spectral.json | 50 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 config/spectral/.spectral.json diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e59beda..50b7913 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -7,6 +7,8 @@ on: [push] jobs: build: runs-on: ubuntu-latest + permissions: + checks: write steps: - uses: actions/checkout@v3 @@ -17,6 +19,12 @@ jobs: java-version: '11' cache: 'gradle' + - name: Lint API + uses: stoplightio/spectral-action@v0.8.10 + with: + file_glob: 'docs/credit.json' + spectral_ruleset: 'config/spectral/.spectral.json' + - name: Build with Gradle run: ./gradlew build --no-daemon env: diff --git a/config/spectral/.spectral.json b/config/spectral/.spectral.json new file mode 100644 index 0000000..1617db8 --- /dev/null +++ b/config/spectral/.spectral.json @@ -0,0 +1,50 @@ +{ + "extends": [ + [ + "spectral:oas", + "all" + ] + ], + "formats": [ + "oas3" + ], + "rules": { + "contact-properties": "error", + "duplicated-entry-in-enum": "error", + "info-contact": "error", + "info-description": "error", + "info-license": "error", + "license-url": "error", + "no-$ref-siblings": "error", + "no-eval-in-markdown": "error", + "no-script-tags-in-markdown": "error", + "openapi-tags": "error", + "openapi-tags-alphabetical": "error", + "openapi-tags-uniqueness": "error", + "operation-description": "error", + "operation-operationId": "error", + "operation-operationId-unique": "error", + "operation-operationId-valid-in-url": "error", + "operation-parameters": "error", + "operation-singular-tag": "error", + "operation-success-response": "error", + "operation-tags": "error", + "operation-tag-defined": "error", + "path-declarations-must-exist": "error", + "path-keys-no-trailing-slash": "error", + "path-not-include-query": "error", + "path-params": "error", + "tag-description": "error", + "typed-enum": "error", + "oas3-api-servers": "error", + "oas3-examples-value-or-externalValue": "error", + "oas3-operation-security-defined": "error", + "oas3-parameter-description": "error", + "oas3-schema": "error", + "oas3-server-not-example.com": "error", + "oas3-server-trailing-slash": "error", + "oas3-unused-component": "error", + "oas3-valid-media-example": "error", + "oas3-valid-schema-example": "error" + } +} \ No newline at end of file From 0ca629ddf7ce9e452c417a0d772341f428819b58 Mon Sep 17 00:00:00 2001 From: janhendrik hausner Date: Fri, 7 Apr 2023 09:51:43 +0200 Subject: [PATCH 2/3] disabled and changes some spectral rules #patch --- config/spectral/.spectral.json | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/config/spectral/.spectral.json b/config/spectral/.spectral.json index 1617db8..4852cfd 100644 --- a/config/spectral/.spectral.json +++ b/config/spectral/.spectral.json @@ -9,7 +9,21 @@ "oas3" ], "rules": { - "contact-properties": "error", + "contact-properties": { + "description": "Contact object must have 'name', 'url' and 'email'.", + "recommended": false, + "given": "$.info.contact", + "then": [ + { + "field": "name", + "function": "truthy" + }, + { + "field": "email", + "function": "truthy" + } + ] + }, "duplicated-entry-in-enum": "error", "info-contact": "error", "info-description": "error", @@ -21,7 +35,7 @@ "openapi-tags": "error", "openapi-tags-alphabetical": "error", "openapi-tags-uniqueness": "error", - "operation-description": "error", + "operation-description": "off", "operation-operationId": "error", "operation-operationId-unique": "error", "operation-operationId-valid-in-url": "error", @@ -34,7 +48,7 @@ "path-keys-no-trailing-slash": "error", "path-not-include-query": "error", "path-params": "error", - "tag-description": "error", + "tag-description": "off", "typed-enum": "error", "oas3-api-servers": "error", "oas3-examples-value-or-externalValue": "error", From 2b928383f4d85afbddbce61fb86e30ffa4bdbd25 Mon Sep 17 00:00:00 2001 From: janhendrik hausner Date: Fri, 7 Apr 2023 10:15:00 +0200 Subject: [PATCH 3/3] supressed spectral errors #patch --- config/spectral/.spectral.json | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/config/spectral/.spectral.json b/config/spectral/.spectral.json index 4852cfd..8534fb7 100644 --- a/config/spectral/.spectral.json +++ b/config/spectral/.spectral.json @@ -60,5 +60,17 @@ "oas3-unused-component": "error", "oas3-valid-media-example": "error", "oas3-valid-schema-example": "error" - } + }, + "overrides": [ + { + "files": [ + "credit.json#/components/parameters/amountInEuros/example", + "credit.json#/components/parameters/termInMonths/example", + "credit.json#/components/parameters/delayInMilliseconds/example" + ], + "rules": { + "oas3-valid-media-example": "off" + } + } + ] } \ No newline at end of file