diff --git a/src/main/java/apiaddicts/sonar/openapi/checks/format/AbstractDefaultMediaTypeCheck.java b/src/main/java/apiaddicts/sonar/openapi/checks/format/AbstractDefaultMediaTypeCheck.java index 41e70839..42170531 100644 --- a/src/main/java/apiaddicts/sonar/openapi/checks/format/AbstractDefaultMediaTypeCheck.java +++ b/src/main/java/apiaddicts/sonar/openapi/checks/format/AbstractDefaultMediaTypeCheck.java @@ -1,22 +1,21 @@ package apiaddicts.sonar.openapi.checks.format; +import apiaddicts.sonar.openapi.checks.BaseCheck; +import apiaddicts.sonar.openapi.utils.MediaTypeUtils; + import com.google.common.collect.ImmutableSet; import com.sonar.sslr.api.AstNode; import com.sonar.sslr.api.AstNodeType; -import org.sonar.check.RuleProperty; -import org.apiaddicts.apitools.dosonarapi.api.v2.OpenApi2Grammar; -import org.apiaddicts.apitools.dosonarapi.api.v3.OpenApi3Grammar; -import org.apiaddicts.apitools.dosonarapi.api.v31.OpenApi31Grammar; -import apiaddicts.sonar.openapi.checks.BaseCheck; -import org.apiaddicts.apitools.dosonarapi.sslr.yaml.grammar.JsonNode; - import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; - -import static apiaddicts.sonar.openapi.utils.JsonNodeUtils.*; +import org.apiaddicts.apitools.dosonarapi.api.v2.OpenApi2Grammar; +import org.apiaddicts.apitools.dosonarapi.api.v3.OpenApi3Grammar; +import org.apiaddicts.apitools.dosonarapi.api.v31.OpenApi31Grammar; +import org.apiaddicts.apitools.dosonarapi.sslr.yaml.grammar.JsonNode; +import org.sonar.check.RuleProperty; public abstract class AbstractDefaultMediaTypeCheck extends BaseCheck { @@ -74,6 +73,11 @@ public void visitNode(JsonNode node) { } private void visitV2Node(JsonNode node) { + if (node.getType() != OpenApi2Grammar.OPERATION) return; + + String operation = node.key().getTokenValue().toLowerCase(); + if (!(operation.equals("post") || operation.equals("put") || operation.equals("patch"))) return; + JsonNode sectionNode = node.get(section); boolean definesMimeTypes = !sectionNode.isMissing(); @@ -81,51 +85,46 @@ private void visitV2Node(JsonNode node) { if (!supportsDefaultMimeTypeV2(node)) { addIssue(key, message, sectionNode.key()); } - } else { - if (!globalSupportsDefaultMimeType) { - addIssue(key, message, node.key()); - } + return; + } + + if (!globalSupportsDefaultMimeType) { + addIssue(key, message, node.key()); } } private void visitV3Node(JsonNode node) { + if (node.getType() == OpenApi3Grammar.OPERATION && section.equals("consumes")) { - String operation = node.key().getTokenValue().toLowerCase(); - if (operation.equals("post") || operation.equals("put") || operation.equals("patch")) { - visitContentNode(node); - } else { - JsonNode requestBodyNode = node.at("/requestBody"); - if (!requestBodyNode.isMissing()) { - addIssue(key, translate("OAR010.error-request-body-not-allowed", operation.toUpperCase()), node.key()); - } - } + handleConsumesOperation(node); + return; } if (node.getType() == OpenApi3Grammar.RESPONSES && section.equals("produces")) { - List responseCodes = node.properties().stream().collect(Collectors.toList()); - for (JsonNode jsonNode : responseCodes) { - if (!jsonNode.key().getTokenValue().equals("204")) { - boolean externalRefManagement = false; - if (isExternalRef(jsonNode) && externalRefNode == null) { - externalRefNode = jsonNode; - externalRefManagement = true; - } - jsonNode = resolve(jsonNode); - visitContentNode(jsonNode); - if (externalRefManagement) externalRefNode = null; - } - } + MediaTypeUtils.handleProducesResponses(node, externalRefNode, this::visitContentNode); } } - private void visitContentNode(JsonNode node) { - JsonNode contentNode; - if (section.equals("consumes")) { - JsonNode requestBodyNode = node.at("/requestBody"); - contentNode = resolve(requestBodyNode).at("/content"); - } else { - contentNode = node.at("/content"); + private void handleConsumesOperation(JsonNode node) { + String operation = node.key().getTokenValue().toLowerCase(); + boolean allowsBody = operation.equals("post") || operation.equals("put") || operation.equals("patch"); + + if (allowsBody) { + visitContentNode(node); + return; + } + + JsonNode requestBodyNode = node.at("/requestBody"); + if (!requestBodyNode.isMissing()) { + addIssue(key, + translate("OAR010.error-request-body-not-allowed", operation.toUpperCase()), + node.key()); } + } + + private void visitContentNode(JsonNode node) { + JsonNode contentNode = MediaTypeUtils.getContentNode(node, section); + boolean definesMimeTypes = !contentNode.isMissing(); if (definesMimeTypes) { if (!supportsDefaultMimeTypeV3(contentNode)) { diff --git a/src/main/java/apiaddicts/sonar/openapi/checks/format/AbstractUndefinedMediaTypeCheck.java b/src/main/java/apiaddicts/sonar/openapi/checks/format/AbstractUndefinedMediaTypeCheck.java index 92ee53c3..d30fd003 100644 --- a/src/main/java/apiaddicts/sonar/openapi/checks/format/AbstractUndefinedMediaTypeCheck.java +++ b/src/main/java/apiaddicts/sonar/openapi/checks/format/AbstractUndefinedMediaTypeCheck.java @@ -1,20 +1,17 @@ package apiaddicts.sonar.openapi.checks.format; +import apiaddicts.sonar.openapi.checks.BaseCheck; +import apiaddicts.sonar.openapi.utils.MediaTypeUtils; + import com.google.common.collect.ImmutableSet; import com.sonar.sslr.api.AstNodeType; +import java.util.Map; +import java.util.Set; import org.apiaddicts.apitools.dosonarapi.api.v2.OpenApi2Grammar; import org.apiaddicts.apitools.dosonarapi.api.v3.OpenApi3Grammar; import org.apiaddicts.apitools.dosonarapi.api.v31.OpenApi31Grammar; -import apiaddicts.sonar.openapi.checks.BaseCheck; import org.apiaddicts.apitools.dosonarapi.sslr.yaml.grammar.JsonNode; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import static apiaddicts.sonar.openapi.utils.JsonNodeUtils.*; - public abstract class AbstractUndefinedMediaTypeCheck extends BaseCheck { private static final String MESSAGE = "generic.section"; @@ -49,47 +46,49 @@ public void visitNode(JsonNode node) { } private void visitV2Node(JsonNode node) { - if (!globalDefinesMediaTypes && !definesMimeTypesV2(node)) { - addIssue(key, translate(MESSAGE, section), node.key()); + if (node.getType() == OpenApi2Grammar.OPERATION) { + String operation = node.key().getTokenValue().toLowerCase(); + + if ((operation.equals("post") || operation.equals("put") || operation.equals("patch")) + && !globalDefinesMediaTypes + && !definesMimeTypesV2(node)) { + + addIssue(key, translate(MESSAGE, section), node.key()); + } } } private void visitV3Node(JsonNode node) { if (node.getType() == OpenApi3Grammar.OPERATION && section.equals("consumes")) { - String operation = node.key().getTokenValue().toLowerCase(); - if (operation.equals("post") || operation.equals("put") || operation.equals("patch")) { - visitContentNode(node); - } + handleConsumesOperation(node); + return; } if (node.getType() == OpenApi3Grammar.RESPONSES && section.equals("produces")) { - List responseCodes = node.properties().stream().collect(Collectors.toList()); - for (JsonNode jsonNode : responseCodes) { - if (!jsonNode.key().getTokenValue().equals("204")) { - boolean externalRefManagement = false; - if (isExternalRef(jsonNode) && externalRefNode == null) { - externalRefNode = jsonNode; - externalRefManagement = true; - } - jsonNode = resolve(jsonNode); - visitContentNode(jsonNode); - if (externalRefManagement) externalRefNode = null; - } - } + MediaTypeUtils.handleProducesResponses(node, externalRefNode, this::visitContentNode); + } + } + + private void handleConsumesOperation(JsonNode node) { + String operation = node.key().getTokenValue().toLowerCase(); + + if (operation.equals("post") || operation.equals("put") || operation.equals("patch")) { + visitContentNode(node); } } private void visitContentNode(JsonNode node) { JsonNode contentNode; + if (section.equals("consumes")) { JsonNode requestBodyNode = node.at("/requestBody"); if (requestBodyNode.isMissing() || requestBodyNode.isNull()) { addIssue(key, translate(MESSAGE, "requestBody"), node.key()); return; } - contentNode = resolve(requestBodyNode).at("/content"); + contentNode = MediaTypeUtils.getContentNode(node, section); } else { - contentNode = node.at("/content"); + contentNode = MediaTypeUtils.getContentNode(node, section); } if (!globalDefinesMediaTypes && !definesMimeTypesV3(contentNode)) { diff --git a/src/main/java/apiaddicts/sonar/openapi/utils/MediaTypeUtils.java b/src/main/java/apiaddicts/sonar/openapi/utils/MediaTypeUtils.java new file mode 100644 index 00000000..841b6dc0 --- /dev/null +++ b/src/main/java/apiaddicts/sonar/openapi/utils/MediaTypeUtils.java @@ -0,0 +1,35 @@ +package apiaddicts.sonar.openapi.utils; + +import org.apiaddicts.apitools.dosonarapi.sslr.yaml.grammar.JsonNode; +import java.util.function.Consumer; +import static apiaddicts.sonar.openapi.utils.JsonNodeUtils.isExternalRef; +import static apiaddicts.sonar.openapi.utils.JsonNodeUtils.resolve; + +public class MediaTypeUtils { + + private MediaTypeUtils() { + } + + public static void handleProducesResponses(JsonNode node, JsonNode externalRefNode, Consumer visitContentNode) { + for (JsonNode jsonNode : node.properties()) { + if (jsonNode.key().getTokenValue().equals("204")) continue; + + boolean manageExternal = isExternalRef(jsonNode) && externalRefNode == null; + if (manageExternal) externalRefNode = jsonNode; + + JsonNode resolved = resolve(jsonNode); + visitContentNode.accept(resolved); + + if (manageExternal) externalRefNode = null; + } + } + + public static JsonNode getContentNode(JsonNode node, String section) { + if ("consumes".equals(section)) { + JsonNode requestBodyNode = node.at("/requestBody"); + return resolve(requestBodyNode).at("/content"); + } else { + return node.at("/content"); + } + } +} diff --git a/src/test/resources/checks/v2/format/OAR006/with-default-and-specific.json b/src/test/resources/checks/v2/format/OAR006/with-default-and-specific.json index d7e9ef98..53f6f9ba 100644 --- a/src/test/resources/checks/v2/format/OAR006/with-default-and-specific.json +++ b/src/test/resources/checks/v2/format/OAR006/with-default-and-specific.json @@ -9,7 +9,7 @@ ], "paths": { "/pets": { - "get": { + "post": { "consumes": [ "application/xml" ], diff --git a/src/test/resources/checks/v2/format/OAR006/with-default-and-specific.yaml b/src/test/resources/checks/v2/format/OAR006/with-default-and-specific.yaml index 7b549975..01065011 100644 --- a/src/test/resources/checks/v2/format/OAR006/with-default-and-specific.yaml +++ b/src/test/resources/checks/v2/format/OAR006/with-default-and-specific.yaml @@ -6,7 +6,7 @@ consumes: - application/json paths: /pets: - get: + post: consumes: - application/xml responses: diff --git a/src/test/resources/checks/v2/format/OAR006/with-default.json b/src/test/resources/checks/v2/format/OAR006/with-default.json index c5fae1b0..0b4c4aa5 100644 --- a/src/test/resources/checks/v2/format/OAR006/with-default.json +++ b/src/test/resources/checks/v2/format/OAR006/with-default.json @@ -9,7 +9,7 @@ ], "paths": { "/pets": { - "get": { + "post": { "responses": { "200": { "description": "Ok" diff --git a/src/test/resources/checks/v2/format/OAR006/with-default.yaml b/src/test/resources/checks/v2/format/OAR006/with-default.yaml index ca54cf9a..f2cb28da 100644 --- a/src/test/resources/checks/v2/format/OAR006/with-default.yaml +++ b/src/test/resources/checks/v2/format/OAR006/with-default.yaml @@ -6,7 +6,7 @@ consumes: - application/json paths: /pets: - get: + post: responses: 200: description: Ok \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR006/with-specific.json b/src/test/resources/checks/v2/format/OAR006/with-specific.json index 84ebfa31..46495abd 100644 --- a/src/test/resources/checks/v2/format/OAR006/with-specific.json +++ b/src/test/resources/checks/v2/format/OAR006/with-specific.json @@ -6,7 +6,7 @@ }, "paths": { "/pets": { - "get": { + "post": { "consumes": [ "application/json" ], diff --git a/src/test/resources/checks/v2/format/OAR006/with-specific.yaml b/src/test/resources/checks/v2/format/OAR006/with-specific.yaml index ff3a259e..abeb358d 100644 --- a/src/test/resources/checks/v2/format/OAR006/with-specific.yaml +++ b/src/test/resources/checks/v2/format/OAR006/with-specific.yaml @@ -5,7 +5,7 @@ info: paths: /pets: - get: + post: consumes: - application/json responses: diff --git a/src/test/resources/checks/v2/format/OAR006/without-anything.json b/src/test/resources/checks/v2/format/OAR006/without-anything.json index ef8d7d70..a0356fc3 100644 --- a/src/test/resources/checks/v2/format/OAR006/without-anything.json +++ b/src/test/resources/checks/v2/format/OAR006/without-anything.json @@ -6,7 +6,7 @@ }, "paths": { "/pets": { - "get": { # Noncompliant {{OAR006: Section consumes is mandatory}} + "post": { # Noncompliant {{OAR006: Section consumes is mandatory}} "responses": { "200": { "description": "Ok" diff --git a/src/test/resources/checks/v2/format/OAR006/without-anything.yaml b/src/test/resources/checks/v2/format/OAR006/without-anything.yaml index 2c075c6b..e8dc87e7 100644 --- a/src/test/resources/checks/v2/format/OAR006/without-anything.yaml +++ b/src/test/resources/checks/v2/format/OAR006/without-anything.yaml @@ -4,7 +4,7 @@ info: title: Swagger Petstore paths: /pets: - get: # Noncompliant {{OAR006: Section consumes is mandatory}} + post: # Noncompliant {{OAR006: Section consumes is mandatory}} responses: 200: description: Ok \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR007/without-anything.json b/src/test/resources/checks/v2/format/OAR007/without-anything.json index 1e18189b..9363e37d 100644 --- a/src/test/resources/checks/v2/format/OAR007/without-anything.json +++ b/src/test/resources/checks/v2/format/OAR007/without-anything.json @@ -6,7 +6,7 @@ }, "paths": { "/pets": { - "get": { # Noncompliant {{OAR007: Section produces is mandatory}} + "post": { # Noncompliant {{OAR007: Section produces is mandatory}} "responses": { "200": { "description": "Ok" diff --git a/src/test/resources/checks/v2/format/OAR007/without-anything.yaml b/src/test/resources/checks/v2/format/OAR007/without-anything.yaml index 8cb5e5fd..85df5469 100644 --- a/src/test/resources/checks/v2/format/OAR007/without-anything.yaml +++ b/src/test/resources/checks/v2/format/OAR007/without-anything.yaml @@ -4,7 +4,7 @@ info: title: Swagger Petstore paths: /pets: - get: # Noncompliant {{OAR007: Section produces is mandatory}} + post: # Noncompliant {{OAR007: Section produces is mandatory}} responses: 200: description: Ok \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR009/with-default-and-specific.json b/src/test/resources/checks/v2/format/OAR009/with-default-and-specific.json index 39cff17c..e881405a 100644 --- a/src/test/resources/checks/v2/format/OAR009/with-default-and-specific.json +++ b/src/test/resources/checks/v2/format/OAR009/with-default-and-specific.json @@ -9,7 +9,7 @@ ], "paths": { "/pets": { - "get": { + "post": { "consumes": [ # Noncompliant {{OAR009: Should indicate the default request media type}} "application/xml" ], diff --git a/src/test/resources/checks/v2/format/OAR009/with-default-and-specific.yaml b/src/test/resources/checks/v2/format/OAR009/with-default-and-specific.yaml index f8f96fb2..3c8b5cd8 100644 --- a/src/test/resources/checks/v2/format/OAR009/with-default-and-specific.yaml +++ b/src/test/resources/checks/v2/format/OAR009/with-default-and-specific.yaml @@ -6,7 +6,7 @@ consumes: - application/json paths: /pets: - get: + post: consumes: # Noncompliant {{OAR009: Should indicate the default request media type}} - application/xml responses: diff --git a/src/test/resources/checks/v2/format/OAR009/with-default.json b/src/test/resources/checks/v2/format/OAR009/with-default.json index c5fae1b0..0b4c4aa5 100644 --- a/src/test/resources/checks/v2/format/OAR009/with-default.json +++ b/src/test/resources/checks/v2/format/OAR009/with-default.json @@ -9,7 +9,7 @@ ], "paths": { "/pets": { - "get": { + "post": { "responses": { "200": { "description": "Ok" diff --git a/src/test/resources/checks/v2/format/OAR009/with-default.yaml b/src/test/resources/checks/v2/format/OAR009/with-default.yaml index ca54cf9a..f2cb28da 100644 --- a/src/test/resources/checks/v2/format/OAR009/with-default.yaml +++ b/src/test/resources/checks/v2/format/OAR009/with-default.yaml @@ -6,7 +6,7 @@ consumes: - application/json paths: /pets: - get: + post: responses: 200: description: Ok \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR009/with-specific.json b/src/test/resources/checks/v2/format/OAR009/with-specific.json index eb77a8a7..032d2d57 100644 --- a/src/test/resources/checks/v2/format/OAR009/with-specific.json +++ b/src/test/resources/checks/v2/format/OAR009/with-specific.json @@ -6,7 +6,7 @@ }, "paths": { "/pets": { - "get": { + "post": { "consumes": [ "application/json" ], @@ -18,7 +18,7 @@ } }, "/owners": { - "get": { + "post": { "consumes": [ # Noncompliant {{OAR009: Should indicate the default request media type}} "application/xml" ], diff --git a/src/test/resources/checks/v2/format/OAR009/with-specific.yaml b/src/test/resources/checks/v2/format/OAR009/with-specific.yaml index 3addd141..05f77db9 100644 --- a/src/test/resources/checks/v2/format/OAR009/with-specific.yaml +++ b/src/test/resources/checks/v2/format/OAR009/with-specific.yaml @@ -5,14 +5,14 @@ info: paths: /pets: - get: + post: consumes: - application/json responses: 200: description: Ok /owners: - get: + post: consumes: # Noncompliant {{OAR009: Should indicate the default request media type}} - application/xml responses: diff --git a/src/test/resources/checks/v2/format/OAR009/with-wrong-default-and-specific.json b/src/test/resources/checks/v2/format/OAR009/with-wrong-default-and-specific.json index ea01575f..13769fa3 100644 --- a/src/test/resources/checks/v2/format/OAR009/with-wrong-default-and-specific.json +++ b/src/test/resources/checks/v2/format/OAR009/with-wrong-default-and-specific.json @@ -9,7 +9,7 @@ ], "paths": { "/pets": { - "get": { + "post": { "consumes": [ # Noncompliant {{OAR009: Should indicate the default request media type}} "application/xml" ], @@ -21,7 +21,7 @@ } }, "/owners": { - "get": { + "post": { "consumes": [ "application/json" ], diff --git a/src/test/resources/checks/v2/format/OAR009/with-wrong-default-and-specific.yaml b/src/test/resources/checks/v2/format/OAR009/with-wrong-default-and-specific.yaml index 550cd757..ceef0f0e 100644 --- a/src/test/resources/checks/v2/format/OAR009/with-wrong-default-and-specific.yaml +++ b/src/test/resources/checks/v2/format/OAR009/with-wrong-default-and-specific.yaml @@ -6,14 +6,14 @@ consumes: - application/xml paths: /pets: - get: + post: consumes: # Noncompliant {{OAR009: Should indicate the default request media type}} - application/xml responses: 200: description: Ok /owners: - get: + post: consumes: - application/json responses: diff --git a/src/test/resources/checks/v2/format/OAR009/with-wrong-default.json b/src/test/resources/checks/v2/format/OAR009/with-wrong-default.json index d105521a..2bf93739 100644 --- a/src/test/resources/checks/v2/format/OAR009/with-wrong-default.json +++ b/src/test/resources/checks/v2/format/OAR009/with-wrong-default.json @@ -9,7 +9,7 @@ ], "paths": { "/pets": { - "get": { # Noncompliant {{OAR009: Should indicate the default request media type}} + "post": { # Noncompliant {{OAR009: Should indicate the default request media type}} "responses": { "200": { "description": "Ok" diff --git a/src/test/resources/checks/v2/format/OAR009/with-wrong-default.yaml b/src/test/resources/checks/v2/format/OAR009/with-wrong-default.yaml index 7be46a47..2fab8fc3 100644 --- a/src/test/resources/checks/v2/format/OAR009/with-wrong-default.yaml +++ b/src/test/resources/checks/v2/format/OAR009/with-wrong-default.yaml @@ -6,7 +6,7 @@ consumes: - application/xml paths: /pets: - get: # Noncompliant {{OAR009: Should indicate the default request media type}} + post: # Noncompliant {{OAR009: Should indicate the default request media type}} responses: 200: description: Ok \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR009/without-anything.json b/src/test/resources/checks/v2/format/OAR009/without-anything.json index 73a5965f..9adb2d61 100644 --- a/src/test/resources/checks/v2/format/OAR009/without-anything.json +++ b/src/test/resources/checks/v2/format/OAR009/without-anything.json @@ -6,7 +6,7 @@ }, "paths": { "/pets": { - "get": { # Noncompliant {{OAR009: Should indicate the default request media type}} + "post": { # Noncompliant {{OAR009: Should indicate the default request media type}} "responses": { "200": { "description": "Ok" diff --git a/src/test/resources/checks/v2/format/OAR009/without-anything.yaml b/src/test/resources/checks/v2/format/OAR009/without-anything.yaml index 8d7f1050..d10760a0 100644 --- a/src/test/resources/checks/v2/format/OAR009/without-anything.yaml +++ b/src/test/resources/checks/v2/format/OAR009/without-anything.yaml @@ -4,7 +4,7 @@ info: title: Swagger Petstore paths: /pets: - get: # Noncompliant {{OAR009: Should indicate the default request media type}} + post: # Noncompliant {{OAR009: Should indicate the default request media type}} responses: 200: description: Ok \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR010/with-default-and-specific.json b/src/test/resources/checks/v2/format/OAR010/with-default-and-specific.json index 684b14db..a497e839 100644 --- a/src/test/resources/checks/v2/format/OAR010/with-default-and-specific.json +++ b/src/test/resources/checks/v2/format/OAR010/with-default-and-specific.json @@ -9,7 +9,7 @@ ], "paths": { "/pets": { - "get": { + "post": { "produces": [ # Noncompliant {{OAR010: Should indicate the default response media type}} "application/xml" ], diff --git a/src/test/resources/checks/v2/format/OAR010/with-default-and-specific.yaml b/src/test/resources/checks/v2/format/OAR010/with-default-and-specific.yaml index 292c5fd9..44eb8c34 100644 --- a/src/test/resources/checks/v2/format/OAR010/with-default-and-specific.yaml +++ b/src/test/resources/checks/v2/format/OAR010/with-default-and-specific.yaml @@ -6,7 +6,7 @@ produces: - application/json paths: /pets: - get: + post: produces: # Noncompliant {{OAR010: Should indicate the default response media type}} - application/xml responses: diff --git a/src/test/resources/checks/v2/format/OAR010/with-specific.json b/src/test/resources/checks/v2/format/OAR010/with-specific.json index ea69febc..fb822248 100644 --- a/src/test/resources/checks/v2/format/OAR010/with-specific.json +++ b/src/test/resources/checks/v2/format/OAR010/with-specific.json @@ -18,7 +18,7 @@ } }, "/owners": { - "get": { + "post": { "produces": [ # Noncompliant {{OAR010: Should indicate the default response media type}} "application/xml" ], diff --git a/src/test/resources/checks/v2/format/OAR010/with-specific.yaml b/src/test/resources/checks/v2/format/OAR010/with-specific.yaml index 0077203b..0909c695 100644 --- a/src/test/resources/checks/v2/format/OAR010/with-specific.yaml +++ b/src/test/resources/checks/v2/format/OAR010/with-specific.yaml @@ -12,7 +12,7 @@ paths: 200: description: Ok /owners: - get: + post: produces: # Noncompliant {{OAR010: Should indicate the default response media type}} - application/xml responses: diff --git a/src/test/resources/checks/v2/format/OAR010/with-wrong-default-and-specific.json b/src/test/resources/checks/v2/format/OAR010/with-wrong-default-and-specific.json index 191f453f..0b983b0e 100644 --- a/src/test/resources/checks/v2/format/OAR010/with-wrong-default-and-specific.json +++ b/src/test/resources/checks/v2/format/OAR010/with-wrong-default-and-specific.json @@ -9,7 +9,7 @@ ], "paths": { "/pets": { - "get": { + "post": { "produces": [ # Noncompliant {{OAR010: Should indicate the default response media type}} "application/xml" ], diff --git a/src/test/resources/checks/v2/format/OAR010/with-wrong-default-and-specific.yaml b/src/test/resources/checks/v2/format/OAR010/with-wrong-default-and-specific.yaml index d4aba397..47f71f97 100644 --- a/src/test/resources/checks/v2/format/OAR010/with-wrong-default-and-specific.yaml +++ b/src/test/resources/checks/v2/format/OAR010/with-wrong-default-and-specific.yaml @@ -6,7 +6,7 @@ produces: - application/xml paths: /pets: - get: + post: produces: # Noncompliant {{OAR010: Should indicate the default response media type}} - application/xml responses: diff --git a/src/test/resources/checks/v2/format/OAR010/with-wrong-default.json b/src/test/resources/checks/v2/format/OAR010/with-wrong-default.json index 6d92362c..31975dd3 100644 --- a/src/test/resources/checks/v2/format/OAR010/with-wrong-default.json +++ b/src/test/resources/checks/v2/format/OAR010/with-wrong-default.json @@ -9,7 +9,7 @@ ], "paths": { "/pets": { - "get": { # Noncompliant {{OAR010: Should indicate the default response media type}} + "post": { # Noncompliant {{OAR010: Should indicate the default response media type}} "responses": { "200": { "description": "Ok" diff --git a/src/test/resources/checks/v2/format/OAR010/with-wrong-default.yaml b/src/test/resources/checks/v2/format/OAR010/with-wrong-default.yaml index b5ebf147..3d3126c7 100644 --- a/src/test/resources/checks/v2/format/OAR010/with-wrong-default.yaml +++ b/src/test/resources/checks/v2/format/OAR010/with-wrong-default.yaml @@ -6,7 +6,7 @@ produces: - application/xml paths: /pets: - get: # Noncompliant {{OAR010: Should indicate the default response media type}} + post: # Noncompliant {{OAR010: Should indicate the default response media type}} responses: 200: description: Ok \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR010/without-anything.json b/src/test/resources/checks/v2/format/OAR010/without-anything.json index a6f89373..0024fa04 100644 --- a/src/test/resources/checks/v2/format/OAR010/without-anything.json +++ b/src/test/resources/checks/v2/format/OAR010/without-anything.json @@ -6,7 +6,7 @@ }, "paths": { "/pets": { - "get": { # Noncompliant {{OAR010: Should indicate the default response media type}} + "post": { # Noncompliant {{OAR010: Should indicate the default response media type}} "responses": { "200": { "description": "Ok" diff --git a/src/test/resources/checks/v2/format/OAR010/without-anything.yaml b/src/test/resources/checks/v2/format/OAR010/without-anything.yaml index 3db04b5f..ba4cf83c 100644 --- a/src/test/resources/checks/v2/format/OAR010/without-anything.yaml +++ b/src/test/resources/checks/v2/format/OAR010/without-anything.yaml @@ -4,7 +4,7 @@ info: title: Swagger Petstore paths: /pets: - get: # Noncompliant {{OAR010: Should indicate the default response media type}} + post: # Noncompliant {{OAR010: Should indicate the default response media type}} responses: 200: description: Ok \ No newline at end of file