Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion linter/run-linter-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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`
return `spectral lint -r ${LINTER_RULESET_LOCATION} ${apiLocation}/*.json || true`
}

function removeProcessDir(output) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
71 changes: 71 additions & 0 deletions linter/testcases/openapi-root-missing-swagger-2/swagger.json
Original file line number Diff line number Diff line change
@@ -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": {
}
}
}
}
6 changes: 0 additions & 6 deletions linter/testcases/openapi-versie-missing/expected-output.txt

This file was deleted.

26 changes: 26 additions & 0 deletions linter/testcases/unrecognized-format-arazzo/arazzo.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

/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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

/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)
12 changes: 8 additions & 4 deletions media/linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -48,6 +51,7 @@ rules:
field: openapi
function: truthy
message: "The root of the document must contain the `openapi` property."
formats: [oas2]

#/core/version-header
nlgov:missing-version-header:
Expand Down Expand Up @@ -206,9 +210,9 @@ rules:
properties:
type: object
required:
- status
- title
- detail
- status
- title
- detail

#/core/error-handling/invalid-input
nlgov:problem-invalid-input:
Expand All @@ -226,7 +230,7 @@ rules:
responses:
type: object
required:
- "400"
- "400"

#/core/date-time/timezone
nlgov:date-time-ensure-timezone:
Expand Down
Loading