-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 500 messages now require content too
- Loading branch information
1 parent
2791084
commit edb735b
Showing
2 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
__tests__/owasp-api3-2019-define-error-responses-500.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { DiagnosticSeverity } from "@stoplight/types"; | ||
import testRule from "./__helpers__/helper"; | ||
|
||
testRule("owasp:api3:2019-define-error-responses-500", [ | ||
{ | ||
name: "valid: defines a 500 response with content", | ||
document: { | ||
openapi: "3.1.0", | ||
info: { version: "1.0" }, | ||
paths: { | ||
"/": { | ||
get: { | ||
responses: { | ||
"500": { | ||
description: "ok", | ||
content: { | ||
"application/problem+json": {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [], | ||
}, | ||
|
||
{ | ||
name: "invalid: 500 is not defined at all", | ||
document: { | ||
openapi: "3.1.0", | ||
info: { version: "1.0" }, | ||
paths: { | ||
"/": { | ||
get: { | ||
responses: { | ||
"200": { | ||
description: "ok", | ||
content: { | ||
"application/json": {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [ | ||
{ | ||
message: "Operation is missing responses[500].", | ||
path: ["paths", "/", "get", "responses"], | ||
severity: DiagnosticSeverity.Warning, | ||
}, | ||
{ | ||
message: "Operation is missing responses[500].content.", | ||
path: ["paths", "/", "get", "responses"], | ||
severity: DiagnosticSeverity.Warning, | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
name: "invalid: 500 exists but content is missing", | ||
document: { | ||
openapi: "3.1.0", | ||
info: { version: "1.0" }, | ||
paths: { | ||
"/": { | ||
get: { | ||
responses: { | ||
"500": {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
errors: [ | ||
{ | ||
message: "Operation is missing [500].content.", | ||
path: ["paths", "/", "get", "responses", "500"], | ||
severity: DiagnosticSeverity.Warning, | ||
}, | ||
], | ||
}, | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters