Skip to content

Commit

Permalink
Merge pull request #176 from cmars/fix/jsonapi-rules-on-changes
Browse files Browse the repository at this point in the history
fix: JSON API rules are requirementOnChange
  • Loading branch information
cmars authored Feb 10, 2022
2 parents b8b45b8 + c9713ea commit 7926777
Show file tree
Hide file tree
Showing 3 changed files with 28,125 additions and 43,571 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"sweater-comb": "build/index.js"
},
"files": [
"/build"
"/build",
"/schemas"
],
"scripts": {
"test": "jest --colors",
Expand Down
14 changes: 7 additions & 7 deletions src/rulesets/jsonapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function loadSchemaFromFile(filename) {

export const rules = {
statusCodes: ({ operations }: SnykApiCheckDsl) => {
operations.requirement.must(
operations.requirementOnChange.must(
"support the correct status codes",
(operation, context, docs, specItem) => {
docs.includeDocsLink(links.standards.statusCodes);
Expand Down Expand Up @@ -77,7 +77,7 @@ export const rules = {
);
},
contentType: ({ responses }: SnykApiCheckDsl) => {
responses.requirement.must(
responses.requirementOnChange.must(
"use the JSON:API content type",
(response, context, docs, specItem) => {
docs.includeDocsLink(links.jsonApi.contentType);
Expand All @@ -95,7 +95,7 @@ export const rules = {
);
},
responseData: ({ responses }: SnykApiCheckDsl) => {
responses.requirement.must(
responses.requirementOnChange.must(
"use the correct JSON:API response data",
(response, context, docs, specItem) => {
docs.includeDocsLink(links.jsonApi.resourceObjects);
Expand Down Expand Up @@ -170,7 +170,7 @@ export const rules = {
);
},
selfLinks: ({ responses }: SnykApiCheckDsl) => {
responses.requirement.must(
responses.requirementOnChange.must(
"include self links",
(response, context, docs, specItem) => {
docs.includeDocsLink(links.jsonApi.resourceObjectLinks);
Expand All @@ -195,7 +195,7 @@ export const rules = {
);
},
pagination: ({ operations }: SnykApiCheckDsl) => {
operations.requirement.must(
operations.requirementOnChange.must(
"correctly support pagination",
(operation, context, docs, specItem) => {
docs.includeDocsLink(links.jsonApi.pagination);
Expand Down Expand Up @@ -249,7 +249,7 @@ export const rules = {
);
},
compoundDocuments: ({ responses }: SnykApiCheckDsl) => {
responses.requirement.must(
responses.requirementOnChange.must(
"not allow compound documents",
(response, context, docs, specItem) => {
docs.includeDocsLink(links.jsonApi.compoundDocuments);
Expand All @@ -268,7 +268,7 @@ export const rules = {
);
},
schemas: ({ responses }: SnykApiCheckDsl) => {
responses.requirement.must(
responses.requirementOnChange.must(
"have valid JSON:API schemas",
(response, context, docs, specItem) => {
// TODO: this isn't a great link for this
Expand Down
Loading

0 comments on commit 7926777

Please sign in to comment.