From 88820f68dc8327e66cd9510cdf5c3048778d63bb Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 08:37:01 +0200 Subject: [PATCH 01/14] specify format Signed-off-by: Erwin --- media/linter.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/media/linter.yaml b/media/linter.yaml index 15b99e9..f54ffe1 100644 --- a/media/linter.yaml +++ b/media/linter.yaml @@ -20,6 +20,9 @@ extends: - ["spectral:oas", "off"] # extend spectral:oas maar zet standaard alle regels uit +formats: + - oas3 + rules: #/core/publish-openapi (deze error-rules valideren of OAS valid is) oas3-schema: error From 1831a99ce6d2f73dd1cc6bdf018337c762143d20 Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 09:01:15 +0200 Subject: [PATCH 02/14] formats oas2 en oas3 for steering to v3 Signed-off-by: Erwin --- media/linter.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/media/linter.yaml b/media/linter.yaml index f54ffe1..bae6fc5 100644 --- a/media/linter.yaml +++ b/media/linter.yaml @@ -43,6 +43,7 @@ rules: functionOptions: match: '^3(.\d+){1,2}$' message: "The OpenAPI Specification is versioned using a `major.minor.patch` versioning scheme. Use a version 3 OpenAPI Specification for documentation." + formats: [oas2, oas3] nlgov:openapi-root-exists: severity: error From 22cc915870544903ac674f192fba8875680897cf Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 09:36:38 +0200 Subject: [PATCH 03/14] always check, even if not exists Signed-off-by: Erwin --- media/linter.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/media/linter.yaml b/media/linter.yaml index bae6fc5..4ac77a0 100644 --- a/media/linter.yaml +++ b/media/linter.yaml @@ -37,11 +37,14 @@ rules: #/core/doc-openapi nlgov:openapi3: severity: error - given: $.['openapi'] + given: $ then: - function: pattern - functionOptions: - match: '^3(.\d+){1,2}$' + - field: openapi + function: truthy + - field: openapi + function: pattern + functionOptions: + match: '^3(.\d+){1,2}$' message: "The OpenAPI Specification is versioned using a `major.minor.patch` versioning scheme. Use a version 3 OpenAPI Specification for documentation." formats: [oas2, oas3] From 695d0ec44638ba00b591fba94efbb450619bc923 Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 09:57:16 +0200 Subject: [PATCH 04/14] implement on root-exists rule Signed-off-by: Erwin --- media/linter.yaml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/media/linter.yaml b/media/linter.yaml index 4ac77a0..26b15f0 100644 --- a/media/linter.yaml +++ b/media/linter.yaml @@ -37,14 +37,11 @@ rules: #/core/doc-openapi nlgov:openapi3: severity: error - given: $ + given: $.['openapi'] then: - - field: openapi - function: truthy - - field: openapi - function: pattern - functionOptions: - match: '^3(.\d+){1,2}$' + function: pattern + functionOptions: + match: '^3(.\d+){1,2}$' message: "The OpenAPI Specification is versioned using a `major.minor.patch` versioning scheme. Use a version 3 OpenAPI Specification for documentation." formats: [oas2, oas3] @@ -55,6 +52,7 @@ rules: field: openapi function: truthy message: "The root of the document must contain the `openapi` property." + formats: [oas2, oas3] #/core/version-header nlgov:missing-version-header: From 0b73aeb3ef854b3f6b38f7e4e33ea706986aac98 Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 10:05:15 +0200 Subject: [PATCH 05/14] only on root-exists; and format Signed-off-by: Erwin --- media/linter.yaml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/media/linter.yaml b/media/linter.yaml index 26b15f0..d92267e 100644 --- a/media/linter.yaml +++ b/media/linter.yaml @@ -43,7 +43,6 @@ rules: functionOptions: match: '^3(.\d+){1,2}$' message: "The OpenAPI Specification is versioned using a `major.minor.patch` versioning scheme. Use a version 3 OpenAPI Specification for documentation." - formats: [oas2, oas3] nlgov:openapi-root-exists: severity: error @@ -52,7 +51,7 @@ rules: field: openapi function: truthy message: "The root of the document must contain the `openapi` property." - formats: [oas2, oas3] + formats: [oas2] #/core/version-header nlgov:missing-version-header: @@ -211,9 +210,9 @@ rules: properties: type: object required: - - status - - title - - detail + - status + - title + - detail #/core/error-handling/invalid-input nlgov:problem-invalid-input: @@ -231,7 +230,7 @@ rules: responses: type: object required: - - "400" + - "400" #/core/date-time/timezone nlgov:date-time-ensure-timezone: From c4e77d056a495527a6364223cff4b8db70cca52c Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 10:32:54 +0200 Subject: [PATCH 06/14] fix testcase Signed-off-by: Erwin --- linter/testcases/openapi-versie-missing/expected-output.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/linter/testcases/openapi-versie-missing/expected-output.txt b/linter/testcases/openapi-versie-missing/expected-output.txt index 3cc27be..266caba 100644 --- a/linter/testcases/openapi-versie-missing/expected-output.txt +++ b/linter/testcases/openapi-versie-missing/expected-output.txt @@ -1,6 +1,5 @@ /testcases/openapi-versie-missing/openapi.json - 1:1 error nlgov:openapi-root-exists The root of the document must contain the `openapi` property. 1:1 warning unrecognized-format The provided document does not match any of the registered formats [OpenAPI 2.0 (Swagger), OpenAPI 3.x, OpenAPI 3.0.x, OpenAPI 3.1.x] ✖ 2 problems (1 error, 1 warning, 0 infos, 0 hints) From 81df02316cb732d9fe996d11b23ac50a7480edf3 Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 10:33:35 +0200 Subject: [PATCH 07/14] fix Signed-off-by: Erwin --- linter/testcases/openapi-versie-missing/expected-output.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linter/testcases/openapi-versie-missing/expected-output.txt b/linter/testcases/openapi-versie-missing/expected-output.txt index 266caba..fcfe3da 100644 --- a/linter/testcases/openapi-versie-missing/expected-output.txt +++ b/linter/testcases/openapi-versie-missing/expected-output.txt @@ -2,4 +2,4 @@ /testcases/openapi-versie-missing/openapi.json 1:1 warning unrecognized-format The provided document does not match any of the registered formats [OpenAPI 2.0 (Swagger), OpenAPI 3.x, OpenAPI 3.0.x, OpenAPI 3.1.x] -✖ 2 problems (1 error, 1 warning, 0 infos, 0 hints) +✖ 1 problem (0 errors, 1 warning, 0 infos, 0 hints) From 0e2189717a31d5b4f08e684324df8b65db74f7b5 Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 10:35:56 +0200 Subject: [PATCH 08/14] fix Signed-off-by: Erwin --- linter/testcases/openapi-versie-missing/expected-output.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linter/testcases/openapi-versie-missing/expected-output.txt b/linter/testcases/openapi-versie-missing/expected-output.txt index fcfe3da..21d923f 100644 --- a/linter/testcases/openapi-versie-missing/expected-output.txt +++ b/linter/testcases/openapi-versie-missing/expected-output.txt @@ -1,5 +1,5 @@ /testcases/openapi-versie-missing/openapi.json - 1:1 warning unrecognized-format The provided document does not match any of the registered formats [OpenAPI 2.0 (Swagger), OpenAPI 3.x, OpenAPI 3.0.x, OpenAPI 3.1.x] + 1:1 warning unrecognized-format The provided document does not match any of the registered formats [OpenAPI 3.x, OpenAPI 2.0 (Swagger), OpenAPI 3.0.x, OpenAPI 3.1.x] ✖ 1 problem (0 errors, 1 warning, 0 infos, 0 hints) From 695b745d0fab0b929d6e57cef6d82a4cb98e93b4 Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 12:36:05 +0200 Subject: [PATCH 09/14] arazzo sample Signed-off-by: Erwin --- linter/run-linter-tests.mjs | 3 ++- linter/testcases/arazzo-minimal/arazzo.json | 26 +++++++++++++++++++ .../arazzo-minimal/expected-output.txt | 4 +++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 linter/testcases/arazzo-minimal/arazzo.json create mode 100644 linter/testcases/arazzo-minimal/expected-output.txt diff --git a/linter/run-linter-tests.mjs b/linter/run-linter-tests.mjs index 43975d3..3b3e68c 100755 --- a/linter/run-linter-tests.mjs +++ b/linter/run-linter-tests.mjs @@ -14,7 +14,8 @@ const writeFile = utils.promisify(fs.writeFile); const LINTER_RULESET_LOCATION = path.join(__dirname, '..', 'media', 'linter.yaml'); function computeTestCommand(apiLocation) { - return `spectral lint -r ${LINTER_RULESET_LOCATION} ${apiLocation}/openapi.json || true` + const specificationFile = fs.readdirSync(apiLocation).find(file => file.endsWith('.json')); + return `spectral lint -r ${LINTER_RULESET_LOCATION} ${apiLocation}/${specificationFile} || true` } function removeProcessDir(output) { diff --git a/linter/testcases/arazzo-minimal/arazzo.json b/linter/testcases/arazzo-minimal/arazzo.json new file mode 100644 index 0000000..7d4eee0 --- /dev/null +++ b/linter/testcases/arazzo-minimal/arazzo.json @@ -0,0 +1,26 @@ +{ + "arazzo": "1.0.1", + "info": { + "title": "Minimale Arazzo-specificatie", + "description": "Deze Arazzo-specificatie bevat het minimale om geen errors te geven.", + "version": "1.0.0" + }, + "sourceDescriptions": [ + { + "name": "basis-api", + "url": "https://example.com/openapi.json", + "type": "openapi" + } + ], + "workflows": [ + { + "workflowId": "openapi-document-ophalen", + "steps": [ + { + "stepId": "openapi-document-ophalen", + "operationId": "getOpenapiJSON" + } + ] + } + ] +} \ No newline at end of file diff --git a/linter/testcases/arazzo-minimal/expected-output.txt b/linter/testcases/arazzo-minimal/expected-output.txt new file mode 100644 index 0000000..12585ce --- /dev/null +++ b/linter/testcases/arazzo-minimal/expected-output.txt @@ -0,0 +1,4 @@ +/testcases/arazzo-minimal/arazzo.json + 1:1 warning unrecognized-format The provided document does not match any of the registered formats [OpenAPI 3.x, OpenAPI 2.0 (Swagger), OpenAPI 3.0.x, OpenAPI 3.1.x] + +✖ 1 problem (0 errors, 1 warning, 0 infos, 0 hints) From 0ab370429cc3b5a0627da578829113105e5ae246 Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 12:38:19 +0200 Subject: [PATCH 10/14] enter Signed-off-by: Erwin --- linter/testcases/arazzo-minimal/expected-output.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/linter/testcases/arazzo-minimal/expected-output.txt b/linter/testcases/arazzo-minimal/expected-output.txt index 12585ce..856d2cf 100644 --- a/linter/testcases/arazzo-minimal/expected-output.txt +++ b/linter/testcases/arazzo-minimal/expected-output.txt @@ -1,3 +1,4 @@ + /testcases/arazzo-minimal/arazzo.json 1:1 warning unrecognized-format The provided document does not match any of the registered formats [OpenAPI 3.x, OpenAPI 2.0 (Swagger), OpenAPI 3.0.x, OpenAPI 3.1.x] From fd3d9f590642c169186824b6ad953533a2f66d7f Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 12:46:35 +0200 Subject: [PATCH 11/14] rename Signed-off-by: Erwin --- .../{arazzo-minimal => unrecognized-format-arazzo}/arazzo.json | 0 .../expected-output.txt | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename linter/testcases/{arazzo-minimal => unrecognized-format-arazzo}/arazzo.json (100%) rename linter/testcases/{arazzo-minimal => unrecognized-format-arazzo}/expected-output.txt (81%) diff --git a/linter/testcases/arazzo-minimal/arazzo.json b/linter/testcases/unrecognized-format-arazzo/arazzo.json similarity index 100% rename from linter/testcases/arazzo-minimal/arazzo.json rename to linter/testcases/unrecognized-format-arazzo/arazzo.json diff --git a/linter/testcases/arazzo-minimal/expected-output.txt b/linter/testcases/unrecognized-format-arazzo/expected-output.txt similarity index 81% rename from linter/testcases/arazzo-minimal/expected-output.txt rename to linter/testcases/unrecognized-format-arazzo/expected-output.txt index 856d2cf..1e00d04 100644 --- a/linter/testcases/arazzo-minimal/expected-output.txt +++ b/linter/testcases/unrecognized-format-arazzo/expected-output.txt @@ -1,5 +1,5 @@ -/testcases/arazzo-minimal/arazzo.json +/testcases/unrecognized-format-arazzo/arazzo.json 1:1 warning unrecognized-format The provided document does not match any of the registered formats [OpenAPI 3.x, OpenAPI 2.0 (Swagger), OpenAPI 3.0.x, OpenAPI 3.1.x] ✖ 1 problem (0 errors, 1 warning, 0 infos, 0 hints) From 68a0b4430c3ae9091088b8bee233088ee544a6a6 Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 13:01:01 +0200 Subject: [PATCH 12/14] swagger rule Signed-off-by: Erwin --- .../expected-output.txt | 5 ++ .../swagger.json | 71 +++++++++++++++++++ .../expected-output.txt | 2 +- .../openapi.json | 0 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 linter/testcases/openapi-root-missing-swagger-2/expected-output.txt create mode 100644 linter/testcases/openapi-root-missing-swagger-2/swagger.json rename linter/testcases/{openapi-versie-missing => unrecognized-format-openapi}/expected-output.txt (81%) rename linter/testcases/{openapi-versie-missing => unrecognized-format-openapi}/openapi.json (100%) diff --git a/linter/testcases/openapi-root-missing-swagger-2/expected-output.txt b/linter/testcases/openapi-root-missing-swagger-2/expected-output.txt new file mode 100644 index 0000000..c61138b --- /dev/null +++ b/linter/testcases/openapi-root-missing-swagger-2/expected-output.txt @@ -0,0 +1,5 @@ + +/testcases/openapi-root-missing-swagger-2/swagger.json + 1:1 error nlgov:openapi-root-exists The root of the document must contain the `openapi` property. + +✖ 1 problem (1 error, 0 warnings, 0 infos, 0 hints) \ No newline at end of file diff --git a/linter/testcases/openapi-root-missing-swagger-2/swagger.json b/linter/testcases/openapi-root-missing-swagger-2/swagger.json new file mode 100644 index 0000000..2439b27 --- /dev/null +++ b/linter/testcases/openapi-root-missing-swagger-2/swagger.json @@ -0,0 +1,71 @@ +{ + "swagger": "2.0", + "info": { + "title": "Baseline", + "description": "Deze OpenAPI specification bevat het minimale om aan alle regels te voldoen.", + "contact": { + "name": "Beheerder", + "url": "https://www.example.com", + "email": "mail@example.com" + }, + "version": "1.0.0" + }, + "host": "example.com", + "basePath": "/api/v1", + "schemes": [ + "https" + ], + "security": [ + { + "default": [] + } + ], + "tags": [ + { + "name": "swagger" + } + ], + "paths": { + "/swagger.json": { + "get": { + "tags": [ + "swagger" + ], + "description": "Swagger document", + "operationId": "getSwaggerJSON", + "parameters": [], + "responses": { + "200": { + "description": "OK", + "headers": { + "API-Version": { + "description": "De huidige versie van de applicatie", + "type": "string" + }, + "access-control-allow-origin": { + "description": "Alle origins mogen bij deze resource", + "type": "string" + } + } + } + }, + "security": [ + { + "default": [] + } + ] + } + } + }, + "definitions": { + }, + "securityDefinitions": { + "default": { + "type": "oauth2", + "flow": "implicit", + "authorizationUrl": "https://test.com", + "scopes": { + } + } + } +} \ No newline at end of file diff --git a/linter/testcases/openapi-versie-missing/expected-output.txt b/linter/testcases/unrecognized-format-openapi/expected-output.txt similarity index 81% rename from linter/testcases/openapi-versie-missing/expected-output.txt rename to linter/testcases/unrecognized-format-openapi/expected-output.txt index 21d923f..77f1330 100644 --- a/linter/testcases/openapi-versie-missing/expected-output.txt +++ b/linter/testcases/unrecognized-format-openapi/expected-output.txt @@ -1,5 +1,5 @@ -/testcases/openapi-versie-missing/openapi.json +/testcases/unrecognized-format-openapi/openapi.json 1:1 warning unrecognized-format The provided document does not match any of the registered formats [OpenAPI 3.x, OpenAPI 2.0 (Swagger), OpenAPI 3.0.x, OpenAPI 3.1.x] ✖ 1 problem (0 errors, 1 warning, 0 infos, 0 hints) diff --git a/linter/testcases/openapi-versie-missing/openapi.json b/linter/testcases/unrecognized-format-openapi/openapi.json similarity index 100% rename from linter/testcases/openapi-versie-missing/openapi.json rename to linter/testcases/unrecognized-format-openapi/openapi.json From 2a0024957b4b667f7f6eccf1030e03c0c2e37861 Mon Sep 17 00:00:00 2001 From: Erwin Date: Fri, 3 Jul 2026 13:05:51 +0200 Subject: [PATCH 13/14] fix enter Signed-off-by: Erwin --- .../openapi-root-missing-swagger-2/expected-output.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linter/testcases/openapi-root-missing-swagger-2/expected-output.txt b/linter/testcases/openapi-root-missing-swagger-2/expected-output.txt index c61138b..15195cd 100644 --- a/linter/testcases/openapi-root-missing-swagger-2/expected-output.txt +++ b/linter/testcases/openapi-root-missing-swagger-2/expected-output.txt @@ -2,4 +2,4 @@ /testcases/openapi-root-missing-swagger-2/swagger.json 1:1 error nlgov:openapi-root-exists The root of the document must contain the `openapi` property. -✖ 1 problem (1 error, 0 warnings, 0 infos, 0 hints) \ No newline at end of file +✖ 1 problem (1 error, 0 warnings, 0 infos, 0 hints) From a88d7cb7f37b7abd8e2f646fa1ef47da5c3ce3d7 Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Mon, 6 Jul 2026 11:50:36 +0200 Subject: [PATCH 14/14] Update linter/run-linter-tests.mjs --- linter/run-linter-tests.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linter/run-linter-tests.mjs b/linter/run-linter-tests.mjs index 3b3e68c..c07d077 100755 --- a/linter/run-linter-tests.mjs +++ b/linter/run-linter-tests.mjs @@ -14,8 +14,7 @@ const writeFile = utils.promisify(fs.writeFile); const LINTER_RULESET_LOCATION = path.join(__dirname, '..', 'media', 'linter.yaml'); function computeTestCommand(apiLocation) { - const specificationFile = fs.readdirSync(apiLocation).find(file => file.endsWith('.json')); - return `spectral lint -r ${LINTER_RULESET_LOCATION} ${apiLocation}/${specificationFile} || true` + return `spectral lint -r ${LINTER_RULESET_LOCATION} ${apiLocation}/*.json || true` } function removeProcessDir(output) {