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
34 changes: 19 additions & 15 deletions .spectral.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,54 +403,58 @@ rules:

# HTTP method responses validation
entur-get-responses-validation:
message: "Invalid response code: {{property}}. GET responses MUST use one of these response codes: 200, 304, 400, 401, 403, 404, 500, 503"
documentationUrl: "https://github.com/entur/api-guidelines/blob/main/guidelines.md#41-http-status-codes"
severity: error
given: $.paths.*.get.responses.*~
given: $.paths.*.get.responses
then:
field: "@key"
function: enumeration
functionOptions:
values: ["200", "302", "304", "400", "401", "403", "404", "500", "503"]
values: ["200", "302", "304", "400", "401", "403", "404", "500", "503", "default"]

entur-delete-responses-validation:
message: "Invalid response code: {{property}}. DELETE responses MUST use one of these response codes: 200, 204, 400, 401, 403, 404, 409, 500, 503"
message: "Invalid response code: {{value}}. DELETE responses MUST use one of these response codes: 200, 204, 400, 401, 403, 404, 409, 500, 503"
documentationUrl: "https://github.com/entur/api-guidelines/blob/main/guidelines.md#41-http-status-codes"
severity: error
given: $.paths.*.delete.responses.*~
given: $.paths.*.delete.responses
then:
field: "@key"
function: enumeration
functionOptions:
values: ["200", "204", "400", "401", "403", "404", "409", "500", "503"]
values: ["200", "204", "400", "401", "403", "404", "409", "500", "503", "default"]

entur-post-responses-validation:
message: "Invalid response code: {{property}}. POST responses MUST use one of these response codes: 200, 201, 202, 204, 303, 400, 401, 403, 404, 409, 500, 503"
message: "Invalid response code: {{value}}. POST responses MUST use one of these response codes: 200, 201, 202, 204, 303, 400, 401, 403, 404, 409, 500, 503"
documentationUrl: "https://github.com/entur/api-guidelines/blob/main/guidelines.md#41-http-status-codes"
severity: error
given: $.paths.*.post.responses.*~
given: $.paths.*.post.responses
then:
field: "@key"
function: enumeration
functionOptions:
values: ["200", "201", "202", "204", "303", "400", "401", "403", "404", "409", "500", "503"]
values: ["200", "201", "202", "204", "303", "400", "401", "403", "404", "409", "500", "503", "default"]

entur-put-responses-validation:
message: "Invalid response code: {{property}}. PUT responses MUST use one of these response codes: 200, 204, 400, 401, 403, 404, 409, 500, 503"
message: "Invalid response code: {{value}}. PUT responses MUST use one of these response codes: 200, 204, 400, 401, 403, 404, 409, 500, 503"
documentationUrl: "https://github.com/entur/api-guidelines/blob/main/guidelines.md#41-http-status-codes"
severity: error
given: $.paths.*.put.responses.*~
given: $.paths.*.put.responses
then:
field: "@key"
function: enumeration
functionOptions:
values: ["200", "201", "204", "400", "401", "403", "404", "409", "500", "503"]
values: ["200", "201", "204", "400", "401", "403", "404", "409", "500", "503", "default"]

entur-patch-responses-validation:
message: "Invalid response code: {{property}}. PATCH responses MUST use one of these response codes: 200, 204, 400, 401, 403, 404, 409, 500, 503"
message: "Invalid response code: {{value}}. PATCH responses MUST use one of these response codes: 200, 204, 400, 401, 403, 404, 409, 500, 503"
documentationUrl: "https://github.com/entur/api-guidelines/blob/main/guidelines.md#41-http-status-codes"
severity: error
given: $.paths.*.patch.responses.*~
given: $.paths.*.patch.responses
then:
field: "@key"
function: enumeration
functionOptions:
values: ["200", "204", "400", "401", "403", "404", "409", "500", "503"]
values: ["200", "204", "400", "401", "403", "404", "409", "500", "503", "default"]


# -------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion specs/reference-spec-with-errors.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"openapi": "3.1.0",
"info": {
"title": "Items API",

Check warning on line 4 in specs/reference-spec-with-errors.json

View workflow job for this annotation

GitHub Actions / lint-reference-spec-with-errors

entur-info-title-no-api

"version": "1.0.0",
"description": "A long and descriptive description",
"termsOfService": "https://developer.entur.org/terms-of-service",
Expand All @@ -10,9 +10,9 @@
"url": "https://entur.no",
"email": "support@entur.no"
},
"x-entur-metadata": {
"owner": "team-Api",

Check failure on line 14 in specs/reference-spec-with-errors.json

View workflow job for this annotation

GitHub Actions / lint-reference-spec-with-errors

entur-info-metadata-owner-valid

"team-Api" must match the pattern "^team-[a-z0-9]+(-[a-z0-9]+)*$"::https://github.com/entur/api-guidelines/blob/main/guidelines.md#242-specification-owner
"audience": "public"

Check failure on line 15 in specs/reference-spec-with-errors.json

View workflow job for this annotation

GitHub Actions / lint-reference-spec-with-errors

entur-info-metadata-audience-valid

"public" must be equal to one of the allowed values: "open", "partner", "internal"::https://github.com/entur/api-guidelines/blob/main/guidelines.md#24-entur-metadata

Check warning on line 15 in specs/reference-spec-with-errors.json

View workflow job for this annotation

GitHub Actions / lint-reference-spec-with-errors

entur-info-metadata-id

The OpenAPI info section SHOULD include "x-entur-metadata.id".::https://github.com/entur/api-guidelines/blob/main/guidelines.md#241-identifying-a-specification
}
},

Expand Down Expand Up @@ -224,12 +224,12 @@
"description": "Get an item with given id.",
"operationId": "getItem",
"responses": {
"200": {
"201": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Item"

Check failure on line 232 in specs/reference-spec-with-errors.json

View workflow job for this annotation

GitHub Actions / lint-reference-spec-with-errors

entur-get-responses-validation

Object{} must be equal to one of the allowed values: "200", "302", "304", "400", "401", "403", "404", "500", "503", "default"::https://github.com/entur/api-guidelines/blob/main/guidelines.md#41-http-status-codes
}
}
}
Expand Down