@apisyouwonthate/style-guide
Version:
Make your HTTP APIs better, faster, stronger, whether they are still being designed (API Design-First) or your organization has flopped various mismatched APIs into production and now you're thinking some consistency would be nice. Using Spectral and Open
51 lines (48 loc) • 1.07 kB
text/typescript
import { DiagnosticSeverity } from "@stoplight/types";
import testRule from "./__helpers__/helper";
testRule("request-GET-no-body-oas2", [
{
name: "valid case",
document: {
swagger: "2.0",
info: { version: "1.0" },
paths: {
"/": {
get: {},
},
},
},
errors: [],
},
{
name: "invalid case",
document: {
swagger: "2.0.0",
info: { version: "1.0" },
paths: {
"/": {
get: {
summary: "Get is a question but this looks like an answer",
consumes: ["application/json"],
parameters: [
{
in: "body",
name: "user",
schema: {
type: "object",
},
},
],
},
},
},
},
errors: [
{
message: "A `GET` request MUST NOT accept a request body.",
path: ["paths", "/", "get", "parameters", "0", "in"],
severity: DiagnosticSeverity.Error,
},
],
},
]);