diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ce9b595..54061489 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.3.5] - 2026-04-08 + +### Fixed + - OAR102 - SecondPartBasePathCheck Test + - OAR101 - FirstPartBasePathCheck Test + - OAR034 - StandardPagedResponseSchemaCheck Test + - OAR029 - StandardResponseSchemaCheck Test + - OAR083 - ForbiddenQueryParamsCheck Test + - OAR084 - ForbiddenFormatsInQueryCheck Test + - OAR043 - ParsingErrorCheck Test + - OAR028 - FilterParameterCheck Test + - OAR073 - RateLimitCheck Test + - OAR079 - PathParameter404Check Test + + - AbstractSchemaCheck + - AbstractForbiddenQueryCheck + - AbstractPathResponseCheck + - VerbPathMatcher + ## [1.3.4] - 2026-04-01 ### Fixed diff --git a/README.md b/README.md index f7d3d3fa..1435cb3b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# 🛠️ sonaropenapi-rules ![Release](https://img.shields.io/badge/release-1.3.4-purple) ![Java](https://img.shields.io/badge/java-%23ED8B00.svg?style=flat&logo=openjdk&logoColor=white) [![License: LGPL v3](https://img.shields.io/badge/license-LGPL_v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0) +# 🛠️ sonaropenapi-rules ![Release](https://img.shields.io/badge/release-1.3.5-purple) ![Java](https://img.shields.io/badge/java-%23ED8B00.svg?style=flat&logo=openjdk&logoColor=white) [![License: LGPL v3](https://img.shields.io/badge/license-LGPL_v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0) This repository contains a set of custom SonarQube rules specifically designed to analyze and improve the quality of OpenAPI specifications. By integrating these rules, teams can ensure best practices, maintainability, and consistency in their API definitions. @@ -31,7 +31,14 @@ Feel free to drop by and greet us on our GitHub discussion or Discord chat. You [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/apiaddicts) -# 📑 Getting started +# 📑 Getting started + +## ⚠️ Prerequisites + +Before using this plugin, you must install the base **OpenAPI plugin** for SonarQube: +📦 [`sonar-openapi-plugin`](https://central.sonatype.com/artifact/org.apiaddicts.apitools.dosonarapi/sonar-openapi-plugin/versions) + +> Make sure to install the **latest available version** of the plugin and that it is properly loaded in your SonarQube instance before adding this rules plugin. ## 🔍 Configure scanner diff --git a/pom.xml b/pom.xml index 1c899a46..1a24854e 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.apiaddicts.apitools.dosonarapi sonaropenapi-rules-community - 1.3.4 + 1.3.5 sonar-plugin SonarQube OpenAPI Community Rules diff --git a/src/main/java/apiaddicts/sonar/openapi/checks/owasp/OAR073RateLimitCheck.java b/src/main/java/apiaddicts/sonar/openapi/checks/owasp/OAR073RateLimitCheck.java index fd5a827c..ace904c9 100644 --- a/src/main/java/apiaddicts/sonar/openapi/checks/owasp/OAR073RateLimitCheck.java +++ b/src/main/java/apiaddicts/sonar/openapi/checks/owasp/OAR073RateLimitCheck.java @@ -20,7 +20,7 @@ public OAR073RateLimitCheck() { @Override protected void validateOperation(JsonNode node, String currentPath) { JsonNode responsesNode = node.get("responses"); - if (responsesNode != null && responsesNode.get("429").isMissing()) { + if (responsesNode.get("429").isMissing()) { addIssue(ruleKey, translate(messageKey), responsesNode.key()); } } diff --git a/src/main/java/apiaddicts/sonar/openapi/checks/schemas/AbstractSchemaCheck.java b/src/main/java/apiaddicts/sonar/openapi/checks/schemas/AbstractSchemaCheck.java index 807efdcd..65c14041 100644 --- a/src/main/java/apiaddicts/sonar/openapi/checks/schemas/AbstractSchemaCheck.java +++ b/src/main/java/apiaddicts/sonar/openapi/checks/schemas/AbstractSchemaCheck.java @@ -1,6 +1,5 @@ package apiaddicts.sonar.openapi.checks.schemas; -import com.sonar.sslr.api.AstNode; import org.json.JSONArray; import org.json.JSONObject; import apiaddicts.sonar.openapi.checks.BaseCheck; @@ -61,17 +60,6 @@ protected Optional validateProperty(Map properties, return validateProperty(prop, propertyName, propertyType, parentNode); } - protected Optional validateProperty(JsonNode properties, String propertyName, String propertyType) { - return handleExternalRef.resolve(properties, resolvedProps -> { - if (resolvedProps.propertyNames().isEmpty()) { - addIssue(key, translate(GENERIC_PROPERTY_MISSING, propertyName), handleExternalRef.getTrueNode(resolvedProps)); - return Optional.empty(); - } - JsonNode prop = resolvedProps.get(propertyName); - return validateProperty(prop, propertyName, propertyType, handleExternalRef.getTrueNode(resolvedProps.key())); - }); - } - protected Optional validateProperty(JsonNode prop, String propertyName, String propertyType, JsonNode parentNode) { if (prop.isMissing()) { addIssue(key, translate(GENERIC_PROPERTY_MISSING, propertyName), handleExternalRef.getTrueNode(parentNode)); @@ -124,20 +112,6 @@ protected Optional validateItems(JsonNode prop, String iType) { }); } - protected void validateEnumValues(JsonNode property, Set expected) { - Set found = getEnumValues(property); - if (!expected.equals(found)) { - String propertyName = property.key().getTokenValue(); - String values = expected.stream().sorted().collect(Collectors.joining(", ")); - addIssue(key, translate("generic.enum-values", propertyName, values), handleExternalRef.getTrueNode(property.key())); - } - } - - private Set getEnumValues(JsonNode schema) { - return schema.get("enum").elements() - .stream().map(AstNode::getTokenValue).collect(Collectors.toSet()); - } - private boolean matchesTypeViaAllOf(JsonNode node, String expectedType) { JsonNode allOf = node.get("allOf"); if (allOf.isMissing()) return false; @@ -205,7 +179,4 @@ private void validateArray(JSONObject propertySchema, JsonNode propertyNode) { } } - protected JsonNode getTrueNode (JsonNode node){ - return handleExternalRef.getTrueNode(node); - } } \ No newline at end of file diff --git a/src/main/java/apiaddicts/sonar/openapi/checks/security/AbstractForbiddenQueryCheck.java b/src/main/java/apiaddicts/sonar/openapi/checks/security/AbstractForbiddenQueryCheck.java index ad11dbc9..5c86cf85 100644 --- a/src/main/java/apiaddicts/sonar/openapi/checks/security/AbstractForbiddenQueryCheck.java +++ b/src/main/java/apiaddicts/sonar/openapi/checks/security/AbstractForbiddenQueryCheck.java @@ -59,7 +59,7 @@ protected void handleOperation(JsonNode node, AstNodeType type) { if (shouldExcludePath() || !isMethod) return; JsonNode parameters = node.get("parameters"); - if (parameters == null || parameters.isMissing() || parameters.isNull()) return; + if (parameters.isMissing() || parameters.isNull()) return; validateParameters(parameters, type == OpenApi2Grammar.OPERATION); } diff --git a/src/main/java/apiaddicts/sonar/openapi/checks/security/OAR079PathParameter404Check.java b/src/main/java/apiaddicts/sonar/openapi/checks/security/OAR079PathParameter404Check.java index 015ce89c..cf1d5f7e 100644 --- a/src/main/java/apiaddicts/sonar/openapi/checks/security/OAR079PathParameter404Check.java +++ b/src/main/java/apiaddicts/sonar/openapi/checks/security/OAR079PathParameter404Check.java @@ -19,11 +19,11 @@ public OAR079PathParameter404Check() { @Override protected void validateOperation(JsonNode node, String currentPath) { JsonNode parametersNode = node.get("parameters"); - if (parametersNode == null || !parametersNode.isArray()) return; + if (!parametersNode.isArray()) return; for (JsonNode parameterNode : parametersNode.elements()) { JsonNode inNode = parameterNode.get("in"); - if (inNode != null && "path".equals(inNode.getTokenValue())) { + if ("path".equals(inNode.getTokenValue())) { JsonNode responsesNode = node.get("responses"); if (responsesNode.get("404").isMissing()) { addIssue(ruleKey, translate(messageKey), responsesNode.key()); diff --git a/src/main/java/apiaddicts/sonar/openapi/checks/security/OAR083ForbiddenQueryParamsCheck.java b/src/main/java/apiaddicts/sonar/openapi/checks/security/OAR083ForbiddenQueryParamsCheck.java index 8c4aeb29..f3ecf3b1 100644 --- a/src/main/java/apiaddicts/sonar/openapi/checks/security/OAR083ForbiddenQueryParamsCheck.java +++ b/src/main/java/apiaddicts/sonar/openapi/checks/security/OAR083ForbiddenQueryParamsCheck.java @@ -36,7 +36,7 @@ protected void validateParameters(JsonNode parametersNode, boolean isV2) { Set queryParams = parametersNode.elements().stream() .map(p -> p.get("name")) - .filter(n -> n != null && !n.isNull()) + .filter(n -> !n.isNull()) .map(JsonNode::getTokenValue) .collect(Collectors.toSet()); diff --git a/src/main/java/apiaddicts/sonar/openapi/checks/security/OAR084ForbiddenFormatsInQueryCheck.java b/src/main/java/apiaddicts/sonar/openapi/checks/security/OAR084ForbiddenFormatsInQueryCheck.java index 0715850a..f923077c 100644 --- a/src/main/java/apiaddicts/sonar/openapi/checks/security/OAR084ForbiddenFormatsInQueryCheck.java +++ b/src/main/java/apiaddicts/sonar/openapi/checks/security/OAR084ForbiddenFormatsInQueryCheck.java @@ -35,11 +35,11 @@ protected void validateParameters(JsonNode parametersNode, boolean isV2) { parametersNode.elements().forEach(param -> { JsonNode in = param.get("in"); - if (in == null || !"query".equals(in.getTokenValue())) return; + if (!"query".equals(in.getTokenValue())) return; JsonNode formatNode = isV2 ? param.get("format") : param.get("schema").get("format"); - if (formatNode != null && !formatNode.isMissing() && !formatNode.isNull() && + if (!formatNode.isMissing() && !formatNode.isNull() && forbiddenQueryFormats.contains(formatNode.getTokenValue())) { addIssue(KEY, translate(MESSAGE, formatNode.getTokenValue()), formatNode); } diff --git a/src/main/java/apiaddicts/sonar/openapi/utils/JsonNodeUtils.java b/src/main/java/apiaddicts/sonar/openapi/utils/JsonNodeUtils.java index 2923fc15..8dd2c5bc 100644 --- a/src/main/java/apiaddicts/sonar/openapi/utils/JsonNodeUtils.java +++ b/src/main/java/apiaddicts/sonar/openapi/utils/JsonNodeUtils.java @@ -9,6 +9,7 @@ import org.apiaddicts.apitools.dosonarapi.sslr.yaml.grammar.YamlParser; import java.net.HttpURLConnection; +import java.net.URI; import java.net.URL; import java.io.BufferedReader; import java.io.InputStream; @@ -89,7 +90,7 @@ private static String retriveExternalRefContent(String ref) { HttpURLConnection conn = null; try { - URL url = new URL(ref); + URL url = URI.create(ref).toURL(); conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"); diff --git a/src/main/java/apiaddicts/sonar/openapi/utils/VerbPathMatcher.java b/src/main/java/apiaddicts/sonar/openapi/utils/VerbPathMatcher.java index 4c5825c8..51e4aba5 100644 --- a/src/main/java/apiaddicts/sonar/openapi/utils/VerbPathMatcher.java +++ b/src/main/java/apiaddicts/sonar/openapi/utils/VerbPathMatcher.java @@ -119,10 +119,6 @@ private void processExclusions(String expression) { } } - public boolean matches(String verb, String path) { - return matchesWithValues(verb, path).isPresent(); - } - public Optional matchesWithValues(String verb, String path) { if (exclusionsByVerb.getOrDefault(verb, Collections.emptySet()).contains(path)) return Optional.empty(); return patternsByVerb.getOrDefault(verb, Collections.emptyList()) @@ -145,16 +141,14 @@ private Set strToSet(String str) { public boolean matches(String path) { if (!hasAtMostOneMe(path)) return false; - return pattern.matcher(path).matches(); } private boolean hasAtMostOneMe(String path) { Matcher matcher = ME_WORD_PATTERN.matcher(path); int count = 0; - while (matcher.find()) { + while (matcher.find()) if (++count > 1) return false; - } return true; } diff --git a/src/test/java/apiaddicts/sonar/openapi/checks/format/OAR101FirstPartBasePathCheckTest.java b/src/test/java/apiaddicts/sonar/openapi/checks/format/OAR101FirstPartBasePathCheckTest.java index 7aec7e37..b1024737 100644 --- a/src/test/java/apiaddicts/sonar/openapi/checks/format/OAR101FirstPartBasePathCheckTest.java +++ b/src/test/java/apiaddicts/sonar/openapi/checks/format/OAR101FirstPartBasePathCheckTest.java @@ -22,11 +22,29 @@ public void verifyInV2() { verifyV2("valid"); } + @Test + public void verifyFirstPartBasePathLogicInV2() { + ((OAR101FirstPartBasePathCheck) check).firstPartValuesStr = "api-seguros"; + + verifyV2("invalid"); + verifyV2("valid-with-values"); + verifyV2("empty-path"); + } + @Test public void verifyInV3() { verifyV3("valid"); } + @Test + public void verifyFirstPartBasePathLogicInV3() { + ((OAR101FirstPartBasePathCheck) check).firstPartValuesStr = "api-seguros"; + + verifyV3("invalid"); + verifyV3("valid-with-values"); + verifyV3("empty-path"); + } + @Override public void verifyRule() { diff --git a/src/test/java/apiaddicts/sonar/openapi/checks/format/OAR102SecondPartBasePathCheckTest.java b/src/test/java/apiaddicts/sonar/openapi/checks/format/OAR102SecondPartBasePathCheckTest.java index 5f539529..481acb92 100644 --- a/src/test/java/apiaddicts/sonar/openapi/checks/format/OAR102SecondPartBasePathCheckTest.java +++ b/src/test/java/apiaddicts/sonar/openapi/checks/format/OAR102SecondPartBasePathCheckTest.java @@ -22,11 +22,29 @@ public void verifyInV2() { verifyV2("valid"); } + @Test + public void verifySecondPartBasePathLogicInV2() { + ((OAR102SecondPartBasePathCheck) check).secondPartValuesStr = "v1"; + + verifyV2("invalid"); + verifyV2("valid-with-values"); + verifyV2("one-part-path"); + } + @Test public void verifyInV3() { verifyV3("valid"); } + @Test + public void verifySecondPartBasePathLogicInV3() { + ((OAR102SecondPartBasePathCheck) check).secondPartValuesStr = "v1"; + + verifyV3("invalid"); + verifyV3("valid-with-values"); + verifyV3("one-part-path"); + } + @Override public void verifyRule() { assertRuleProperties("OAR102 - SecondPartBasePath - The second part of the path should be one of the alloweds", RuleType.BUG, Severity.CRITICAL, tags("format")); diff --git a/src/test/java/apiaddicts/sonar/openapi/checks/operations/OAR043ParsingErrorCheckTest.java b/src/test/java/apiaddicts/sonar/openapi/checks/operations/OAR043ParsingErrorCheckTest.java index 939303bf..d26a6682 100644 --- a/src/test/java/apiaddicts/sonar/openapi/checks/operations/OAR043ParsingErrorCheckTest.java +++ b/src/test/java/apiaddicts/sonar/openapi/checks/operations/OAR043ParsingErrorCheckTest.java @@ -21,41 +21,100 @@ import com.sonar.sslr.api.RecognitionException; +import org.junit.BeforeClass; import org.junit.Test; import org.apiaddicts.apitools.dosonarapi.api.OpenApiFile; import org.apiaddicts.apitools.dosonarapi.api.OpenApiVisitorContext; import org.apiaddicts.apitools.dosonarapi.api.PreciseIssue; +import apiaddicts.sonar.openapi.I18nContext; +import apiaddicts.sonar.openapi.checks.BaseCheck; +import java.lang.reflect.Field; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; public class OAR043ParsingErrorCheckTest { + @BeforeClass + public static void setupLang() throws Exception { + I18nContext.setLang("en"); + Field field = BaseCheck.class.getDeclaredField("resourceBundle"); + field.setAccessible(true); + field.set(null, null); + } + @Test - public void reports_parsing_errors() { - OpenApiVisitorContext context = new OpenApiVisitorContext(new TestFile(), new RecognitionException(3, "Parsing exception message")); + public void reports_parsing_errors_no_cause_no_numbers() { + OpenApiVisitorContext context = new OpenApiVisitorContext(new TestFile(), + new RecognitionException(3, "Parsing exception message")); OAR043ParsingErrorCheck check = new OAR043ParsingErrorCheck(); List issues = check.scanFileForIssues(context); - assertThat(issues) - .extracting(i -> i.primaryLocation().startLine(), i -> i.primaryLocation().message()) - .contains(tuple(0, "OAR043: Error parsing line 0 column null")); + assertThat(issues).hasSize(1); + assertThat(issues.get(0).primaryLocation().startLine()).isZero(); + assertThat(issues.get(0).primaryLocation().message()).isEqualTo("OAR043: Error parsing line 0 column null"); } - private static class TestFile implements OpenApiFile { + @Test + public void reports_parsing_errors_with_numbers_in_message() { + OpenApiVisitorContext context = new OpenApiVisitorContext(new TestFile(), + new RecognitionException(0, "Error at line 5 column 10")); + OAR043ParsingErrorCheck check = new OAR043ParsingErrorCheck(); + + List issues = check.scanFileForIssues(context); + + assertThat(issues).hasSize(1); + assertThat(issues.get(0).primaryLocation().startLine()).isEqualTo(4); + } + + @Test + public void reports_parsing_errors_with_one_cause() { + RuntimeException cause = new RuntimeException("Error at line 10 column 3"); + RecognitionException ex = new RecognitionException(0, "outer") { + @Override public synchronized Throwable getCause() { return cause; } + }; + OpenApiVisitorContext context = new OpenApiVisitorContext(new TestFile(), ex); + OAR043ParsingErrorCheck check = new OAR043ParsingErrorCheck(); + + List issues = check.scanFileForIssues(context); + + assertThat(issues).hasSize(1); + assertThat(issues.get(0).primaryLocation().startLine()).isEqualTo(8); + } + + @Test + public void reports_parsing_errors_with_two_causes() { + RuntimeException deepCause = new RuntimeException("Error at line 15 column 5"); + RuntimeException shallowCause = new RuntimeException("wrapper") { + @Override public synchronized Throwable getCause() { return deepCause; } + }; + RecognitionException ex = new RecognitionException(0, "outer") { + @Override public synchronized Throwable getCause() { return shallowCause; } + }; + OpenApiVisitorContext context = new OpenApiVisitorContext(new TestFile(), ex); + OAR043ParsingErrorCheck check = new OAR043ParsingErrorCheck(); - @Override - public String content() { - return null; - } + List issues = check.scanFileForIssues(context); + + assertThat(issues).hasSize(1); + assertThat(issues.get(0).primaryLocation().startLine()).isEqualTo(12); + } - @Override - public String fileName() { - return null; - } + @Test + public void reports_no_issues_when_no_exception_and_no_issues() { + OpenApiVisitorContext context = new OpenApiVisitorContext(new TestFile(), null); + OAR043ParsingErrorCheck check = new OAR043ParsingErrorCheck(); + + List issues = check.scanFileForIssues(context); + + assertThat(issues).isEmpty(); + } + + private static class TestFile implements OpenApiFile { + @Override public String content() { return null; } + @Override public String fileName() { return null; } } } diff --git a/src/test/java/apiaddicts/sonar/openapi/checks/parameters/OAR028FilterParameterCheckTest.java b/src/test/java/apiaddicts/sonar/openapi/checks/parameters/OAR028FilterParameterCheckTest.java index 34a04ff8..765481d6 100644 --- a/src/test/java/apiaddicts/sonar/openapi/checks/parameters/OAR028FilterParameterCheckTest.java +++ b/src/test/java/apiaddicts/sonar/openapi/checks/parameters/OAR028FilterParameterCheckTest.java @@ -1,14 +1,26 @@ package apiaddicts.sonar.openapi.checks.parameters; +import java.lang.reflect.Field; +import org.junit.BeforeClass; import org.junit.Before; import org.junit.Test; import org.sonar.api.rule.Severity; import org.sonar.api.rules.RuleType; import org.sonar.api.server.rule.RuleParamType; import apiaddicts.sonar.openapi.BaseCheckTest; +import apiaddicts.sonar.openapi.I18nContext; +import apiaddicts.sonar.openapi.checks.BaseCheck; public class OAR028FilterParameterCheckTest extends BaseCheckTest { + @BeforeClass + public static void setupLang() throws Exception { + I18nContext.setLang("en"); + Field field = BaseCheck.class.getDeclaredField("resourceBundle"); + field.setAccessible(true); + field.set(null, null); + } + @Before public void init() { ruleName = "OAR028"; @@ -46,6 +58,47 @@ public void verifyInV3Without() { verifyV3("plain-without"); } + @Test + public void verifyInV2ExcludeStrategy() { + setField("pathCheckStrategy", "/exclude"); + setField("pathsStr", "/examples"); + verifyV2("exclude-noncompliant"); + } + + @Test + public void verifyInV3ExcludeStrategy() { + setField("pathCheckStrategy", "/exclude"); + setField("pathsStr", "/examples"); + verifyV3("exclude-noncompliant"); + } + + @Test + public void verifyInV2EmptyPaths() { + setField("pathsStr", ""); + verifyV2("plain"); + } + + @Test + public void verifyInV3EmptyPaths() { + setField("pathsStr", ""); + verifyV3("plain"); + } + + @Test + public void verifyInV3ComponentsParam() { + verifyV3("components-param"); + } + + private void setField(String name, String value) { + try { + java.lang.reflect.Field f = OAR028FilterParameterCheck.class.getDeclaredField(name); + f.setAccessible(true); + f.set(check, value); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Override public void verifyRule() { assertRuleProperties("OAR028 - FilterParameter - the chosen parameter must be defined in this operation", RuleType.BUG, Severity.MINOR, tags("parameters")); diff --git a/src/test/java/apiaddicts/sonar/openapi/checks/schemas/OAR029StandardResponseSchemaCheckTest.java b/src/test/java/apiaddicts/sonar/openapi/checks/schemas/OAR029StandardResponseSchemaCheckTest.java index 628456db..48ce2096 100644 --- a/src/test/java/apiaddicts/sonar/openapi/checks/schemas/OAR029StandardResponseSchemaCheckTest.java +++ b/src/test/java/apiaddicts/sonar/openapi/checks/schemas/OAR029StandardResponseSchemaCheckTest.java @@ -6,6 +6,14 @@ import org.sonar.api.rules.RuleType; import org.sonar.api.server.rule.RuleParamType; import apiaddicts.sonar.openapi.BaseCheckTest; +import apiaddicts.sonar.openapi.ExtendedOpenApiCheckVerifier; +import org.apiaddicts.apitools.dosonarapi.api.PreciseIssue; + +import java.io.File; +import java.lang.reflect.Field; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; public class OAR029StandardResponseSchemaCheckTest extends BaseCheckTest { @@ -15,6 +23,7 @@ public void init() { check = new OAR029StandardResponseSchemaCheck(); v2Path = getV2Path("schemas"); v3Path = getV3Path("schemas"); + v31Path = getV31Path("schemas"); } @Test @@ -43,6 +52,46 @@ public void verifyInV2ValidR() { verifyV2("valid-r"); } + @Test + public void verifyV2InvalidMissingRequired() { + verifyV2("invalid-missing-required"); + } + + @Test + public void verifyV2NoSchema() { + verifyV2("no-schema"); + } + + @Test + public void verifyV2Status204() { + verifyV2("status-204"); + } + + @Test + public void verifyV2DefaultResponse() { + verifyV2("default-response"); + } + + @Test + public void verifyV2ExcludedPath() { + verifyV2("excluded-path"); + } + + @Test + public void verifyV2EmptyProperties() { + verifyV2("empty-properties"); + } + + @Test + public void verifyV3MultipleContent() { + verifyV3("multiple-content"); + } + + @Test + public void verifyV3NoJsonContent() { + verifyV3("no-json-content"); + } + @Test public void verifyInV3() { verifyV3("valid"); @@ -68,6 +117,150 @@ public void verifyInV3ValidR() { verifyV3("valid-r"); } + @Test + public void verifyV31Valid() { + verifyV31("valid.yaml"); + } + + @Test + public void verifyV2WithArrayTypeValid() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"items\"],\"properties\":{\"items\":{\"type\":\"array\",\"items\":{\"type\":\"object\"}}}}"); + verifyV2("array-type-valid.yaml"); + } + + @Test + public void verifyV2WithArrayTypeMissingItems() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"items\"],\"properties\":{\"items\":{\"type\":\"array\",\"items\":{\"type\":\"object\"}}}}"); + verifyV2("array-type-missing-items.yaml"); + } + + @Test + public void verifyV2WithArrayTypeWrongItemsType() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"items\"],\"properties\":{\"items\":{\"type\":\"array\",\"items\":{\"type\":\"object\"}}}}"); + verifyV2("array-type-wrong-items-type.yaml"); + } + + @Test + public void verifyV2WithArrayTypeRecursive() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"matrix\"],\"properties\":{\"matrix\":{\"type\":\"array\",\"items\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}}}}"); + verifyV2("array-type-recursive.yaml"); + } + + @Test + public void verifyV2WithArrayTypePrimitiveItems() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"tags\"],\"properties\":{\"tags\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}}}"); + verifyV2("array-type-primitive-items.yaml"); + } + + @Test + public void verifyV2WithInvalidSchema() throws Exception { + setResponseSchema("not valid json"); + List issues = ExtendedOpenApiCheckVerifier.scanFileForIssues( + new File(v2Path + "valid.yaml"), check, true, false, false); + assertThat(issues).isNotEmpty(); + } + + @Test + public void verifyV2WithRequiredOnSuccessAndError() throws Exception { + setResponseSchema("{\"requiredOnSuccess\":[\"status\"],\"requiredOnError\":[\"status\"]}"); + verifyV2("required-on-success-valid.yaml"); + } + + @Test + public void verifyV2WithRequiredAlwaysAndDataProperty() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"payload\"],\"dataProperty\":\"payload\",\"properties\":{\"payload\":{\"type\":\"object\"}}}"); + verifyV2("data-property.yaml"); + } + + @Test + public void verifyV2WithEmptyDataProperty() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"payload\"],\"dataProperty\":\"payload\",\"properties\":{\"payload\":{\"type\":\"object\"}}}"); + verifyV2("data-property-empty.yaml"); + } + + @Test + public void verifyV2WithArrayParentDataProperty() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"payload\"],\"dataProperty\":\"payload\",\"properties\":{\"payload\":{\"type\":\"object\"}}}"); + verifyV2("data-property-array-parent.yaml"); + } + + @Test + public void verifyV2WithRootProperty() throws Exception { + setResponseSchema("{\"rootProperty\":\"data\",\"requiredAlways\":[\"id\"],\"properties\":{\"id\":{\"type\":\"string\"}}}"); + verifyV2("root-property-valid.yaml"); + } + + @Test + public void verifyV2WithRootPropertyEmptySub() throws Exception { + setResponseSchema("{\"rootProperty\":\"data\",\"requiredAlways\":[\"id\"],\"properties\":{\"id\":{\"type\":\"string\"}}}"); + verifyV2("root-property-empty-sub.yaml"); + } + + @Test + public void verifyV2WithRootPropertyWildcard() throws Exception { + setResponseSchema("{\"rootProperty\":\"*\",\"requiredAlways\":[\"id\"],\"properties\":{\"id\":{\"type\":\"string\"}}}"); + verifyV2("root-wildcard-valid.yaml"); + } + + @Test + public void verifyV2WithEmptyRequiredOnSuccess() throws Exception { + setResponseSchema("{\"requiredOnSuccess\":[],\"requiredOnError\":[],\"requiredAlways\":[]}"); + verifyV2("required-on-success-valid.yaml"); + } + + @Test + public void verifyV2WithNullDataPropertySchema() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"payload\"],\"dataProperty\":\"payload\"}"); + verifyV2("data-property.yaml"); + } + + @Test + public void verifyV2WithDataPropertySchemaNoType() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"payload\"],\"dataProperty\":\"payload\",\"properties\":{\"payload\":{}}}"); + verifyV2("data-property.yaml"); + } + + @Test + public void verifyV2WithDataPropertySchemaAnyType() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"payload\"],\"dataProperty\":\"payload\",\"properties\":{\"payload\":{\"type\":\"any\"}}}"); + verifyV2("data-property.yaml"); + } + + @Test + public void verifyV2WithRequiredNameNotInProperties() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"payload\",\"extra\"],\"dataProperty\":\"payload\",\"properties\":{\"payload\":{\"type\":\"object\"}}}"); + verifyV2("data-property-extra-required.yaml"); + } + + @Test + public void verifyV2WithArrayParentDataPropertyEmpty() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"payload\"],\"dataProperty\":\"payload\",\"properties\":{\"payload\":{\"type\":\"object\"}}}"); + verifyV2("data-property-array-parent-empty.yaml"); + } + + @Test + public void verifyV2WithPropertySchemaAnyType() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"status\"],\"properties\":{\"status\":{\"type\":\"any\"}}}"); + verifyV2("status-any-type.yaml"); + } + + @Test + public void verifyV2WithPropertySchemaNoType() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"status\"],\"properties\":{\"status\":{\"properties\":{\"code\":{\"type\":\"integer\"}}}}}"); + verifyV2("status-schema-with-properties.yaml"); + } + + @Test + public void verifyV2WithArrayItemsNoType() throws Exception { + setResponseSchema("{\"requiredAlways\":[\"items\"],\"properties\":{\"items\":{\"type\":\"array\",\"items\":{\"type\":\"object\"}}}}"); + verifyV2("array-items-no-type.yaml"); + } + + private void setResponseSchema(String schema) throws Exception { + Field field = OAR029StandardResponseSchemaCheck.class.getDeclaredField("responseSchemaStr"); + field.setAccessible(true); + field.set(check, schema); + } @Override public void verifyParameters() { diff --git a/src/test/java/apiaddicts/sonar/openapi/checks/schemas/OAR034StandardPagedResponseSchemaCheckTest.java b/src/test/java/apiaddicts/sonar/openapi/checks/schemas/OAR034StandardPagedResponseSchemaCheckTest.java index e967029a..0db4b1c2 100644 --- a/src/test/java/apiaddicts/sonar/openapi/checks/schemas/OAR034StandardPagedResponseSchemaCheckTest.java +++ b/src/test/java/apiaddicts/sonar/openapi/checks/schemas/OAR034StandardPagedResponseSchemaCheckTest.java @@ -6,6 +6,13 @@ import org.sonar.api.rules.RuleType; import org.sonar.api.server.rule.RuleParamType; import apiaddicts.sonar.openapi.BaseCheckTest; +import apiaddicts.sonar.openapi.ExtendedOpenApiCheckVerifier; +import org.apiaddicts.apitools.dosonarapi.api.PreciseIssue; + +import java.io.File; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; public class OAR034StandardPagedResponseSchemaCheckTest extends BaseCheckTest { @@ -107,6 +114,25 @@ public void verifyInV3WithoutPaginationRequiredFields() { verifyV3("without-pagination-required-fields"); } + @Test + public void verifyInV2WithPagingNoType() { + List issues = ExtendedOpenApiCheckVerifier.scanFileForIssues( + new File(v2Path + "with-paging-no-type.yaml"), check, true, false, false); + assertThat(issues).isNotEmpty(); + } + + @Test + public void verifyInV2WithPagingAllofWrongType() { + verifyV2("with-paging-allof-wrong-type.yaml"); + } + + @Test + public void verifyInV2WithoutPagingRequiredKey() { + List issues = ExtendedOpenApiCheckVerifier.scanFileForIssues( + new File(v2Path + "without-paging-required-key.yaml"), check, true, false, false); + assertThat(issues).isNotEmpty(); + } + @Override public void verifyParameters() { assertNumberOfParameters(1); diff --git a/src/test/java/apiaddicts/sonar/openapi/checks/security/OAR079PathParameter404CheckTest.java b/src/test/java/apiaddicts/sonar/openapi/checks/security/OAR079PathParameter404CheckTest.java index 47637492..d621120d 100644 --- a/src/test/java/apiaddicts/sonar/openapi/checks/security/OAR079PathParameter404CheckTest.java +++ b/src/test/java/apiaddicts/sonar/openapi/checks/security/OAR079PathParameter404CheckTest.java @@ -37,6 +37,26 @@ public void verifyInV3NoBadRequest() { verifyV3("no-bad-request404"); } + @Test + public void verifyInV2NoParameters() { + verifyV2("no-parameters"); + } + + @Test + public void verifyInV2QueryParamOnly() { + verifyV2("query-param-only"); + } + + @Test + public void verifyInV3NoParameters() { + verifyV3("no-parameters"); + } + + @Test + public void verifyInV3QueryParamOnly() { + verifyV3("query-param-only"); + } + @Override public void verifyRule() { assertRuleProperties("OAR079 - PathParameter404 - Paths parameters, should have not found (404) response", diff --git a/src/test/java/apiaddicts/sonar/openapi/checks/security/OAR083ForbiddenQueryParamsCheckTest.java b/src/test/java/apiaddicts/sonar/openapi/checks/security/OAR083ForbiddenQueryParamsCheckTest.java index 001bceef..9e6e6c72 100644 --- a/src/test/java/apiaddicts/sonar/openapi/checks/security/OAR083ForbiddenQueryParamsCheckTest.java +++ b/src/test/java/apiaddicts/sonar/openapi/checks/security/OAR083ForbiddenQueryParamsCheckTest.java @@ -27,6 +27,42 @@ public void verifyInV2ForbiddenQueryParams() { verifyV2("forbidden-query-params"); } + @Test + public void verifyInV2NoParameters() { + verifyV2("no-parameters"); + } + + @Test + public void verifyInV2NullNameParam() { + verifyV2("null-name-param"); + } + + @Test + public void verifyInV2OptionsOperation() { + verifyV2("options-operation"); + } + + @Test + public void verifyPathFilteringStrategiesInV2() { + OAR083ForbiddenQueryParamsCheck c = (OAR083ForbiddenQueryParamsCheck) check; + + c.pathsStr = "/examples"; + c.pathCheckStrategy = "/exclude"; + verifyV2("valid-query-params"); + + c.pathCheckStrategy = "/include"; + verifyV2("valid-query-params"); + + c.pathsStr = "/other"; + verifyV2("valid-query-params"); + } + + @Test + public void verifyInV2EmptyForbiddenQueryParams() { + ((OAR083ForbiddenQueryParamsCheck) check).forbiddenQueryParamsStr = ""; + verifyV2("valid-query-params"); + } + @Test public void verifyInV3() { verifyV3("valid-query-params"); @@ -37,6 +73,43 @@ public void verifyInV3ForbiddenQueryParams() { verifyV3("forbidden-query-params"); } + @Test + public void verifyInV3NoParameters() { + verifyV3("no-parameters"); + } + + @Test + public void verifyInV3NullNameParam() { + verifyV3("null-name-param"); + } + + @Test + public void verifyInV3OptionsOperation() { + verifyV3("options-operation"); + } + + @Test + public void verifyPathFilteringStrategiesInV3() { + OAR083ForbiddenQueryParamsCheck c = (OAR083ForbiddenQueryParamsCheck) check; + + c.pathsStr = "/examples"; + c.pathCheckStrategy = "/exclude"; + verifyV3("valid-query-params"); + + c.pathsStr = "/items"; + c.pathCheckStrategy = "/include"; + verifyV3("valid-query-params"); + + c.pathsStr = "/other"; + verifyV3("valid-query-params"); + } + + @Test + public void verifyInV3EmptyForbiddenQueryParams() { + ((OAR083ForbiddenQueryParamsCheck) check).forbiddenQueryParamsStr = ""; + verifyV3("valid-query-params"); + } + @Override public void verifyRule() { assertRuleProperties("OAR083 - ForbiddenQueryParams - Some parameters should not pass through this querystring", RuleType.VULNERABILITY, Severity.MAJOR, tags("safety")); diff --git a/src/test/java/apiaddicts/sonar/openapi/checks/security/OAR084ForbiddenFormatsInQueryCheckTest.java b/src/test/java/apiaddicts/sonar/openapi/checks/security/OAR084ForbiddenFormatsInQueryCheckTest.java index d6fe8471..bf863efc 100644 --- a/src/test/java/apiaddicts/sonar/openapi/checks/security/OAR084ForbiddenFormatsInQueryCheckTest.java +++ b/src/test/java/apiaddicts/sonar/openapi/checks/security/OAR084ForbiddenFormatsInQueryCheckTest.java @@ -27,6 +27,42 @@ public void verifyInV2ForbiddenQueryFormats() { verifyV2("forbidden-query-formats"); } + @Test + public void verifyInV2NoParameters() { + verifyV2("no-parameters"); + } + + @Test + public void verifyInV2NonQueryParam() { + verifyV2("non-query-param"); + } + + @Test + public void verifyInV2NullFormatParam() { + verifyV2("null-format-param"); + } + + @Test + public void verifyPathFilteringStrategiesInV2() { + OAR084ForbiddenFormatsInQueryCheck c = (OAR084ForbiddenFormatsInQueryCheck) check; + + c.pathsStr = "/examples"; + c.pathCheckStrategy = "/exclude"; + verifyV2("valid-query-formats"); + + c.pathCheckStrategy = "/include"; + verifyV2("valid-query-formats"); + + c.pathsStr = "/other"; + verifyV2("valid-query-formats"); + } + + @Test + public void verifyInV2EmptyForbiddenQueryFormats() { + ((OAR084ForbiddenFormatsInQueryCheck) check).forbiddenQueryFormatsStr = ""; + verifyV2("valid-query-formats"); + } + @Test public void verifyInV3() { verifyV3("valid-query-formats"); @@ -37,6 +73,42 @@ public void verifyInV3ForbiddenQueryFormats() { verifyV3("forbidden-query-formats"); } + @Test + public void verifyInV3NoParameters() { + verifyV3("no-parameters"); + } + + @Test + public void verifyInV3NonQueryParam() { + verifyV3("non-query-param"); + } + + @Test + public void verifyInV3NullFormatParam() { + verifyV3("null-format-param"); + } + + @Test + public void verifyPathFilteringStrategiesInV3() { + OAR084ForbiddenFormatsInQueryCheck c = (OAR084ForbiddenFormatsInQueryCheck) check; + + c.pathsStr = "/examples"; + c.pathCheckStrategy = "/exclude"; + verifyV3("valid-query-formats"); + + c.pathCheckStrategy = "/include"; + verifyV3("valid-query-formats"); + + c.pathsStr = "/other"; + verifyV3("valid-query-formats"); + } + + @Test + public void verifyInV3EmptyForbiddenQueryFormats() { + ((OAR084ForbiddenFormatsInQueryCheck) check).forbiddenQueryFormatsStr = ""; + verifyV3("valid-query-formats"); + } + @Override public void verifyRule() { assertRuleProperties("OAR084 - ForbiddenQueryFormats - Some formats should not pass through this querystring", RuleType.VULNERABILITY, Severity.MAJOR, tags("safety")); diff --git a/src/test/resources/checks/v2/format/OAR101/empty-path.json b/src/test/resources/checks/v2/format/OAR101/empty-path.json new file mode 100644 index 00000000..8b816ad9 --- /dev/null +++ b/src/test/resources/checks/v2/format/OAR101/empty-path.json @@ -0,0 +1,9 @@ +{ + "swagger" : "2.0", + "info" : { + "version" : "1.0.0", + "title" : "Swagger Petstore" + }, + "basePath" : "/", + "paths" : { } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR101/empty-path.yaml b/src/test/resources/checks/v2/format/OAR101/empty-path.yaml new file mode 100644 index 00000000..8a1a4535 --- /dev/null +++ b/src/test/resources/checks/v2/format/OAR101/empty-path.yaml @@ -0,0 +1,6 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Swagger Petstore +basePath: / +paths: {} \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR101/invalid.json b/src/test/resources/checks/v2/format/OAR101/invalid.json new file mode 100644 index 00000000..6a0240b8 --- /dev/null +++ b/src/test/resources/checks/v2/format/OAR101/invalid.json @@ -0,0 +1,9 @@ +{ + "swagger" : "2.0", + "info" : { + "version" : "1.0.0", + "title" : "Swagger Petstore" + }, + "basePath" : "/wrong/v1", # Noncompliant {{OAR101: The first part of the path is not allowed. Allowed values are: wrong}} + "paths" : { } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR101/invalid.yaml b/src/test/resources/checks/v2/format/OAR101/invalid.yaml new file mode 100644 index 00000000..690ec3cb --- /dev/null +++ b/src/test/resources/checks/v2/format/OAR101/invalid.yaml @@ -0,0 +1,6 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Swagger Petstore +basePath: /wrong/v1 # Noncompliant {{OAR101: The first part of the path is not allowed. Allowed values are: wrong}} +paths: {} \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR101/valid-with-values.json b/src/test/resources/checks/v2/format/OAR101/valid-with-values.json new file mode 100644 index 00000000..64edad3b --- /dev/null +++ b/src/test/resources/checks/v2/format/OAR101/valid-with-values.json @@ -0,0 +1,9 @@ +{ + "swagger" : "2.0", + "info" : { + "version" : "1.0.0", + "title" : "Swagger Petstore" + }, + "basePath" : "/api-seguros/v1", + "paths" : { } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR101/valid-with-values.yaml b/src/test/resources/checks/v2/format/OAR101/valid-with-values.yaml new file mode 100644 index 00000000..c1f97597 --- /dev/null +++ b/src/test/resources/checks/v2/format/OAR101/valid-with-values.yaml @@ -0,0 +1,6 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Swagger Petstore +basePath: /api-seguros/v1 +paths: {} \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR102/invalid.json b/src/test/resources/checks/v2/format/OAR102/invalid.json new file mode 100644 index 00000000..d53dbbba --- /dev/null +++ b/src/test/resources/checks/v2/format/OAR102/invalid.json @@ -0,0 +1,9 @@ +{ + "swagger" : "2.0", + "info" : { + "version" : "1.0.0", + "title" : "Swagger Petstore" + }, + "basePath" : "/api-seguros/wrong", # Noncompliant {{OAR102: The second part of the path is not allowed. Allowed values are: wrong}} + "paths" : { } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR102/invalid.yaml b/src/test/resources/checks/v2/format/OAR102/invalid.yaml new file mode 100644 index 00000000..dc32fa03 --- /dev/null +++ b/src/test/resources/checks/v2/format/OAR102/invalid.yaml @@ -0,0 +1,6 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Swagger Petstore +basePath: /api-seguros/wrong # Noncompliant {{OAR102: The second part of the path is not allowed. Allowed values are: wrong}} +paths: {} \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR102/one-part-path.json b/src/test/resources/checks/v2/format/OAR102/one-part-path.json new file mode 100644 index 00000000..f10ee3df --- /dev/null +++ b/src/test/resources/checks/v2/format/OAR102/one-part-path.json @@ -0,0 +1,9 @@ +{ + "swagger" : "2.0", + "info" : { + "version" : "1.0.0", + "title" : "Swagger Petstore" + }, + "basePath" : "/api-seguros", + "paths" : { } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR102/one-part-path.yaml b/src/test/resources/checks/v2/format/OAR102/one-part-path.yaml new file mode 100644 index 00000000..e6473524 --- /dev/null +++ b/src/test/resources/checks/v2/format/OAR102/one-part-path.yaml @@ -0,0 +1,6 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Swagger Petstore +basePath: /api-seguros +paths: {} \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR102/valid-with-values.json b/src/test/resources/checks/v2/format/OAR102/valid-with-values.json new file mode 100644 index 00000000..64edad3b --- /dev/null +++ b/src/test/resources/checks/v2/format/OAR102/valid-with-values.json @@ -0,0 +1,9 @@ +{ + "swagger" : "2.0", + "info" : { + "version" : "1.0.0", + "title" : "Swagger Petstore" + }, + "basePath" : "/api-seguros/v1", + "paths" : { } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/format/OAR102/valid-with-values.yaml b/src/test/resources/checks/v2/format/OAR102/valid-with-values.yaml new file mode 100644 index 00000000..c1f97597 --- /dev/null +++ b/src/test/resources/checks/v2/format/OAR102/valid-with-values.yaml @@ -0,0 +1,6 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Swagger Petstore +basePath: /api-seguros/v1 +paths: {} \ No newline at end of file diff --git a/src/test/resources/checks/v2/owasp/OAR073/no-responses.json b/src/test/resources/checks/v2/owasp/OAR073/no-responses.json new file mode 100644 index 00000000..67ba2974 --- /dev/null +++ b/src/test/resources/checks/v2/owasp/OAR073/no-responses.json @@ -0,0 +1,14 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "Compliant API" + }, + "paths": { + "/items": { + "get": { + "summary": "Get a list of items with no responses key" + } + } + } +} diff --git a/src/test/resources/checks/v2/owasp/OAR073/no-responses.yaml b/src/test/resources/checks/v2/owasp/OAR073/no-responses.yaml new file mode 100644 index 00000000..0746301c --- /dev/null +++ b/src/test/resources/checks/v2/owasp/OAR073/no-responses.yaml @@ -0,0 +1,8 @@ +swagger: '2.0' +info: + version: 1.0.0 + title: Compliant API +paths: + /items: + get: + summary: Get a list of items with no responses key diff --git a/src/test/resources/checks/v2/parameters/OAR028/exclude-noncompliant.json b/src/test/resources/checks/v2/parameters/OAR028/exclude-noncompliant.json new file mode 100644 index 00000000..01030ba9 --- /dev/null +++ b/src/test/resources/checks/v2/parameters/OAR028/exclude-noncompliant.json @@ -0,0 +1,33 @@ +{ + "swagger" : "2.0", + "info" : { + "version" : "1.0.0", + "title" : "Swagger Petstore" + }, + "paths" : { + "/status" : { + "get" : { + "parameters" : [ { + "in" : "query", + "name" : "other", # Noncompliant {{OAR028: $filter must be defined as a parameter in this operation}} + "type" : "array", + "items" : { + "type" : "string" + } + }, { + "in" : "query", + "name" : "select", # Noncompliant {{OAR028: $filter must be defined as a parameter in this operation}} + "type" : "array", + "items" : { + "type" : "string" + } + } ], + "responses" : { + "206" : { + "description" : "Ok" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v2/parameters/OAR028/exclude-noncompliant.yaml b/src/test/resources/checks/v2/parameters/OAR028/exclude-noncompliant.yaml new file mode 100644 index 00000000..5b5548d1 --- /dev/null +++ b/src/test/resources/checks/v2/parameters/OAR028/exclude-noncompliant.yaml @@ -0,0 +1,21 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Swagger Petstore +paths: + /status: + get: + parameters: + - in: query + name: other # Noncompliant {{OAR028: $filter must be defined as a parameter in this operation}} + type: array + items: + type: string + - in: query + name: select # Noncompliant {{OAR028: $filter must be defined as a parameter in this operation}} + type: array + items: + type: string + responses: + 206: + description: Ok diff --git a/src/test/resources/checks/v2/resources/OAR018/plain.yaml b/src/test/resources/checks/v2/resources/OAR018/plain.yaml index db703729..37421696 100644 --- a/src/test/resources/checks/v2/resources/OAR018/plain.yaml +++ b/src/test/resources/checks/v2/resources/OAR018/plain.yaml @@ -47,6 +47,28 @@ paths: 200: description: Ok + /resources/me: + get: + responses: + 200: + description: Ok + post: # Noncompliant {{OAR018: Operation not recommended for resource path: POST /resources/me}} + responses: + 200: + description: Ok + put: + responses: + 200: + description: Ok + patch: + responses: + 200: + description: Ok + delete: + responses: + 200: + description: Ok + /resources/get: get: # Noncompliant {{OAR018: Operation not recommended for resource path: GET /resources/get}} responses: diff --git a/src/test/resources/checks/v2/schemas/OAR029/array-items-no-type.yaml b/src/test/resources/checks/v2/schemas/OAR029/array-items-no-type.yaml new file mode 100644 index 00000000..36da59fc --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/array-items-no-type.yaml @@ -0,0 +1,20 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + items: + type: array + items: + description: has properties but no explicit type # Noncompliant {{OAR029: 'items' items must be of type object}} + properties: + id: + type: string diff --git a/src/test/resources/checks/v2/schemas/OAR029/array-type-missing-items.yaml b/src/test/resources/checks/v2/schemas/OAR029/array-type-missing-items.yaml new file mode 100644 index 00000000..451942e0 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/array-type-missing-items.yaml @@ -0,0 +1,15 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + items: # Noncompliant {{OAR029: 'items' items are missing}} + type: array diff --git a/src/test/resources/checks/v2/schemas/OAR029/array-type-primitive-items.yaml b/src/test/resources/checks/v2/schemas/OAR029/array-type-primitive-items.yaml new file mode 100644 index 00000000..ee1b0bf0 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/array-type-primitive-items.yaml @@ -0,0 +1,17 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + tags: + type: array + items: + type: string diff --git a/src/test/resources/checks/v2/schemas/OAR029/array-type-recursive.yaml b/src/test/resources/checks/v2/schemas/OAR029/array-type-recursive.yaml new file mode 100644 index 00000000..cf1ed622 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/array-type-recursive.yaml @@ -0,0 +1,19 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + matrix: + type: array + items: + type: array + items: + type: string diff --git a/src/test/resources/checks/v2/schemas/OAR029/array-type-valid.yaml b/src/test/resources/checks/v2/schemas/OAR029/array-type-valid.yaml new file mode 100644 index 00000000..05b82cc9 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/array-type-valid.yaml @@ -0,0 +1,20 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + items: + type: array + items: + type: object + properties: + id: + type: string diff --git a/src/test/resources/checks/v2/schemas/OAR029/array-type-wrong-items-type.yaml b/src/test/resources/checks/v2/schemas/OAR029/array-type-wrong-items-type.yaml new file mode 100644 index 00000000..ccf8922b --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/array-type-wrong-items-type.yaml @@ -0,0 +1,17 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + items: + type: array + items: + type: string # Noncompliant {{OAR029: 'items' items must be of type object}} diff --git a/src/test/resources/checks/v2/schemas/OAR029/data-property-array-parent-empty.yaml b/src/test/resources/checks/v2/schemas/OAR029/data-property-array-parent-empty.yaml new file mode 100644 index 00000000..fcb2c416 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/data-property-array-parent-empty.yaml @@ -0,0 +1,15 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: array + properties: + payload: + type: object diff --git a/src/test/resources/checks/v2/schemas/OAR029/data-property-array-parent.yaml b/src/test/resources/checks/v2/schemas/OAR029/data-property-array-parent.yaml new file mode 100644 index 00000000..7075f9fd --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/data-property-array-parent.yaml @@ -0,0 +1,18 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: array + properties: + payload: + type: object + properties: + id: + type: string diff --git a/src/test/resources/checks/v2/schemas/OAR029/data-property-empty.yaml b/src/test/resources/checks/v2/schemas/OAR029/data-property-empty.yaml new file mode 100644 index 00000000..dc3c0a75 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/data-property-empty.yaml @@ -0,0 +1,15 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + payload: # Noncompliant {{OAR029: At least one property must be defined}} + type: object diff --git a/src/test/resources/checks/v2/schemas/OAR029/data-property-extra-required.yaml b/src/test/resources/checks/v2/schemas/OAR029/data-property-extra-required.yaml new file mode 100644 index 00000000..fa10067e --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/data-property-extra-required.yaml @@ -0,0 +1,20 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: # Noncompliant {{OAR029: 'extra' property is missing}} + type: object + properties: + payload: + type: object + properties: + id: + type: string + status: + type: object diff --git a/src/test/resources/checks/v2/schemas/OAR029/data-property.json b/src/test/resources/checks/v2/schemas/OAR029/data-property.json new file mode 100644 index 00000000..7fad1c71 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/data-property.json @@ -0,0 +1,34 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "Test" + }, + "paths": { + "/test": { + "get": { + "responses": { + "200": { + "description": "ok", + "schema": { + "type": "object", + "properties": { + "payload": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } + }, + "status": { + "type": "object" + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/data-property.yaml b/src/test/resources/checks/v2/schemas/OAR029/data-property.yaml new file mode 100644 index 00000000..c7c52762 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/data-property.yaml @@ -0,0 +1,20 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + payload: + type: object + properties: + id: + type: string + status: + type: object \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/default-response.json b/src/test/resources/checks/v2/schemas/OAR029/default-response.json new file mode 100644 index 00000000..3a4e51ad --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/default-response.json @@ -0,0 +1,29 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "Test" + }, + "paths": { + "/test": { + "get": { + "responses": { + "default": { + "description": "error", + "schema": { + "type": "object", + "properties": { + "status": { + "type": "object" + }, + "payload": { + "type": "object" + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/default-response.yaml b/src/test/resources/checks/v2/schemas/OAR029/default-response.yaml new file mode 100644 index 00000000..c0afe00a --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/default-response.yaml @@ -0,0 +1,17 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + default: + description: error + schema: + type: object + properties: + status: + type: object + payload: + type: object \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/empty-properties.json b/src/test/resources/checks/v2/schemas/OAR029/empty-properties.json new file mode 100644 index 00000000..1cb3521d --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/empty-properties.json @@ -0,0 +1,26 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "Test" + }, + "paths": { + "/test": { + "get": { + "responses": { + "200": { + "description": "ok", + "schema": { + "type": "object", + "properties": { + "payload": { + "type": "object" + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/empty-properties.yaml b/src/test/resources/checks/v2/schemas/OAR029/empty-properties.yaml new file mode 100644 index 00000000..f111adb8 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/empty-properties.yaml @@ -0,0 +1,15 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + payload: + type: object \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/excluded-path.json b/src/test/resources/checks/v2/schemas/OAR029/excluded-path.json new file mode 100644 index 00000000..4e1a39f9 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/excluded-path.json @@ -0,0 +1,21 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "Test" + }, + "paths": { + "/status": { + "get": { + "responses": { + "200": { + "description": "ok", + "schema": { + "type": "object" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/excluded-path.yaml b/src/test/resources/checks/v2/schemas/OAR029/excluded-path.yaml new file mode 100644 index 00000000..b14b6bda --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/excluded-path.yaml @@ -0,0 +1,12 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /status: + get: + responses: + "200": + description: ok + schema: + type: object \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/invalid-missing-required.json b/src/test/resources/checks/v2/schemas/OAR029/invalid-missing-required.json new file mode 100644 index 00000000..8f7be930 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/invalid-missing-required.json @@ -0,0 +1,26 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "Test" + }, + "paths": { + "/test": { + "get": { + "responses": { + "200": { + "description": "ok", + "schema": { + "type": "object", + "properties": { + "status": { + "type": "object" + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/invalid-missing-required.yaml b/src/test/resources/checks/v2/schemas/OAR029/invalid-missing-required.yaml new file mode 100644 index 00000000..db7150cf --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/invalid-missing-required.yaml @@ -0,0 +1,15 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + status: + type: object \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/no-schema.json b/src/test/resources/checks/v2/schemas/OAR029/no-schema.json new file mode 100644 index 00000000..fb78cb23 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/no-schema.json @@ -0,0 +1,18 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "Test" + }, + "paths": { + "/test": { + "get": { + "responses": { + "200": { + "description": "ok" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/no-schema.yaml b/src/test/resources/checks/v2/schemas/OAR029/no-schema.yaml new file mode 100644 index 00000000..362bb794 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/no-schema.yaml @@ -0,0 +1,10 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/required-on-success-valid.yaml b/src/test/resources/checks/v2/schemas/OAR029/required-on-success-valid.yaml new file mode 100644 index 00000000..055e401e --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/required-on-success-valid.yaml @@ -0,0 +1,24 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "100": + description: info + "200": + description: ok + schema: + type: object + properties: + status: + type: object + "400": + description: error + schema: + type: object + properties: + status: + type: object diff --git a/src/test/resources/checks/v2/schemas/OAR029/root-property-empty-sub.yaml b/src/test/resources/checks/v2/schemas/OAR029/root-property-empty-sub.yaml new file mode 100644 index 00000000..284f23ac --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/root-property-empty-sub.yaml @@ -0,0 +1,15 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + data: # Noncompliant {{OAR029: At least one property must be defined}} {{OAR029: 'id' property is missing}} + type: object diff --git a/src/test/resources/checks/v2/schemas/OAR029/root-property-valid.yaml b/src/test/resources/checks/v2/schemas/OAR029/root-property-valid.yaml new file mode 100644 index 00000000..bb5aae03 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/root-property-valid.yaml @@ -0,0 +1,18 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string diff --git a/src/test/resources/checks/v2/schemas/OAR029/root-wildcard-valid.yaml b/src/test/resources/checks/v2/schemas/OAR029/root-wildcard-valid.yaml new file mode 100644 index 00000000..bb5aae03 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/root-wildcard-valid.yaml @@ -0,0 +1,18 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string diff --git a/src/test/resources/checks/v2/schemas/OAR029/status-204.json b/src/test/resources/checks/v2/schemas/OAR029/status-204.json new file mode 100644 index 00000000..58e2c758 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/status-204.json @@ -0,0 +1,18 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "Test" + }, + "paths": { + "/test": { + "get": { + "responses": { + "204": { + "description": "no content" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/status-204.yaml b/src/test/resources/checks/v2/schemas/OAR029/status-204.yaml new file mode 100644 index 00000000..2aa0006d --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/status-204.yaml @@ -0,0 +1,10 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "204": + description: no content \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/status-any-type.yaml b/src/test/resources/checks/v2/schemas/OAR029/status-any-type.yaml new file mode 100644 index 00000000..c83cdf8b --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/status-any-type.yaml @@ -0,0 +1,15 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + status: + type: object diff --git a/src/test/resources/checks/v2/schemas/OAR029/status-schema-with-properties.yaml b/src/test/resources/checks/v2/schemas/OAR029/status-schema-with-properties.yaml new file mode 100644 index 00000000..7f922f6a --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR029/status-schema-with-properties.yaml @@ -0,0 +1,18 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + schema: + type: object + properties: + status: + type: object + properties: + code: + type: integer diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-error-with-properties-wrong-type-r.json b/src/test/resources/checks/v2/schemas/OAR029/with-error-with-properties-wrong-type-r.json deleted file mode 100644 index b7686dd2..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-error-with-properties-wrong-type-r.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore" - }, - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "schema": { - "$ref": "#/definitions/successResponse" - } - }, - "204": { - "description": "No content" - }, - "400": { - "description": "Error", - "schema": { - "$ref": "#/definitions/errorResponse" - } - }, - "default": { - "description": "Unknown" - } - } - } - } - }, - "definitions": { - "successResponse": { - "type": "object", - "properties": { - "payload": { - "type": "object", - "properties": { - "tipos": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "errorResponse": { - "type": "object", - "properties": { - "error": { - "type": "object", - "properties": { - "code": { - "type": "integer" # Noncompliant {{OAR029: 'code' must be of type string}} - }, - "message": { - "type": "integer" # Noncompliant {{OAR029: 'message' must be of type string}} - }, - "details": { - "type": "integer" # Noncompliant {{OAR029: 'details' must be of type array}} - }, - "httpStatus": { - "type": "string" # Noncompliant {{OAR029: 'httpStatus' must be of type integer}} - } - }, - "required": [ - "code", - "message", - "httpStatus" - ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-error-with-properties-wrong-type-r.yaml b/src/test/resources/checks/v2/schemas/OAR029/with-error-with-properties-wrong-type-r.yaml deleted file mode 100644 index be2d6003..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-error-with-properties-wrong-type-r.yaml +++ /dev/null @@ -1,50 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/successResponse' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/errorResponse' - default: - description: Unknown - -definitions: - successResponse: - type: object - properties: - payload: - type: object - properties: - tipos: - type: array - items: - type: string - errorResponse: - type: object - properties: - error: - type: object - properties: - code: - type: integer # Noncompliant {{OAR029: 'code' must be of type string}} - message: - type: integer # Noncompliant {{OAR029: 'message' must be of type string}} - details: - type: integer # Noncompliant {{OAR029: 'details' must be of type array}} - httpStatus: - type: string # Noncompliant {{OAR029: 'httpStatus' must be of type integer}} - required: - - code - - message - - httpStatus diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-error-without-properties-r.json b/src/test/resources/checks/v2/schemas/OAR029/with-error-without-properties-r.json deleted file mode 100644 index da18c418..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-error-without-properties-r.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore" - }, - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "schema": { - "$ref": "#/definitions/successResponse" - } - }, - "204": { - "description": "No content" - }, - "400": { - "description": "Error", - "schema": { - "$ref": "#/definitions/errorResponse" - } - }, - "default": { - "description": "Unknown" - } - } - } - } - }, - "definitions": { - "successResponse": { - "type": "object", - "properties": { - "payload": { - "type": "object", - "properties": { - "tipos": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "errorResponse": { - "type": "object", - "properties": { - "error": { # Noncompliant {{OAR029: 'code' property is missing}} {{OAR029: 'details' property is missing}} {{OAR029: 'httpStatus' property is missing}} {{OAR029: 'message' property is missing}} - "type": "object", - "properties": {}, - "required": [ - "code", - "message", - "httpStatus" - ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-error-without-properties-r.yaml b/src/test/resources/checks/v2/schemas/OAR029/with-error-without-properties-r.yaml deleted file mode 100644 index 438694b3..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-error-without-properties-r.yaml +++ /dev/null @@ -1,42 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/successResponse' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/errorResponse' - default: - description: Unknown - -definitions: - successResponse: - type: object - properties: - payload: - type: object - properties: - tipos: - type: array - items: - type: string - errorResponse: - type: object - properties: - error: # Noncompliant {{OAR029: 'code' property is missing}} {{OAR029: 'details' property is missing}} {{OAR029: 'httpStatus' property is missing}} {{OAR029: 'message' property is missing}} - type: object - properties: {} - required: - - code - - message - - httpStatus \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-error-wrong-type-r.json b/src/test/resources/checks/v2/schemas/OAR029/with-error-wrong-type-r.json deleted file mode 100644 index 51c83d4c..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-error-wrong-type-r.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore" - }, - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "schema": { - "$ref": "#/definitions/successResponse" - } - }, - "204": { - "description": "No content" - }, - "400": { - "description": "Error", - "schema": { - "$ref": "#/definitions/errorResponse" - } - }, - "default": { - "description": "Unknown" - } - } - } - } - }, - "definitions": { - "successResponse": { - "type": "object", - "properties": { - "payload": { - "type": "object", - "properties": { - "tipos": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "errorResponse": { - "type": "object", - "properties": { - "error": { - "type": "integer", # Noncompliant {{OAR029: 'error' must be of type object}} - "properties": { - "code": { - "type": "string" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "type": "string" - } - }, - "httpStatus": { - "type": "integer" - } - }, - "required": [ - "code", - "message", - "httpStatus" - ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-error-wrong-type-r.yaml b/src/test/resources/checks/v2/schemas/OAR029/with-error-wrong-type-r.yaml deleted file mode 100644 index c4b2b65f..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-error-wrong-type-r.yaml +++ /dev/null @@ -1,52 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/successResponse' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/errorResponse' - default: - description: Unknown - -definitions: - successResponse: - type: object - properties: - payload: - type: object - properties: - tipos: - type: array - items: - type: string - errorResponse: - type: object - properties: - error: - type: integer # Noncompliant {{OAR029: 'error' must be of type object}} - properties: - code: - type: string - message: - type: string - details: - type: array - items: - type: string - httpStatus: - type: integer - required: - - code - - message - - httpStatus \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-result-with-properties-wrong-type-md.json b/src/test/resources/checks/v2/schemas/OAR029/with-result-with-properties-wrong-type-md.json deleted file mode 100644 index 234597b7..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-result-with-properties-wrong-type-md.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "response" : { - "type" : "object", - "allOf" : [ { - "$ref" : "#/definitions/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "result" : { - "type" : "object", - "properties" : { - "status" : { - "type" : "string" # Noncompliant {{OAR029: 'status' must be of type boolean}} - }, - "http_code" : { - "type" : "string" # Noncompliant {{OAR029: 'http_code' must be of type integer}} - }, - "errors" : { - "type" : "string" # Noncompliant {{OAR029: 'errors' must be of type array}} - }, - "trace_id" : { - "type" : "integer" # Noncompliant {{OAR029: 'trace_id' must be of type string}} - } - }, - "required" : [ "status", "http_code", "trace_id" ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-result-with-properties-wrong-type-md.yaml b/src/test/resources/checks/v2/schemas/OAR029/with-result-with-properties-wrong-type-md.yaml deleted file mode 100644 index 42de213c..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-result-with-properties-wrong-type-md.yaml +++ /dev/null @@ -1,52 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/response' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/response' - default: - description: Unknown - -definitions: - response: - type: object - allOf: - - $ref: '#/definitions/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - result: - type: object - properties: - status: - type: string # Noncompliant {{OAR029: 'status' must be of type boolean}} - http_code: - type: string # Noncompliant {{OAR029: 'http_code' must be of type integer}} - errors: - type: string # Noncompliant {{OAR029: 'errors' must be of type array}} - trace_id: - type: integer # Noncompliant {{OAR029: 'trace_id' must be of type string}} - required: - - status - - http_code - - trace_id diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-result-without-properties-md.json b/src/test/resources/checks/v2/schemas/OAR029/with-result-without-properties-md.json deleted file mode 100644 index 984bb2fb..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-result-without-properties-md.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "response" : { - "type" : "object", - "allOf" : [ { - "$ref" : "#/definitions/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "result" : { # Noncompliant {{OAR029: 'errors' property is missing}} {{OAR029: 'http_code' property is missing}} {{OAR029: 'status' property is missing}} {{OAR029: 'trace_id' property is missing}} - "type" : "object", - "properties" : { }, - "required" : [ "status", "http_code", "trace_id" ] - } - } - } - } - } \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-result-without-properties-md.yaml b/src/test/resources/checks/v2/schemas/OAR029/with-result-without-properties-md.yaml deleted file mode 100644 index 253575d0..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-result-without-properties-md.yaml +++ /dev/null @@ -1,44 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/response' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/response' - default: - description: Unknown - -definitions: - response: - type: object - allOf: - - $ref: '#/definitions/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - result: # Noncompliant {{OAR029: 'errors' property is missing}} {{OAR029: 'http_code' property is missing}} {{OAR029: 'status' property is missing}} {{OAR029: 'trace_id' property is missing}} - type: object - properties: {} - required: - - status - - http_code - - trace_id diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-result-wrong-type-md.json b/src/test/resources/checks/v2/schemas/OAR029/with-result-wrong-type-md.json deleted file mode 100644 index cca7f99b..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-result-wrong-type-md.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "response" : { - "type" : "object", - "allOf" : [ { - "$ref" : "#/definitions/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "result" : { - "type" : "integer", # Noncompliant {{OAR029: 'result' must be of type object}} - "properties" : { - "status" : { - "type" : "boolean" - }, - "http_code" : { - "type" : "integer" - }, - "errors" : { - "type" : "array", - "items" : { - "type" : "object" - } - }, - "trace_id" : { - "type" : "string" - } - }, - "required" : [ "status", "http_code", "trace_id" ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-result-wrong-type-md.yaml b/src/test/resources/checks/v2/schemas/OAR029/with-result-wrong-type-md.yaml deleted file mode 100644 index d7826fcf..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-result-wrong-type-md.yaml +++ /dev/null @@ -1,54 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/response' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/response' - default: - description: Unknown - -definitions: - response: - type: object - allOf: - - $ref: '#/definitions/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - result: - type: integer # Noncompliant {{OAR029: 'result' must be of type object}} - properties: - status: - type: boolean - http_code: - type: integer - errors: - type: array - items: - type: object - trace_id: - type: string - required: - - status - - http_code - - trace_id \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-status-with-properties-wrong-type.json b/src/test/resources/checks/v2/schemas/OAR029/with-status-with-properties-wrong-type.json deleted file mode 100644 index 12fb4887..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-status-with-properties-wrong-type.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "response" : { - "type" : "object", - "allOf" : [ { - "$ref" : "#/definitions/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "status" : { - "type" : "object", - "properties" : { - "http_status" : { - "type" : "boolean" # Noncompliant {{OAR029: 'http_status' must be of type string}} - }, - "code" : { - "type" : "string" # Noncompliant {{OAR029: 'code' must be of type integer}} - }, - "errors" : { - "type" : "string" # Noncompliant {{OAR029: 'errors' must be of type array}} - }, - "description" : { - "type" : "integer" # Noncompliant {{OAR029: 'description' must be of type string}} - }, - "internal_code" : { - "type" : "integer" # Noncompliant {{OAR029: 'internal_code' must be of type string}} - } - }, - "required" : [ "http_status", "code", "description", "errors" ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-status-with-properties-wrong-type.yaml b/src/test/resources/checks/v2/schemas/OAR029/with-status-with-properties-wrong-type.yaml deleted file mode 100644 index 50dff4fb..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-status-with-properties-wrong-type.yaml +++ /dev/null @@ -1,55 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/response' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/response' - default: - description: Unknown - -definitions: - response: - type: object - allOf: - - $ref: '#/definitions/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - status: - type: object - properties: - http_status: - type: boolean # Noncompliant {{OAR029: 'http_status' must be of type string}} - code: - type: string # Noncompliant {{OAR029: 'code' must be of type integer}} - errors: - type: string # Noncompliant {{OAR029: 'errors' must be of type array}} - description: - type: integer # Noncompliant {{OAR029: 'description' must be of type string}} - internal_code: - type: integer # Noncompliant {{OAR029: 'internal_code' must be of type string}} - required: - - http_status - - code - - description - - errors diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-status-without-properties.json b/src/test/resources/checks/v2/schemas/OAR029/with-status-without-properties.json deleted file mode 100644 index e6e45b28..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-status-without-properties.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "response" : { - "type" : "object", - "allOf" : [ { - "$ref" : "#/definitions/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "status" : { # Noncompliant {{OAR029: 'code' property is missing}} {{OAR029: 'description' property is missing}} {{OAR029: 'errors' property is missing}} {{OAR029: 'http_status' property is missing}} {{OAR029: 'internal_code' property is missing}} - "type" : "object", - "properties" : { }, - "required" : [ "http_status", "code", "description", "errors" ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-status-without-properties.yaml b/src/test/resources/checks/v2/schemas/OAR029/with-status-without-properties.yaml deleted file mode 100644 index af1d3ca1..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-status-without-properties.yaml +++ /dev/null @@ -1,45 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/response' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/response' - default: - description: Unknown - -definitions: - response: - type: object - allOf: - - $ref: '#/definitions/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - status: # Noncompliant {{OAR029: 'code' property is missing}} {{OAR029: 'description' property is missing}} {{OAR029: 'errors' property is missing}} {{OAR029: 'http_status' property is missing}} {{OAR029: 'internal_code' property is missing}} - type: object - properties: {} - required: - - http_status - - code - - description - - errors diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-status-wrong-type.json b/src/test/resources/checks/v2/schemas/OAR029/with-status-wrong-type.json deleted file mode 100644 index 736262d9..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-status-wrong-type.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "response" : { - "type" : "object", - "allOf" : [ { - "$ref" : "#/definitions/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "status" : { - "type" : "integer", # Noncompliant {{OAR029: 'status' must be of type object}} - "properties" : { - "http_status" : { - "type" : "string" - }, - "code" : { - "type" : "integer" - }, - "errors" : { - "type" : "array", - "items" : { - "type" : "object" - } - }, - "description" : { - "type" : "string" - }, - "internal_code": { - "type": "string" - } - }, - "required" : [ "http_status", "code", "description", "errors" ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/with-status-wrong-type.yaml b/src/test/resources/checks/v2/schemas/OAR029/with-status-wrong-type.yaml deleted file mode 100644 index f4e0aa4d..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/with-status-wrong-type.yaml +++ /dev/null @@ -1,57 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/response' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/response' - default: - description: Unknown - -definitions: - response: - type: object - allOf: - - $ref: '#/definitions/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - status: - type: integer # Noncompliant {{OAR029: 'status' must be of type object}} - properties: - http_status: - type: string - code: - type: integer - errors: - type: array - items: - type: object - description: - type: string - internal_code: - type: string - required: - - http_status - - code - - description - - errors \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-data-md.json b/src/test/resources/checks/v2/schemas/OAR029/without-data-md.json deleted file mode 100644 index 38967f27..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-data-md.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "response" : { # Noncompliant {{OAR029: 'data' property is missing}} - "type" : "object", - "allOf" : [ { - "$ref" : "#/definitions/standard_response" - } ], - "properties" : { - "info" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "result" : { - "type" : "object", - "properties" : { - "status" : { - "type" : "boolean" - }, - "http_code" : { - "type" : "integer" - }, - "errors" : { - "type" : "array", - "items" : { - "type" : "object", - "properties": { - "code": { - "type": "integer" - }, - "message": { - "type": "string" - } - }, - "required": ["code", "message"] - } - }, - "trace_id" : { - "type" : "string" - } - }, - "required" : [ "status", "http_code", "trace_id" ] - } - } - } - } - } \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-data-md.yaml b/src/test/resources/checks/v2/schemas/OAR029/without-data-md.yaml deleted file mode 100644 index 5134b19a..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-data-md.yaml +++ /dev/null @@ -1,62 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/response' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/response' - default: - description: Unknown - -definitions: - response: # Noncompliant {{OAR029: 'data' property is missing}} - type: object - allOf: - - $ref: '#/definitions/standard_response' - properties: - info: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - result: - type: object - properties: - status: - type: boolean - http_code: - type: integer - errors: - type: array - items: - type: object - properties: - code: - type: integer - message: - type: string - required: - - code - - message - trace_id: - type: string - required: - - status - - http_code - - trace_id diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-data.json b/src/test/resources/checks/v2/schemas/OAR029/without-data.json deleted file mode 100644 index a112b4dd..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-data.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "response" : { # Noncompliant {{OAR029: 'data' property is missing}} - "type" : "object", - "allOf" : [ { - "$ref" : "#/definitions/standard_response" - } ], - "properties" : { - "value" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "status" : { - "type" : "object", - "properties" : { - "http_status" : { - "type" : "string" - }, - "code" : { - "type" : "integer" - }, - "errors" : { - "type" : "array", - "items" : { - "type" : "object", - "properties": { - "name": { - "type": "string" - }, - "value": { - "type": "string" - } - } - } - }, - "description" : { - "type" : "string" - }, - "internal_code": { - "type": "string" - } - }, - "required" : [ "http_status", "code", "description", "errors" ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-data.yaml b/src/test/resources/checks/v2/schemas/OAR029/without-data.yaml deleted file mode 100644 index 892c8215..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-data.yaml +++ /dev/null @@ -1,62 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/response' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/response' - default: - description: Unknown - -definitions: - response: # Noncompliant {{OAR029: 'data' property is missing}} - type: object - allOf: - - $ref: '#/definitions/standard_response' - properties: - value: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - status: - type: object - properties: - http_status: - type: string - code: - type: integer - errors: - type: array - items: - type: object - properties: - name: - type: string - value: - type: string - description: - type: string - internal_code: - type: string - required: - - http_status - - code - - description - - errors diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-error-r.json b/src/test/resources/checks/v2/schemas/OAR029/without-error-r.json deleted file mode 100644 index 26fc446f..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-error-r.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/successResponse" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/errorResponse" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "successResponse": { - "type": "object", - "properties": { - "payload": { - "type": "object", - "properties": { - "tipos": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "errorResponse": { # Noncompliant {{OAR029: 'error' property is missing}} - "type": "object", - "properties": { - "result": { - "type": "object", - "properties": { - "code": { - "type": "string" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "type": "string" - } - }, - "httpStatus": { - "type": "integer" - } - }, - "required": [ - "code", - "message", - "httpStatus" - ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-error-r.yaml b/src/test/resources/checks/v2/schemas/OAR029/without-error-r.yaml deleted file mode 100644 index 7b3e66a5..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-error-r.yaml +++ /dev/null @@ -1,52 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/successResponse' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/errorResponse' - default: - description: Unknown - -definitions: - successResponse: - type: object - properties: - payload: - type: object - properties: - tipos: - type: array - items: - type: string - errorResponse: # Noncompliant {{OAR029: 'error' property is missing}} - type: object - properties: - result: - type: object - properties: - code: - type: string - message: - type: string - details: - type: array - items: - type: string - httpStatus: - type: integer - required: - - code - - message - - httpStatus diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-payload-r.json b/src/test/resources/checks/v2/schemas/OAR029/without-payload-r.json deleted file mode 100644 index 8a8dbfe3..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-payload-r.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/successResponse" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/errorResponse" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions": { - "successResponse": { # Noncompliant {{OAR029: 'payload' property is missing}} - "type": "object", - "properties": { - "data": { - "type": "object", - "properties": { - "tipos": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "errorResponse": { - "type": "object", - "properties": { - "error": { - "type": "object", - "properties": { - "code": { - "type": "string" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "type": "string" - } - }, - "httpStatus": { - "type": "integer" - } - }, - "required": [ - "code", - "message", - "httpStatus" - ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-payload-r.yaml b/src/test/resources/checks/v2/schemas/OAR029/without-payload-r.yaml deleted file mode 100644 index 761f5ecb..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-payload-r.yaml +++ /dev/null @@ -1,52 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/successResponse' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/errorResponse' - default: - description: Unknown - -definitions: - successResponse: # Noncompliant {{OAR029: 'payload' property is missing}} - type: object - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - errorResponse: - type: object - properties: - error: - type: object - properties: - code: - type: string - message: - type: string - details: - type: array - items: - type: string - httpStatus: - type: integer - required: - - code - - message - - httpStatus diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-required-fields-md.json b/src/test/resources/checks/v2/schemas/OAR029/without-required-fields-md.json deleted file mode 100644 index 8b44b9b8..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-required-fields-md.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "response" : { - "type" : "object", - "allOf" : [ { - "$ref" : "#/definitions/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "result" : { - "type" : "object", - "properties" : { - "status" : { - "type" : "boolean" - }, - "http_code" : { - "type" : "integer" - }, - "errors" : { - "type" : "array", - "items" : { - "type" : "object", - "properties": { - "code": { - "type": "integer" - }, - "message": { - "type": "string" - } - }, - "required": ["code", "message"] - } - }, - "trace_id" : { - "type" : "string" - } - }, - "required" : [ "status" ] # Noncompliant {{OAR029: The following fields must be required: http_code, status, trace_id}} - } - } - } - } - } \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-required-fields-md.yaml b/src/test/resources/checks/v2/schemas/OAR029/without-required-fields-md.yaml deleted file mode 100644 index af782906..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-required-fields-md.yaml +++ /dev/null @@ -1,60 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/response' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/response' - default: - description: Unknown - -definitions: - response: - type: object - allOf: - - $ref: '#/definitions/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - result: - type: object - properties: - status: - type: boolean - http_code: - type: integer - errors: - type: array - items: - type: object - properties: - code: - type: integer - message: - type: string - required: - - code - - message - trace_id: - type: string - required: # Noncompliant {{OAR029: The following fields must be required: http_code, status, trace_id}} - - status diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-required-fields-r.json b/src/test/resources/checks/v2/schemas/OAR029/without-required-fields-r.json deleted file mode 100644 index d3f9332d..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-required-fields-r.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore" - }, - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "schema": { - "$ref": "#/definitions/successResponse" - } - }, - "204": { - "description": "No content" - }, - "400": { - "description": "Error", - "schema": { - "$ref": "#/definitions/errorResponse" - } - }, - "default": { - "description": "Unknown" - } - } - } - } - }, - "definitions": { - "successResponse": { - "type": "object", - "properties": { - "payload": { - "type": "object", - "properties": { - "tipos": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "errorResponse": { - "type": "object", - "properties": { - "error": { - "type": "object", - "properties": { - "code": { - "type": "string" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "type": "string" - } - }, - "httpStatus": { - "type": "integer" - } - }, - "required": [ # Noncompliant {{OAR029: The following fields must be required: code, httpStatus, message}} - "httpStatus" - ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-required-fields-r.yaml b/src/test/resources/checks/v2/schemas/OAR029/without-required-fields-r.yaml deleted file mode 100644 index a3b6153d..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-required-fields-r.yaml +++ /dev/null @@ -1,50 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/successResponse' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/errorResponse' - default: - description: Unknown - -definitions: - successResponse: - type: object - properties: - payload: - type: object - properties: - tipos: - type: array - items: - type: string - errorResponse: - type: object - properties: - error: - type: object - properties: - code: - type: string - message: - type: string - details: - type: array - items: - type: string - httpStatus: - type: integer - required: # Noncompliant {{OAR029: The following fields must be required: code, httpStatus, message}} - - httpStatus diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-required-fields.json b/src/test/resources/checks/v2/schemas/OAR029/without-required-fields.json deleted file mode 100644 index 203828a0..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-required-fields.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "response" : { - "type" : "object", - "allOf" : [ { - "$ref" : "#/definitions/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "status" : { - "type" : "object", - "properties" : { - "http_status" : { - "type" : "string" - }, - "code" : { - "type" : "integer" - }, - "errors" : { - "type" : "array", - "items" : { - "type" : "object", - "properties": { - "name": { - "type": "string" - }, - "value": { - "type": "string" - } - } - } - }, - "description" : { - "type" : "string" - }, - "internal_code" : { - "type" : "string" - } - }, - "required" : [ "http_status" ] # Noncompliant {{OAR029: The following fields must be required: code, description, errors, http_status}} - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-required-fields.yaml b/src/test/resources/checks/v2/schemas/OAR029/without-required-fields.yaml deleted file mode 100644 index 3937b320..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-required-fields.yaml +++ /dev/null @@ -1,59 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/response' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/response' - default: - description: Unknown - -definitions: - response: - type: object - allOf: - - $ref: '#/definitions/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - status: - type: object - properties: - http_status: - type: string - code: - type: integer - errors: - type: array - items: - type: object - properties: - name: - type: string - value: - type: string - description: - type: string - internal_code: - type: string - required: # Noncompliant {{OAR029: The following fields must be required: code, description, errors, http_status}} - - http_status diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-result-md.json b/src/test/resources/checks/v2/schemas/OAR029/without-result-md.json deleted file mode 100644 index a9b68386..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-result-md.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "response" : { # Noncompliant {{OAR029: 'result' property is missing}} - "type" : "object", - "allOf" : [ { - "$ref" : "#/definitions/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "response" : { - "type" : "object", - "properties" : { - "status" : { - "type" : "boolean" - }, - "http_code" : { - "type" : "integer" - }, - "errors" : { - "type" : "array", - "items" : { - "type" : "object" - } - }, - "trace_id" : { - "type" : "string" - } - }, - "required" : [ "status", "http_code", "trace_id" ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-result-md.yaml b/src/test/resources/checks/v2/schemas/OAR029/without-result-md.yaml deleted file mode 100644 index 5acc48cd..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-result-md.yaml +++ /dev/null @@ -1,54 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/response' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/response' - default: - description: Unknown - -definitions: - response: # Noncompliant {{OAR029: 'result' property is missing}} - type: object - allOf: - - $ref: '#/definitions/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - response: - type: object - properties: - status: - type: boolean - http_code: - type: integer - errors: - type: array - items: - type: object - trace_id: - type: string - required: - - status - - http_code - - trace_id diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-status.json b/src/test/resources/checks/v2/schemas/OAR029/without-status.json deleted file mode 100644 index eb4ca668..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-status.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "schema" : { - "$ref" : "#/definitions/response" - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "definitions" : { - "response" : { # Noncompliant {{OAR029: 'status' property is missing}} - "type" : "object", - "allOf" : [ { - "$ref" : "#/definitions/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "response" : { - "type" : "object", - "properties" : { - "http_status" : { - "type" : "string" - }, - "code" : { - "type" : "integer" - }, - "errors" : { - "type" : "array", - "items" : { - "type" : "object" - } - }, - "description" : { - "type" : "string" - }, - "internal_code": { - "type": "string" - } - }, - "required" : [ "http_status", "code", "description", "errors" ] - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v2/schemas/OAR029/without-status.yaml b/src/test/resources/checks/v2/schemas/OAR029/without-status.yaml deleted file mode 100644 index a7b2fb72..00000000 --- a/src/test/resources/checks/v2/schemas/OAR029/without-status.yaml +++ /dev/null @@ -1,57 +0,0 @@ -swagger: "2.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - schema: - $ref: '#/definitions/response' - 204: - description: No content - 400: - description: Error - schema: - $ref: '#/definitions/response' - default: - description: Unknown - -definitions: - response: # Noncompliant {{OAR029: 'status' property is missing}} - type: object - allOf: - - $ref: '#/definitions/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - response: - type: object - properties: - http_status: - type: string - code: - type: integer - errors: - type: array - items: - type: object - description: - type: string - internal_code: - type: string - required: - - http_status - - code - - description - - errors diff --git a/src/test/resources/checks/v2/schemas/OAR034/with-paging-allof-wrong-type.yaml b/src/test/resources/checks/v2/schemas/OAR034/with-paging-allof-wrong-type.yaml new file mode 100644 index 00000000..b6ab2322 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR034/with-paging-allof-wrong-type.yaml @@ -0,0 +1,21 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Swagger Petstore +paths: + /endpoint: + get: + responses: + 206: + description: Ok + schema: + $ref: '#/definitions/response' + +definitions: + response: + type: object + properties: + paging: + type: integer # Noncompliant {{OAR034: 'paging' must be of type object}} + allOf: + - type: integer diff --git a/src/test/resources/checks/v2/schemas/OAR034/with-paging-no-type.yaml b/src/test/resources/checks/v2/schemas/OAR034/with-paging-no-type.yaml new file mode 100644 index 00000000..0b952655 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR034/with-paging-no-type.yaml @@ -0,0 +1,19 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Swagger Petstore +paths: + /endpoint: + get: + responses: + 206: + description: Ok + schema: + $ref: '#/definitions/response' + +definitions: + response: + type: object + properties: + paging: + description: has no type field diff --git a/src/test/resources/checks/v2/schemas/OAR034/without-paging-required-key.yaml b/src/test/resources/checks/v2/schemas/OAR034/without-paging-required-key.yaml new file mode 100644 index 00000000..30d8f1d4 --- /dev/null +++ b/src/test/resources/checks/v2/schemas/OAR034/without-paging-required-key.yaml @@ -0,0 +1,50 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Swagger Petstore +paths: + /endpoint: + get: + responses: + 206: + description: Ok + schema: + $ref: '#/definitions/response' + +definitions: + response: + type: object + properties: + paging: + type: object + properties: + start: + type: integer + limit: + type: integer + total: + type: integer + numPages: + type: integer + links: + type: object + properties: + self: + type: object + properties: + href: + type: string + previous: + type: object + properties: + href: + type: string + next: + type: object + properties: + href: + type: string + required: + - self + - previous + - next diff --git a/src/test/resources/checks/v2/security/OAR079/no-parameters.json b/src/test/resources/checks/v2/security/OAR079/no-parameters.json new file mode 100644 index 00000000..c3ae663c --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR079/no-parameters.json @@ -0,0 +1,19 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore" + }, + "paths": { + "/items": { + "get": { + "summary": "Get a list of items", + "responses": { + "200": { + "description": "A list of items" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v2/security/OAR079/no-parameters.yaml b/src/test/resources/checks/v2/security/OAR079/no-parameters.yaml new file mode 100644 index 00000000..7c5bde3f --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR079/no-parameters.yaml @@ -0,0 +1,11 @@ +swagger: "2.0" +info: + version: "1.0.0" + title: "Swagger Petstore" +paths: + /items: + get: + summary: Get a list of items + responses: + '200': + description: "A list of items" diff --git a/src/test/resources/checks/v2/security/OAR079/query-param-only.json b/src/test/resources/checks/v2/security/OAR079/query-param-only.json new file mode 100644 index 00000000..1766aa34 --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR079/query-param-only.json @@ -0,0 +1,26 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore" + }, + "paths": { + "/items": { + "get": { + "summary": "Get a list of items", + "parameters": [ + { + "name": "param1", + "in": "query", + "type": "string" + } + ], + "responses": { + "200": { + "description": "A list of items" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v2/security/OAR079/query-param-only.yaml b/src/test/resources/checks/v2/security/OAR079/query-param-only.yaml new file mode 100644 index 00000000..ae796fe1 --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR079/query-param-only.yaml @@ -0,0 +1,15 @@ +swagger: "2.0" +info: + version: "1.0.0" + title: "Swagger Petstore" +paths: + /items: + get: + summary: Get a list of items + parameters: + - name: "param1" + in: "query" + type: "string" + responses: + '200': + description: "A list of items" diff --git a/src/test/resources/checks/v2/security/OAR083/no-parameters.json b/src/test/resources/checks/v2/security/OAR083/no-parameters.json new file mode 100644 index 00000000..da3849b1 --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR083/no-parameters.json @@ -0,0 +1,19 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "My API" + }, + "paths": { + "/examples": { + "get": { + "summary": "Get a list of items", + "responses": { + "200": { + "description": "A list of items" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v2/security/OAR083/no-parameters.yaml b/src/test/resources/checks/v2/security/OAR083/no-parameters.yaml new file mode 100644 index 00000000..549f7fa3 --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR083/no-parameters.yaml @@ -0,0 +1,11 @@ +swagger: '2.0' +info: + version: 1.0.0 + title: My API +paths: + /examples: + get: + summary: Get a list of items + responses: + 200: + description: A list of items diff --git a/src/test/resources/checks/v2/security/OAR083/null-name-param.json b/src/test/resources/checks/v2/security/OAR083/null-name-param.json new file mode 100644 index 00000000..d5437454 --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR083/null-name-param.json @@ -0,0 +1,32 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "My API" + }, + "paths": { + "/examples/{id}": { + "get": { + "summary": "Get an item", + "parameters": [ + { + "name": null, + "in": "query", + "type": "string" + }, + { + "name": "id", + "in": "path", + "type": "string", + "required": true + } + ], + "responses": { + "200": { + "description": "An item" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v2/security/OAR083/null-name-param.yaml b/src/test/resources/checks/v2/security/OAR083/null-name-param.yaml new file mode 100644 index 00000000..854d18a5 --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR083/null-name-param.yaml @@ -0,0 +1,19 @@ +swagger: '2.0' +info: + version: 1.0.0 + title: My API +paths: + /examples/{id}: + get: + summary: Get an item + parameters: + - name: ~ + in: query + type: string + - name: id + in: path + type: string + required: true + responses: + 200: + description: An item diff --git a/src/test/resources/checks/v2/security/OAR083/options-operation.json b/src/test/resources/checks/v2/security/OAR083/options-operation.json new file mode 100644 index 00000000..e5b69593 --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR083/options-operation.json @@ -0,0 +1,26 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "My API" + }, + "paths": { + "/examples": { + "options": { + "summary": "Options for the resource", + "parameters": [ + { + "name": "email", + "in": "query", + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v2/security/OAR083/options-operation.yaml b/src/test/resources/checks/v2/security/OAR083/options-operation.yaml new file mode 100644 index 00000000..a623e40f --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR083/options-operation.yaml @@ -0,0 +1,15 @@ +swagger: '2.0' +info: + version: 1.0.0 + title: My API +paths: + /examples: + options: + summary: Options for the resource + parameters: + - name: email + in: query + type: string + responses: + 200: + description: OK diff --git a/src/test/resources/checks/v2/security/OAR084/no-parameters.json b/src/test/resources/checks/v2/security/OAR084/no-parameters.json new file mode 100644 index 00000000..da3849b1 --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR084/no-parameters.json @@ -0,0 +1,19 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "My API" + }, + "paths": { + "/examples": { + "get": { + "summary": "Get a list of items", + "responses": { + "200": { + "description": "A list of items" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v2/security/OAR084/no-parameters.yaml b/src/test/resources/checks/v2/security/OAR084/no-parameters.yaml new file mode 100644 index 00000000..549f7fa3 --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR084/no-parameters.yaml @@ -0,0 +1,11 @@ +swagger: '2.0' +info: + version: 1.0.0 + title: My API +paths: + /examples: + get: + summary: Get a list of items + responses: + 200: + description: A list of items diff --git a/src/test/resources/checks/v2/security/OAR084/non-query-param.json b/src/test/resources/checks/v2/security/OAR084/non-query-param.json new file mode 100644 index 00000000..95d3b39b --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR084/non-query-param.json @@ -0,0 +1,28 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "My API" + }, + "paths": { + "/examples/{id}": { + "get": { + "summary": "Get an item", + "parameters": [ + { + "name": "id", + "in": "path", + "type": "string", + "format": "password", + "required": true + } + ], + "responses": { + "200": { + "description": "An item" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v2/security/OAR084/non-query-param.yaml b/src/test/resources/checks/v2/security/OAR084/non-query-param.yaml new file mode 100644 index 00000000..66397ebb --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR084/non-query-param.yaml @@ -0,0 +1,17 @@ +swagger: '2.0' +info: + version: 1.0.0 + title: My API +paths: + /examples/{id}: + get: + summary: Get an item + parameters: + - name: id + in: path + type: string + format: password + required: true + responses: + 200: + description: An item diff --git a/src/test/resources/checks/v2/security/OAR084/null-format-param.json b/src/test/resources/checks/v2/security/OAR084/null-format-param.json new file mode 100644 index 00000000..c38523df --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR084/null-format-param.json @@ -0,0 +1,27 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "My API" + }, + "paths": { + "/examples": { + "get": { + "summary": "Get a list of items", + "parameters": [ + { + "name": "exampleParam1", + "in": "query", + "type": "string", + "format": null + } + ], + "responses": { + "200": { + "description": "A list of items" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v2/security/OAR084/null-format-param.yaml b/src/test/resources/checks/v2/security/OAR084/null-format-param.yaml new file mode 100644 index 00000000..3b0cdf74 --- /dev/null +++ b/src/test/resources/checks/v2/security/OAR084/null-format-param.yaml @@ -0,0 +1,16 @@ +swagger: '2.0' +info: + version: 1.0.0 + title: My API +paths: + /examples: + get: + summary: Get a list of items + parameters: + - name: exampleParam1 + in: query + type: string + format: ~ + responses: + 200: + description: A list of items diff --git a/src/test/resources/checks/v3/format/OAR101/empty-path.json b/src/test/resources/checks/v3/format/OAR101/empty-path.json new file mode 100644 index 00000000..6341fc10 --- /dev/null +++ b/src/test/resources/checks/v3/format/OAR101/empty-path.json @@ -0,0 +1,13 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/" + } + ], + "paths": {} +} \ No newline at end of file diff --git a/src/test/resources/checks/v3/format/OAR101/empty-path.yaml b/src/test/resources/checks/v3/format/OAR101/empty-path.yaml new file mode 100644 index 00000000..8925b6e8 --- /dev/null +++ b/src/test/resources/checks/v3/format/OAR101/empty-path.yaml @@ -0,0 +1,7 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore +servers: + - url: https://petstore.swagger.io/ +paths: {} \ No newline at end of file diff --git a/src/test/resources/checks/v3/format/OAR101/invalid.json b/src/test/resources/checks/v3/format/OAR101/invalid.json new file mode 100644 index 00000000..0ab8f8ab --- /dev/null +++ b/src/test/resources/checks/v3/format/OAR101/invalid.json @@ -0,0 +1,13 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/wrong/v1" # Noncompliant {{OAR101: The first part of the path is not allowed. Allowed values are: wrong}} + } + ], + "paths": {} +} \ No newline at end of file diff --git a/src/test/resources/checks/v3/format/OAR101/invalid.yaml b/src/test/resources/checks/v3/format/OAR101/invalid.yaml new file mode 100644 index 00000000..d06571ea --- /dev/null +++ b/src/test/resources/checks/v3/format/OAR101/invalid.yaml @@ -0,0 +1,7 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore +servers: + - url: https://petstore.swagger.io/wrong/v1 # Noncompliant {{OAR101: The first part of the path is not allowed. Allowed values are: wrong}} +paths: {} \ No newline at end of file diff --git a/src/test/resources/checks/v3/format/OAR101/valid-with-values.json b/src/test/resources/checks/v3/format/OAR101/valid-with-values.json new file mode 100644 index 00000000..3ea07fc5 --- /dev/null +++ b/src/test/resources/checks/v3/format/OAR101/valid-with-values.json @@ -0,0 +1,13 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api-seguros/v1" + } + ], + "paths": {} +} \ No newline at end of file diff --git a/src/test/resources/checks/v3/format/OAR101/valid-with-values.yaml b/src/test/resources/checks/v3/format/OAR101/valid-with-values.yaml new file mode 100644 index 00000000..89bfccfb --- /dev/null +++ b/src/test/resources/checks/v3/format/OAR101/valid-with-values.yaml @@ -0,0 +1,7 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore +servers: + - url: https://petstore.swagger.io/api-seguros/v1 +paths: {} \ No newline at end of file diff --git a/src/test/resources/checks/v3/format/OAR102/invalid.json b/src/test/resources/checks/v3/format/OAR102/invalid.json new file mode 100644 index 00000000..ee51dd65 --- /dev/null +++ b/src/test/resources/checks/v3/format/OAR102/invalid.json @@ -0,0 +1,13 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api-seguros/wrong" # Noncompliant {{OAR102: The second part of the path is not allowed. Allowed values are: wrong}} + } + ], + "paths": {} +} \ No newline at end of file diff --git a/src/test/resources/checks/v3/format/OAR102/invalid.yaml b/src/test/resources/checks/v3/format/OAR102/invalid.yaml new file mode 100644 index 00000000..ca2c1240 --- /dev/null +++ b/src/test/resources/checks/v3/format/OAR102/invalid.yaml @@ -0,0 +1,7 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore +servers: + - url: https://petstore.swagger.io/api-seguros/wrong # Noncompliant {{OAR102: The second part of the path is not allowed. Allowed values are: wrong}} +paths: {} \ No newline at end of file diff --git a/src/test/resources/checks/v3/format/OAR102/one-part-path.json b/src/test/resources/checks/v3/format/OAR102/one-part-path.json new file mode 100644 index 00000000..3679b681 --- /dev/null +++ b/src/test/resources/checks/v3/format/OAR102/one-part-path.json @@ -0,0 +1,13 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api-seguros" + } + ], + "paths": {} +} \ No newline at end of file diff --git a/src/test/resources/checks/v3/format/OAR102/one-part-path.yaml b/src/test/resources/checks/v3/format/OAR102/one-part-path.yaml new file mode 100644 index 00000000..84c7df71 --- /dev/null +++ b/src/test/resources/checks/v3/format/OAR102/one-part-path.yaml @@ -0,0 +1,7 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore +servers: + - url: https://petstore.swagger.io/api-seguros +paths: {} \ No newline at end of file diff --git a/src/test/resources/checks/v3/format/OAR102/valid-with-values.json b/src/test/resources/checks/v3/format/OAR102/valid-with-values.json new file mode 100644 index 00000000..3ea07fc5 --- /dev/null +++ b/src/test/resources/checks/v3/format/OAR102/valid-with-values.json @@ -0,0 +1,13 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api-seguros/v1" + } + ], + "paths": {} +} \ No newline at end of file diff --git a/src/test/resources/checks/v3/format/OAR102/valid-with-values.yaml b/src/test/resources/checks/v3/format/OAR102/valid-with-values.yaml new file mode 100644 index 00000000..89bfccfb --- /dev/null +++ b/src/test/resources/checks/v3/format/OAR102/valid-with-values.yaml @@ -0,0 +1,7 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore +servers: + - url: https://petstore.swagger.io/api-seguros/v1 +paths: {} \ No newline at end of file diff --git a/src/test/resources/checks/v3/owasp/OAR073/no-responses.json b/src/test/resources/checks/v3/owasp/OAR073/no-responses.json new file mode 100644 index 00000000..e0294c8b --- /dev/null +++ b/src/test/resources/checks/v3/owasp/OAR073/no-responses.json @@ -0,0 +1,14 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Compliant API" + }, + "paths": { + "/items": { + "get": { + "summary": "Get a list of items with no responses key" + } + } + } +} diff --git a/src/test/resources/checks/v3/owasp/OAR073/no-responses.yaml b/src/test/resources/checks/v3/owasp/OAR073/no-responses.yaml new file mode 100644 index 00000000..2575f439 --- /dev/null +++ b/src/test/resources/checks/v3/owasp/OAR073/no-responses.yaml @@ -0,0 +1,8 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Compliant API +paths: + /items: + get: + summary: Get a list of items with no responses key diff --git a/src/test/resources/checks/v3/parameters/OAR028/components-param.json b/src/test/resources/checks/v3/parameters/OAR028/components-param.json new file mode 100644 index 00000000..38b3f30a --- /dev/null +++ b/src/test/resources/checks/v3/parameters/OAR028/components-param.json @@ -0,0 +1,29 @@ +{ + "openapi" : "3.0.0", + "info" : { + "version" : "1.0.0", + "title" : "Swagger Petstore" + }, + "components" : { + "parameters" : { + "filterParam" : { + "in" : "query", + "name" : "other", + "schema" : { + "type" : "string" + } + } + } + }, + "paths" : { + "/examples" : { + "get" : { + "responses" : { + "200" : { + "description" : "Ok" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v3/parameters/OAR028/components-param.yaml b/src/test/resources/checks/v3/parameters/OAR028/components-param.yaml new file mode 100644 index 00000000..18bc4ac4 --- /dev/null +++ b/src/test/resources/checks/v3/parameters/OAR028/components-param.yaml @@ -0,0 +1,17 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore +components: + parameters: + filterParam: + in: query + name: other + schema: + type: string +paths: + /examples: + get: + responses: + 200: + description: Ok diff --git a/src/test/resources/checks/v3/parameters/OAR028/exclude-noncompliant.json b/src/test/resources/checks/v3/parameters/OAR028/exclude-noncompliant.json new file mode 100644 index 00000000..ec73f987 --- /dev/null +++ b/src/test/resources/checks/v3/parameters/OAR028/exclude-noncompliant.json @@ -0,0 +1,37 @@ +{ + "openapi" : "3.0.0", + "info" : { + "version" : "1.0.0", + "title" : "Swagger Petstore" + }, + "paths" : { + "/status" : { + "get" : { + "parameters" : [ { + "in" : "query", + "name" : "other", # Noncompliant {{OAR028: $filter must be defined as a parameter in this operation}} + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + }, { + "in" : "query", + "name" : "select", # Noncompliant {{OAR028: $filter must be defined as a parameter in this operation}} + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } ], + "responses" : { + "206" : { + "description" : "Ok" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v3/parameters/OAR028/exclude-noncompliant.yaml b/src/test/resources/checks/v3/parameters/OAR028/exclude-noncompliant.yaml new file mode 100644 index 00000000..bc7139de --- /dev/null +++ b/src/test/resources/checks/v3/parameters/OAR028/exclude-noncompliant.yaml @@ -0,0 +1,23 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore +paths: + /status: + get: + parameters: + - in: query + name: other # Noncompliant {{OAR028: $filter must be defined as a parameter in this operation}} + schema: + type: array + items: + type: string + - in: query + name: select # Noncompliant {{OAR028: $filter must be defined as a parameter in this operation}} + schema: + type: array + items: + type: string + responses: + 206: + description: Ok diff --git a/src/test/resources/checks/v3/schemas/OAR029/externalRef.json b/src/test/resources/checks/v3/schemas/OAR029/externalRef.json deleted file mode 100644 index 95e0af87..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/externalRef.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Sample-API_efc2b9f76813_V", - "description": "API de ejemplo para pruebas", - "contact": { - "name": "Nombre del Contacto.", - "email": "contact@mail.com" - }, - "version": "1.0.12" - }, - "servers": [ - { - "url": "https://api.example.es/api-sample/v1" - } - ], - "paths": { - "/datos-usuarios": { - "get": { - "summary": "Listado de usuarios", - "description": "Método que permite obtener un listado con datos básicos de un usuario.", - "parameters": [ - { - "name": "desde", - "in": "query", - "schema": { - "type": "string", - "format": "date" - }, - "required": false - }, - { - "name": "hasta", - "in": "query", - "schema": { - "type": "string", - "format": "date" - }, - "required": false - } - ], - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Correlation-Id": { - "description": "Cabecera 'X-Correlation-Id'", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { # Noncompliant {{OAR029: 'data' property is missing}} {{OAR029: 'status' must be of type object}} - "$ref": "https://api-gateway.apiquality.io/api_apiquality_dev/v1/models/afcda940-7868-4ed3-8002-b5754b35cb26/error-message.yaml#/errorMessage" - } - } - } - }, - "400": { - "description": "Bad Request.", - "headers": { - "X-Correlation-Id": { - "description": "Cabecera 'X-Correlation-Id'", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { # Noncompliant {{OAR029: 'status' must be of type object}} - "$ref": "https://api-gateway.apiquality.io/api_apiquality_dev/v1/models/afcda940-7868-4ed3-8002-b5754b35cb26/error-message.yaml#/errorMessage" - }, - "example": { - "error": { - "status": "400", - "message": "Bad Request", - "path": "/datos-usuario", - "type": "https://docs.example.es/x/A1D8Aw", - "operationId": "10004", - "errors": [ - { - "code": "101", - "message": "Invalid format", - "location": "desde" - } - ] - } - } - } - } - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/externalRef.yaml b/src/test/resources/checks/v3/schemas/OAR029/externalRef.yaml deleted file mode 100644 index 71939d63..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/externalRef.yaml +++ /dev/null @@ -1,64 +0,0 @@ -openapi: 3.0.1 -info: - title: Sample-API_efc2b9f76813_V - description: API de ejemplo para pruebas - contact: - name: Nombre del Contacto. - email: contact@mail.com - version: 1.0.12 -servers: - - url: https://api.example.es/api-sample/v1 -paths: - /datos-usuarios: - get: - summary: Listado de usuarios - description: Método que permite obtener un listado con datos básicos de un usuario. - parameters: - - name: desde - in: query - schema: - type: string - format: date - required: false - - name: hasta - in: query - schema: - type: string - format: date - required: false - responses: - '200': - description: OK - headers: - X-Correlation-Id: - description: Cabecera 'X-Correlation-Id' - schema: - type: string - content: - application/json: - schema: - $ref: >- # Noncompliant {{OAR029: 'data' property is missing}} {{OAR029: 'status' must be of type object}} - https://api-gateway.apiquality.io/api_apiquality_dev/v1/models/afcda940-7868-4ed3-8002-b5754b35cb26/error-message.yaml#/errorMessage - '400': - description: Bad Request. - headers: - X-Correlation-Id: - description: Cabecera 'X-Correlation-Id' - schema: - type: string - content: - application/json: - schema: - $ref: >- # Noncompliant {{OAR029: 'status' must be of type object}} - https://api-gateway.apiquality.io/api_apiquality_dev/v1/models/afcda940-7868-4ed3-8002-b5754b35cb26/error-message.yaml#/errorMessage - example: - error: - status: '400' - message: Bad Request - path: /datos-usuario - type: https://docs.example.es/x/A1D8Aw - operationId: '10004' - errors: - - code: '101' - message: Invalid format - location: desde \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/externalRefNoLinks.json b/src/test/resources/checks/v3/schemas/OAR029/externalRefNoLinks.json deleted file mode 100644 index a1c48da0..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/externalRefNoLinks.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Sample-API_efc2b9f76813_V", - "description": "API de ejemplo para pruebas", - "contact": { - "name": "Nombre del Contacto.", - "email": "contact@mail.com" - }, - "version": "1.0.12" - }, - "servers": [ - { - "url": "https://api.example.es/api-sample/v1" - } - ], - "paths": { - "/datos-usuarios": { - "get": { - "summary": "Listado de usuarios", - "description": "Método que permite obtener un listado con datos básicos de un usuario.", - "parameters": [ - { - "name": "desde", - "in": "query", - "schema": { - "type": "string", - "format": "date" - }, - "required": false - }, - { - "name": "hasta", - "in": "query", - "schema": { - "type": "string", - "format": "date" - }, - "required": false - } - ], - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Correlation-Id": { - "description": "Cabecera 'X-Correlation-Id'", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { # Noncompliant {{OAR029: 'data' property is missing}} - "type": "object", - "required": [ - "message", - "status" - ], - "properties": { - "status": { - "type": "string", # Noncompliant {{OAR029: 'status' must be of type object}} - "description": "Especifica el status code HTTP al que se traducirá la excepción." - }, - "message": { - "type": "string", - "description": "Mensaje descriptivo del error." - }, - "path": { - "type": "string", - "description": "URL path de la petición que originó el error." - }, - "type": { - "type": "string", - "description": "URL que apunta a una descripción de los códigos de error." - }, - "operationId": { - "type": "string", - "description": "Id de negocio de la operación realizada." - }, - "errors": { - "type": "array", - "description": "Listado de suberrores usado para dar información más detallada, como en el caso de errores de validación." - } - } - } - } - } - } - } - } - } - } - } \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/externalRefNolinks.yaml b/src/test/resources/checks/v3/schemas/OAR029/externalRefNolinks.yaml deleted file mode 100644 index 6250a533..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/externalRefNolinks.yaml +++ /dev/null @@ -1,62 +0,0 @@ -openapi: 3.0.1 -info: - title: Sample-API_efc2b9f76813_V - description: API de ejemplo para pruebas - contact: - name: Nombre del Contacto. - email: contact@mail.com - version: 1.0.12 -servers: - - url: https://api.example.es/api-sample/v1 -paths: - /datos-usuarios: - get: - summary: Listado de usuarios - description: Método que permite obtener un listado con datos básicos de un usuario. - parameters: - - name: desde - in: query - schema: - type: string - format: date - required: false - - name: hasta - in: query - schema: - type: string - format: date - required: false - responses: - '200': - description: OK - headers: - X-Correlation-Id: - description: Cabecera 'X-Correlation-Id' - schema: - type: string - content: - application/json: - schema: # Noncompliant {{OAR029: 'data' property is missing}} - type: object - required: - - message - - status - properties: - status: - type: string # Noncompliant {{OAR029: 'status' must be of type object}} - description: Especifica el status code HTTP al que se traducirá la excepción. - message: - type: string - description: Mensaje descriptivo del error. - path: - type: string - description: URL path de la petición que originó el error. - type: - type: string - description: URL que apunta a una descripción de los códigos de error. - operationId: - type: string - description: Id de negocio de la operación realizada. - errors: - type: array - description: Listado de suberrores usado para dar información más detallada, como en el caso de errores de validación. diff --git a/src/test/resources/checks/v3/schemas/OAR029/internalRef.json b/src/test/resources/checks/v3/schemas/OAR029/internalRef.json deleted file mode 100644 index 708e314b..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/internalRef.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Sample-API_efc2b9f76813_V", - "description": "API de ejemplo para pruebas", - "contact": { - "name": "Nombre del Contacto.", - "email": "contact@mail.com" - }, - "version": "1.0.12" - }, - "servers": [ - { - "url": "https://api.example.es/api-sample/v1" - } - ], - "paths": { - "/datos-usuarios": { - "get": { - "summary": "Listado de usuarios", - "description": "Método que permite obtener un listado con datos básicos de un usuario.", - "parameters": [ - { - "name": "desde", - "in": "query", - "schema": { - "type": "string", - "format": "date" - }, - "required": false - }, - { - "name": "hasta", - "in": "query", - "schema": { - "type": "string", - "format": "date" - }, - "required": false - } - ], - "responses": { - "200": { - "description": "OK", - "headers": { - "X-Correlation-Id": { - "description": "Cabecera 'X-Correlation-Id'", - "schema": { - "type": "string" - } - } - }, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ErrorMessage" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "ErrorMessage": { # Noncompliant {{OAR029: 'data' property is missing}} - "required": [ - "message", - "status" - ], - "type": "object", - "properties": { - "status": { - "type": "string", # Noncompliant {{OAR029: 'status' must be of type object}} - "description": "Especifica el status code HTTP al que se traducirá la excepción." - }, - "message": { - "type": "string", - "description": "Mensaje descriptivo del error." - }, - "path": { - "type": "string", - "description": "URL path de la petición que originó el error." - }, - "type": { - "type": "string", - "description": "URL que apunta a una descripción de los códigos de error." - }, - "operationId": { - "type": "string", - "description": "Id de negocio de la operación realizada." - }, - "errors": { - "type": "array", - "description": "Listado de suberrores usado para dar información más detallada, como en el caso de errores de validación." - } - } - } - } - } - } - \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/internalRef.yaml b/src/test/resources/checks/v3/schemas/OAR029/internalRef.yaml deleted file mode 100644 index adb03369..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/internalRef.yaml +++ /dev/null @@ -1,67 +0,0 @@ -openapi: 3.0.1 -info: - title: Sample-API_efc2b9f76813_V - description: API de ejemplo para pruebas - contact: - name: Nombre del Contacto. - email: contact@mail.com - version: 1.0.12 -servers: - - url: https://api.example.es/api-sample/v1 -paths: - /datos-usuarios: - get: - summary: Listado de usuarios - description: Método que permite obtener un listado con datos básicos de un usuario. - parameters: - - name: desde - in: query - schema: - type: string - format: date - required: false - - name: hasta - in: query - schema: - type: string - format: date - required: false - responses: - '200': - description: OK - headers: - X-Correlation-Id: - description: Cabecera 'X-Correlation-Id' - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/errorMessage' -components: - schemas: - errorMessage: # Noncompliant {{OAR029: 'data' property is missing}} - required: - - message - - status - type: object - properties: - status: - type: string # Noncompliant {{OAR029: 'status' must be of type object}} - description: Especifica el status code HTTP al que se traducirá la excepción. - message: - type: string - description: Mensaje descriptivo del error. - path: - type: string - description: URL path de la petición que originó el error. - type: - type: string - description: URL que apunta a una descripción de los códigos de error. - operationId: - type: string - description: Id de negocio de la operación realizada. - errors: - type: array - description: Listado de suberrores usado para dar información más detallada, - como en el caso de errores de validación. diff --git a/src/test/resources/checks/v3/schemas/OAR029/multiple-content.json b/src/test/resources/checks/v3/schemas/OAR029/multiple-content.json new file mode 100644 index 00000000..8d267976 --- /dev/null +++ b/src/test/resources/checks/v3/schemas/OAR029/multiple-content.json @@ -0,0 +1,38 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Test" + }, + "paths": { + "/test": { + "get": { + "responses": { + "200": { + "description": "ok", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "status": { + "type": "object" + }, + "payload": { + "type": "object" + } + } + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/multiple-content.yaml b/src/test/resources/checks/v3/schemas/OAR029/multiple-content.yaml new file mode 100644 index 00000000..ada0c9c8 --- /dev/null +++ b/src/test/resources/checks/v3/schemas/OAR029/multiple-content.yaml @@ -0,0 +1,22 @@ +openapi: 3.0.0 +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + content: + application/json: + schema: + type: object + properties: + status: + type: object + payload: + type: object + text/plain: + schema: + type: string \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/no-json-content.json b/src/test/resources/checks/v3/schemas/OAR029/no-json-content.json new file mode 100644 index 00000000..1b02fe73 --- /dev/null +++ b/src/test/resources/checks/v3/schemas/OAR029/no-json-content.json @@ -0,0 +1,25 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Test" + }, + "paths": { + "/test": { + "get": { + "responses": { + "200": { + "description": "ok", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/no-json-content.yaml b/src/test/resources/checks/v3/schemas/OAR029/no-json-content.yaml new file mode 100644 index 00000000..9966b08c --- /dev/null +++ b/src/test/resources/checks/v3/schemas/OAR029/no-json-content.yaml @@ -0,0 +1,14 @@ +openapi: 3.0.0 +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + content: + text/plain: + schema: + type: string \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-error-with-properties-wrong-type-r.json b/src/test/resources/checks/v3/schemas/OAR029/with-error-with-properties-wrong-type-r.json deleted file mode 100644 index 6a2f1e5e..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-error-with-properties-wrong-type-r.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "openapi": "3.0.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore" - }, - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/successResponse" - } - } - } - }, - "204": { - "description": "No content" - }, - "400": { - "description": "Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/errorResponse" - } - } - } - }, - "default": { - "description": "Unknown" - } - } - } - } - }, - "components": { - "schemas": { - "successResponse": { - "type": "object", - "properties": { - "payload": { - "type": "object", - "properties": { - "tipos": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "errorResponse": { - "type": "object", - "properties": { - "error": { - "type": "object", - "properties": { - "code": { - "type": "integer" # Noncompliant {{OAR029: 'code' must be of type string}} - }, - "message": { - "type": "integer" # Noncompliant {{OAR029: 'message' must be of type string}} - }, - "details": { - "type": "integer" # Noncompliant {{OAR029: 'details' must be of type array}} - }, - "httpStatus": { - "type": "string" # Noncompliant {{OAR029: 'httpStatus' must be of type integer}} - } - }, - "required": [ - "code", - "message", - "httpStatus" - ] - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-error-with-properties-wrong-type-r.yaml b/src/test/resources/checks/v3/schemas/OAR029/with-error-with-properties-wrong-type-r.yaml deleted file mode 100644 index 32eabe95..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-error-with-properties-wrong-type-r.yaml +++ /dev/null @@ -1,55 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - application/json: - schema: - $ref: '#/components/schemas/successResponse' - 204: - description: No content - 400: - description: Error - content: - application/json: - schema: - $ref: '#/components/schemas/errorResponse' - default: - description: Unknown - -components: - schemas: - successResponse: - type: object - properties: - payload: - type: object - properties: - tipos: - type: array - items: - type: string - errorResponse: - type: object - properties: - error: - type: object - properties: - code: - type: integer # Noncompliant {{OAR029: 'code' must be of type string}} - message: - type: integer # Noncompliant {{OAR029: 'message' must be of type string}} - details: - type: integer # Noncompliant {{OAR029: 'details' must be of type array}} - httpStatus: - type: string # Noncompliant {{OAR029: 'httpStatus' must be of type integer}} - required: - - code - - message - - httpStatus diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-error-without-properties-r.json b/src/test/resources/checks/v3/schemas/OAR029/with-error-without-properties-r.json deleted file mode 100644 index d8ea6754..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-error-without-properties-r.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "openapi": "3.0.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore" - }, - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/successResponse" - } - } - } - }, - "204": { - "description": "No content" - }, - "400": { - "description": "Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/errorResponse" - } - } - } - }, - "default": { - "description": "Unknown" - } - } - } - } - }, - "components": { - "schemas": { - "successResponse": { - "type": "object", - "properties": { - "payload": { - "type": "object", - "properties": { - "tipos": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "errorResponse": { - "type": "object", - "properties": { - "error": { # Noncompliant {{OAR029: 'code' property is missing}} {{OAR029: 'details' property is missing}} {{OAR029: 'httpStatus' property is missing}} {{OAR029: 'message' property is missing}} - "type": "object", - "properties": {}, - "required": [ - "code", - "message", - "httpStatus" - ] - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-error-without-properties-r.yaml b/src/test/resources/checks/v3/schemas/OAR029/with-error-without-properties-r.yaml deleted file mode 100644 index 16e83e55..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-error-without-properties-r.yaml +++ /dev/null @@ -1,47 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - application/json: - schema: - $ref: '#/components/schemas/successResponse' - 204: - description: No content - 400: - description: Error - content: - application/json: - schema: - $ref: '#/components/schemas/errorResponse' - default: - description: Unknown - -components: - schemas: - successResponse: - type: object - properties: - payload: - type: object - properties: - tipos: - type: array - items: - type: string - errorResponse: - type: object - properties: - error: # Noncompliant {{OAR029: 'code' property is missing}} {{OAR029: 'details' property is missing}} {{OAR029: 'httpStatus' property is missing}} {{OAR029: 'message' property is missing}} - type: object - properties: {} - required: - - code - - message - - httpStatus \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-error-wrong-type-r.json b/src/test/resources/checks/v3/schemas/OAR029/with-error-wrong-type-r.json deleted file mode 100644 index 2ed7ec61..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-error-wrong-type-r.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "openapi": "3.0.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore" - }, - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/successResponse" - } - } - } - }, - "204": { - "description": "No content" - }, - "400": { - "description": "Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/errorResponse" - } - } - } - }, - "default": { - "description": "Unknown" - } - } - } - } - }, - "components": { - "schemas": { - "successResponse": { - "type": "object", - "properties": { - "payload": { - "type": "object", - "properties": { - "tipos": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "errorResponse": { - "type": "object", - "properties": { - "error": { - "type": "integer", # Noncompliant {{OAR029: 'error' must be of type object}} - "properties": { - "code": { - "type": "string" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "type": "string" - } - }, - "httpStatus": { - "type": "integer" - } - }, - "required": [ - "code", - "message", - "httpStatus" - ] - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-error-wrong-type-r.yaml b/src/test/resources/checks/v3/schemas/OAR029/with-error-wrong-type-r.yaml deleted file mode 100644 index ac0cbfcf..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-error-wrong-type-r.yaml +++ /dev/null @@ -1,57 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - application/json: - schema: - $ref: '#/components/schemas/successResponse' - 204: - description: No content - 400: - description: Error - content: - application/json: - schema: - $ref: '#/components/schemas/errorResponse' - default: - description: Unknown - -components: - schemas: - successResponse: - type: object - properties: - payload: - type: object - properties: - tipos: - type: array - items: - type: string - errorResponse: - type: object - properties: - error: - type: integer # Noncompliant {{OAR029: 'error' must be of type object}} - properties: - code: - type: string - message: - type: string - details: - type: array - items: - type: string - httpStatus: - type: integer - required: - - code - - message - - httpStatus \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-result-with-properties-wrong-type-md.json b/src/test/resources/checks/v3/schemas/OAR029/with-result-with-properties-wrong-type-md.json deleted file mode 100644 index fbdfa315..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-result-with-properties-wrong-type-md.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Swagger Petstore", - "version": "1.0.0" - }, - "servers": [ - { - "url": "/" - } - ], - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/response" - } - } - } - }, - "204": { - "description": "No content", - "content": { - } - }, - "400": { - "description": "Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/response" - } - } - } - }, - "default": { - "description": "Unknown", - "content": { - } - } - } - } - } - }, - "components": { - "schemas": { - "response": { - "allOf": [ - { - "$ref": "#/components/schemas/standard_response" - } - ] - }, - "standard_response": { - "type": "object", - "properties": { - "data": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } - }, - "result": { - "required": [ - "http_code", - "status", - "trace_id" - ], - "type": "object", - "properties": { - "status": { - "type": "string" # Noncompliant {{OAR029: 'status' must be of type boolean}} - }, - "http_code": { - "type": "string" # Noncompliant {{OAR029: 'http_code' must be of type integer}} - }, - "errors": { - "type": "string" # Noncompliant {{OAR029: 'errors' must be of type array}} - }, - "trace_id": { - "type": "integer" # Noncompliant {{OAR029: 'trace_id' must be of type string}} - } - } - } - } - } - } - } - } \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-result-with-properties-wrong-type-md.yaml b/src/test/resources/checks/v3/schemas/OAR029/with-result-with-properties-wrong-type-md.yaml deleted file mode 100644 index 21b31cd5..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-result-with-properties-wrong-type-md.yaml +++ /dev/null @@ -1,56 +0,0 @@ -openapi: 3.0.1 -info: - title: Swagger Petstore - version: 1.0.0 -servers: -- url: / -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - 'application/json': - schema: - $ref: '#/components/schemas/response' - 204: - description: No content - content: {} - 400: - description: Error - content: - 'application/json': - schema: - $ref: '#/components/schemas/response' - default: - description: Unknown - content: {} -components: - schemas: - response: - allOf: - - $ref: '#/components/schemas/standard_response' - standard_response: - type: object - properties: - data: - type: object - properties: - id: - type: string - result: - required: - - http_code - - status - - trace_id - type: object - properties: - status: - type: string # Noncompliant {{OAR029: 'status' must be of type boolean}} - http_code: - type: string # Noncompliant {{OAR029: 'http_code' must be of type integer}} - errors: - type: string # Noncompliant {{OAR029: 'errors' must be of type array}} - trace_id: - type: integer # Noncompliant {{OAR029: 'trace_id' must be of type string}} diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-result-without-properties-md.json b/src/test/resources/checks/v3/schemas/OAR029/with-result-without-properties-md.json deleted file mode 100644 index 5b02c8a8..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-result-without-properties-md.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Swagger Petstore", - "version": "1.0.0" - }, - "servers": [ - { - "url": "/" - } - ], - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/response" - } - } - } - }, - "204": { - "description": "No content", - "content": { - } - }, - "400": { - "description": "Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/response" - } - } - } - }, - "default": { - "description": "Unknown", - "content": { - } - } - } - } - } - }, - "components": { - "schemas": { - "response": { - "allOf": [ - { - "$ref": "#/components/schemas/standard_response" - } - ] - }, - "standard_response": { - "type": "object", - "properties": { - "data": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } - }, - "result": { # Noncompliant {{OAR029: 'errors' property is missing}} {{OAR029: 'http_code' property is missing}} {{OAR029: 'status' property is missing}} {{OAR029: 'trace_id' property is missing}} - "type": "object", - "properties": { - }, - "required": ["http_code", "status", "trace_id"] - } - } - } - } - } - } \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-result-without-properties-md.yaml b/src/test/resources/checks/v3/schemas/OAR029/with-result-without-properties-md.yaml deleted file mode 100644 index 6434b79c..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-result-without-properties-md.yaml +++ /dev/null @@ -1,48 +0,0 @@ -openapi: 3.0.1 -info: - title: Swagger Petstore - version: 1.0.0 -servers: -- url: / -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - 'application/json': - schema: - $ref: '#/components/schemas/response' - 204: - description: No content - content: {} - 400: - description: Error - content: - 'application/json': - schema: - $ref: '#/components/schemas/response' - default: - description: Unknown - content: {} -components: - schemas: - response: - allOf: - - $ref: '#/components/schemas/standard_response' - standard_response: - type: object - properties: - data: - type: object - properties: - id: - type: string - result: # Noncompliant {{OAR029: 'errors' property is missing}} {{OAR029: 'http_code' property is missing}} {{OAR029: 'status' property is missing}} {{OAR029: 'trace_id' property is missing}} - type: object - properties: {} - required: - - http_code - - status - - trace_id diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-result-wrong-type-md.json b/src/test/resources/checks/v3/schemas/OAR029/with-result-wrong-type-md.json deleted file mode 100644 index c24b20fd..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-result-wrong-type-md.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Swagger Petstore", - "version": "1.0.0" - }, - "servers": [ - { - "url": "/" - } - ], - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/response" - } - } - } - }, - "204": { - "description": "No content", - "content": { - } - }, - "400": { - "description": "Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/response" - } - } - } - }, - "default": { - "description": "Unknown", - "content": { - } - } - } - } - } - }, - "components": { - "schemas": { - "response": { - "allOf": [ - { - "$ref": "#/components/schemas/standard_response" - } - ] - }, - "standard_response": { - "type": "object", - "properties": { - "data": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } - }, - "result": { - "required": [ - "http_code", - "status", - "trace_id" - ], - "type": "integer", # Noncompliant {{OAR029: 'result' must be of type object}} - "properties": { - "status": { - "type": "boolean" - }, - "http_code": { - "type": "integer" - }, - "errors": { - "type": "array", - "items": { - "type": "object", - "properties": { - } - } - }, - "trace_id": { - "type": "string" - } - } - } - } - } - } - } - } \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-result-wrong-type-md.yaml b/src/test/resources/checks/v3/schemas/OAR029/with-result-wrong-type-md.yaml deleted file mode 100644 index 37e75c1b..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-result-wrong-type-md.yaml +++ /dev/null @@ -1,59 +0,0 @@ -openapi: 3.0.1 -info: - title: Swagger Petstore - version: 1.0.0 -servers: -- url: / -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - 'application/json': - schema: - $ref: '#/components/schemas/response' - 204: - description: No content - content: {} - 400: - description: Error - content: - 'application/json': - schema: - $ref: '#/components/schemas/response' - default: - description: Unknown - content: {} -components: - schemas: - response: - allOf: - - $ref: '#/components/schemas/standard_response' - standard_response: - type: object - properties: - data: - type: object - properties: - id: - type: string - result: - required: - - http_code - - status - - trace_id - type: integer # Noncompliant {{OAR029: 'result' must be of type object}} - properties: - status: - type: boolean - http_code: - type: integer - errors: - type: array - items: - type: object - properties: {} - trace_id: - type: string diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-status-with-properties-wrong-type.json b/src/test/resources/checks/v3/schemas/OAR029/with-status-with-properties-wrong-type.json deleted file mode 100644 index af6d6d23..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-status-with-properties-wrong-type.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/response" - } - } - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/response" - } - } - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "components": { - "schemas" : { - "response" : { - "type" : "object", - "allOf" : [ { - "$ref" : "#/components/schemas/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "status" : { - "type" : "object", - "properties" : { - "http_status" : { - "type" : "boolean" # Noncompliant {{OAR029: 'http_status' must be of type string}} - }, - "code" : { - "type" : "string" # Noncompliant {{OAR029: 'code' must be of type integer}} - }, - "errors" : { - "type" : "string" # Noncompliant {{OAR029: 'errors' must be of type array}} - }, - "description" : { - "type" : "integer" # Noncompliant {{OAR029: 'description' must be of type string}} - }, - "internal_code" : { - "type" : "integer" # Noncompliant {{OAR029: 'internal_code' must be of type string}} - } - }, - "required" : [ "http_status", "code", "description", "errors" ] - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-status-with-properties-wrong-type.yaml b/src/test/resources/checks/v3/schemas/OAR029/with-status-with-properties-wrong-type.yaml deleted file mode 100644 index 68e59b91..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-status-with-properties-wrong-type.yaml +++ /dev/null @@ -1,59 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - application/json: - schema: - $ref: '#/components/schemas/response' - 204: - description: No content - 400: - description: Error - content: - application/json: - schema: - $ref: '#/components/schemas/response' - default: - description: Unknown -components: - schemas: - response: - type: object - allOf: - - $ref: '#/components/schemas/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - status: - type: object - properties: - http_status: - type: boolean # Noncompliant {{OAR029: 'http_status' must be of type string}} - code: - type: string # Noncompliant {{OAR029: 'code' must be of type integer}} - errors: - type: string # Noncompliant {{OAR029: 'errors' must be of type array}} - description: - type: integer # Noncompliant {{OAR029: 'description' must be of type string}} - internal_code: - type: integer # Noncompliant {{OAR029: 'internal_code' must be of type string}} - required: - - http_status - - code - - description - - errors diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-status-without-properties.json b/src/test/resources/checks/v3/schemas/OAR029/with-status-without-properties.json deleted file mode 100644 index 80e9dbf2..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-status-without-properties.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/response" - } - } - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/response" - } - } - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "components": { - "schemas" : { - "response" : { - "type" : "object", - "allOf" : [ { - "$ref" : "#/components/schemas/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "status" : { # Noncompliant {{OAR029: 'code' property is missing}} {{OAR029: 'description' property is missing}} {{OAR029: 'errors' property is missing}} {{OAR029: 'http_status' property is missing}} {{OAR029: 'internal_code' property is missing}} - "type" : "object", - "properties" : { }, - "required" : [ "http_status", "code", "description", "errors" ] - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-status-without-properties.yaml b/src/test/resources/checks/v3/schemas/OAR029/with-status-without-properties.yaml deleted file mode 100644 index 2437684e..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-status-without-properties.yaml +++ /dev/null @@ -1,49 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - application/json: - schema: - $ref: '#/components/schemas/response' - 204: - description: No content - 400: - description: Error - content: - application/json: - schema: - $ref: '#/components/schemas/response' - default: - description: Unknown -components: - schemas: - response: - type: object - allOf: - - $ref: '#/components/schemas/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - status: # Noncompliant {{OAR029: 'code' property is missing}} {{OAR029: 'description' property is missing}} {{OAR029: 'errors' property is missing}} {{OAR029: 'http_status' property is missing}} {{OAR029: 'internal_code' property is missing}} - type: object - properties: {} - required: - - http_status - - code - - description - - errors diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-status-wrong-type.json b/src/test/resources/checks/v3/schemas/OAR029/with-status-wrong-type.json deleted file mode 100644 index 014223c9..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-status-wrong-type.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/response" - } - } - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/response" - } - } - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "components": { - "schemas" : { - "response" : { - "type" : "object", - "allOf" : [ { - "$ref" : "#/components/schemas/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "status" : { - "type" : "integer", # Noncompliant {{OAR029: 'status' must be of type object}} - "properties" : { - "http_status" : { - "type" : "string" - }, - "code" : { - "type" : "integer" - }, - "errors" : { - "type" : "array", - "items" : { - "type" : "object", - "properties": { - "name": { - "type": "string" - }, - "value": { - "type": "string" - } - } - } - }, - "description" : { - "type" : "string" - }, - "internal_code" : { - "type" : "string" - } - }, - "required" : [ "http_status", "code", "description", "errors" ] - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/with-status-wrong-type.yaml b/src/test/resources/checks/v3/schemas/OAR029/with-status-wrong-type.yaml deleted file mode 100644 index 13bce453..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/with-status-wrong-type.yaml +++ /dev/null @@ -1,66 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - application/json: - schema: - $ref: '#/components/schemas/response' - 204: - description: No content - 400: - description: Error - content: - application/json: - schema: - $ref: '#/components/schemas/response' - default: - description: Unknown -components: - schemas: - response: - type: object - allOf: - - $ref: '#/components/schemas/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - status: - type: integer # Noncompliant {{OAR029: 'status' must be of type object}} - properties: - http_status: - type: string - code: - type: integer - errors: - type: array - items: - type: object - properties: - name: - type: string - value: - type: string - description: - type: string - internal_code: - type: string - required: - - http_status - - code - - description - - errors \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-data-md.json b/src/test/resources/checks/v3/schemas/OAR029/without-data-md.json deleted file mode 100644 index 8262dd65..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-data-md.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Swagger Petstore", - "version": "1.0.0" - }, - "servers": [ - { - "url": "/" - } - ], - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/response" - } - } - } - }, - "204": { - "description": "No content", - "content": { - } - }, - "400": { - "description": "Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/response" - } - } - } - }, - "default": { - "description": "Unknown", - "content": { - } - } - } - } - } - }, - "components": { - "schemas": { - "response": { # Noncompliant {{OAR029: 'data' property is missing}} - "allOf": [ - { - "$ref": "#/components/schemas/standard_response" - } - ] - }, - "standard_response": { - "type": "object", - "properties": { - "result": { - "required": [ - "http_code", - "status", - "trace_id" - ], - "type": "object", - "properties": { - "status": { - "type": "boolean" - }, - "http_code": { - "type": "integer" - }, - "errors": { - "type": "array", - "items": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - }, - "trace_id": { - "type": "string" - } - } - } - } - } - } - } - } \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-data-md.yaml b/src/test/resources/checks/v3/schemas/OAR029/without-data-md.yaml deleted file mode 100644 index 950439cb..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-data-md.yaml +++ /dev/null @@ -1,61 +0,0 @@ -openapi: 3.0.1 -info: - title: Swagger Petstore - version: 1.0.0 -servers: -- url: / -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - 'application/json': - schema: - $ref: '#/components/schemas/response' - 204: - description: No content - content: {} - 400: - description: Error - content: - 'application/json': - schema: - $ref: '#/components/schemas/response' - default: - description: Unknown - content: {} -components: - schemas: - response: # Noncompliant {{OAR029: 'data' property is missing}} - allOf: - - $ref: '#/components/schemas/standard_response' - standard_response: - type: object - properties: - result: - required: - - http_code - - status - - trace_id - type: object - properties: - status: - type: boolean - http_code: - type: integer - errors: - type: array - items: - required: - - code - - message - type: object - properties: - code: - type: integer - message: - type: string - trace_id: - type: string diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-data.json b/src/test/resources/checks/v3/schemas/OAR029/without-data.json deleted file mode 100644 index 4c36767a..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-data.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/response" - } - } - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/response" - } - } - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "components": { - "schemas" : { - "response" : { # Noncompliant {{OAR029: 'data' property is missing}} - "type" : "object", - "allOf" : [ { - "$ref" : "#/components/schemas/standard_response" - } ], - "properties" : { - "value" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "status" : { - "type" : "object", - "properties" : { - "http_status" : { - "type" : "string" - }, - "code" : { - "type" : "integer" - }, - "errors" : { - "type" : "array", - "items" : { - "type" : "object", - "properties": { - "name": { - "type": "string" - }, - "value": { - "type": "string" - } - } - } - }, - "description" : { - "type" : "string" - }, - "internal_code" : { - "type" : "string" - } - }, - "required" : [ "http_status", "code", "description", "errors" ] - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-data.yaml b/src/test/resources/checks/v3/schemas/OAR029/without-data.yaml deleted file mode 100644 index 02cb167f..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-data.yaml +++ /dev/null @@ -1,66 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - application/json: - schema: - $ref: '#/components/schemas/response' - 204: - description: No content - 400: - description: Error - content: - application/json: - schema: - $ref: '#/components/schemas/response' - default: - description: Unknown -components: - schemas: - response: # Noncompliant {{OAR029: 'data' property is missing}} - type: object - allOf: - - $ref: '#/components/schemas/standard_response' - properties: - value: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - status: - type: object - properties: - http_status: - type: string - code: - type: integer - errors: - type: array - items: - type: object - properties: - name: - type: string - value: - type: string - description: - type: string - internal_code: - type: string - required: - - http_status - - code - - description - - errors diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-error-r.json b/src/test/resources/checks/v3/schemas/OAR029/without-error-r.json deleted file mode 100644 index 4a2978a7..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-error-r.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/successResponse" - } - } - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/errorResponse" - } - } - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "components": { - "schemas": { - "successResponse": { - "type": "object", - "properties": { - "payload": { - "type": "object", - "properties": { - "tipos": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "errorResponse": { # Noncompliant {{OAR029: 'error' property is missing}} - "type": "object", - "properties": { - "result": { - "type": "object", - "properties": { - "code": { - "type": "string" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "type": "string" - } - }, - "httpStatus": { - "type": "integer" - } - }, - "required": [ - "code", - "message", - "httpStatus" - ] - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-error-r.yaml b/src/test/resources/checks/v3/schemas/OAR029/without-error-r.yaml deleted file mode 100644 index fdaf26ad..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-error-r.yaml +++ /dev/null @@ -1,57 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - application/json: - schema: - $ref: '#/components/schemas/successResponse' - 204: - description: No content - 400: - description: Error - content: - application/json: - schema: - $ref: '#/components/schemas/errorResponse' - default: - description: Unknown - -components: - schemas: - successResponse: - type: object - properties: - payload: - type: object - properties: - tipos: - type: array - items: - type: string - errorResponse: # Noncompliant {{OAR029: 'error' property is missing}} - type: object - properties: - result: - type: object - properties: - code: - type: string - message: - type: string - details: - type: array - items: - type: string - httpStatus: - type: integer - required: - - code - - message - - httpStatus diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-payload-r.json b/src/test/resources/checks/v3/schemas/OAR029/without-payload-r.json deleted file mode 100644 index f2ee25c9..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-payload-r.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/successResponse" - } - } - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/errorResponse" - } - } - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "components": { - "schemas": { - "successResponse": { # Noncompliant {{OAR029: 'payload' property is missing}} - "type": "object", - "properties": { - "data": { - "type": "object", - "properties": { - "tipos": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "errorResponse": { - "type": "object", - "properties": { - "error": { - "type": "object", - "properties": { - "code": { - "type": "string" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "type": "string" - } - }, - "httpStatus": { - "type": "integer" - } - }, - "required": [ - "code", - "message", - "httpStatus" - ] - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-payload-r.yaml b/src/test/resources/checks/v3/schemas/OAR029/without-payload-r.yaml deleted file mode 100644 index 0993f891..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-payload-r.yaml +++ /dev/null @@ -1,57 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - application/json: - schema: - $ref: '#/components/schemas/successResponse' - 204: - description: No content - 400: - description: Error - content: - application/json: - schema: - $ref: '#/components/schemas/errorResponse' - default: - description: Unknown - -components: - schemas: - successResponse: # Noncompliant {{OAR029: 'payload' property is missing}} - type: object - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - errorResponse: - type: object - properties: - error: - type: object - properties: - code: - type: string - message: - type: string - details: - type: array - items: - type: string - httpStatus: - type: integer - required: - - code - - message - - httpStatus diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-required-fields-md.json b/src/test/resources/checks/v3/schemas/OAR029/without-required-fields-md.json deleted file mode 100644 index 63d7a3bb..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-required-fields-md.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Swagger Petstore", - "version": "1.0.0" - }, - "servers": [ - { - "url": "/" - } - ], - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/response" - } - } - } - }, - "204": { - "description": "No content", - "content": { - } - }, - "400": { - "description": "Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/response" - } - } - } - }, - "default": { - "description": "Unknown", - "content": { - } - } - } - } - } - }, - "components": { - "schemas": { - "response": { - "allOf": [ - { - "$ref": "#/components/schemas/standard_response" - } - ] - }, - "standard_response": { - "type": "object", - "properties": { - "data": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } - }, - "result": { - "required": ["status"], # Noncompliant {{OAR029: The following fields must be required: http_code, status, trace_id}} - "type": "object", - "properties": { - "status": { - "type": "boolean" - }, - "http_code": { - "type": "integer" - }, - "errors": { - "type": "array", - "items": { - "required": [ - "code", - "message" - ], - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "message": { - "type": "string" - } - } - } - }, - "trace_id": { - "type": "string" - } - } - } - } - } - } - } - } \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-required-fields-md.yaml b/src/test/resources/checks/v3/schemas/OAR029/without-required-fields-md.yaml deleted file mode 100644 index efecd06f..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-required-fields-md.yaml +++ /dev/null @@ -1,64 +0,0 @@ -openapi: 3.0.1 -info: - title: Swagger Petstore - version: 1.0.0 -servers: -- url: / -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - 'application/json': - schema: - $ref: '#/components/schemas/response' - 204: - description: No content - content: {} - 400: - description: Error - content: - 'application/json': - schema: - $ref: '#/components/schemas/response' - default: - description: Unknown - content: {} -components: - schemas: - response: - allOf: - - $ref: '#/components/schemas/standard_response' - standard_response: - type: object - properties: - data: - type: object - properties: - id: - type: string - result: - required: # Noncompliant {{OAR029: The following fields must be required: http_code, status, trace_id}} - - status - type: object - properties: - status: - type: boolean - http_code: - type: integer - errors: - type: array - items: - required: - - code - - message - type: object - properties: - code: - type: integer - message: - type: string - trace_id: - type: string diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-required-fields-r.json b/src/test/resources/checks/v3/schemas/OAR029/without-required-fields-r.json deleted file mode 100644 index ea97f57f..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-required-fields-r.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "openapi": "3.0.0", - "info": { - "version": "1.0.0", - "title": "Swagger Petstore" - }, - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/successResponse" - } - } - } - }, - "204": { - "description": "No content" - }, - "400": { - "description": "Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/errorResponse" - } - } - } - }, - "default": { - "description": "Unknown" - } - } - } - } - }, - "components": { - "schemas": { - "successResponse": { - "type": "object", - "properties": { - "payload": { - "type": "object", - "properties": { - "tipos": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, - "errorResponse": { - "type": "object", - "properties": { - "error": { - "type": "object", - "properties": { - "code": { - "type": "string" - }, - "message": { - "type": "string" - }, - "details": { - "type": "array", - "items": { - "type": "string" - } - }, - "httpStatus": { - "type": "integer" - } - }, - "required": [ # Noncompliant {{OAR029: The following fields must be required: code, httpStatus, message}} - "httpStatus" - ] - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-required-fields-r.yaml b/src/test/resources/checks/v3/schemas/OAR029/without-required-fields-r.yaml deleted file mode 100644 index 8ee987d5..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-required-fields-r.yaml +++ /dev/null @@ -1,55 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - application/json: - schema: - $ref: '#/components/schemas/successResponse' - 204: - description: No content - 400: - description: Error - content: - application/json: - schema: - $ref: '#/components/schemas/errorResponse' - default: - description: Unknown - -components: - schemas: - successResponse: - type: object - properties: - payload: - type: object - properties: - tipos: - type: array - items: - type: string - errorResponse: - type: object - properties: - error: - type: object - properties: - code: - type: string - message: - type: string - details: - type: array - items: - type: string - httpStatus: - type: integer - required: # Noncompliant {{OAR029: The following fields must be required: code, httpStatus, message}} - - httpStatus diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-required-fields.json b/src/test/resources/checks/v3/schemas/OAR029/without-required-fields.json deleted file mode 100644 index 350d748a..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-required-fields.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/response" - } - } - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/response" - } - } - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "components": { - "schemas" : { - "response" : { - "type" : "object", - "allOf" : [ { - "$ref" : "#/components/schemas/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "status" : { - "type" : "object", - "properties" : { - "http_status" : { - "type" : "string" - }, - "code" : { - "type" : "integer" - }, - "errors" : { - "type" : "array", - "items" : { - "type" : "object", - "properties": { - "name": { - "type": "string" - }, - "value": { - "type": "string" - } - } - } - }, - "description" : { - "type" : "string" - }, - "internal_code" : { - "type" : "string" - } - }, - "required" : [ "http_status" ] # Noncompliant {{OAR029: The following fields must be required: code, description, errors, http_status}} - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-required-fields.yaml b/src/test/resources/checks/v3/schemas/OAR029/without-required-fields.yaml deleted file mode 100644 index 234683f0..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-required-fields.yaml +++ /dev/null @@ -1,63 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - application/json: - schema: - $ref: '#/components/schemas/response' - 204: - description: No content - 400: - description: Error - content: - application/json: - schema: - $ref: '#/components/schemas/response' - default: - description: Unknown -components: - schemas: - response: - type: object - allOf: - - $ref: '#/components/schemas/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - status: - type: object - properties: - http_status: - type: string - code: - type: integer - errors: - type: array - items: - type: object - properties: - name: - type: string - value: - type: string - description: - type: string - internal_code: - type: string - required: # Noncompliant {{OAR029: The following fields must be required: code, description, errors, http_status}} - - http_status diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-result-md.json b/src/test/resources/checks/v3/schemas/OAR029/without-result-md.json deleted file mode 100644 index 136cf12d..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-result-md.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Swagger Petstore", - "version": "1.0.0" - }, - "servers": [ - { - "url": "/" - } - ], - "paths": { - "/endpoint": { - "get": { - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/response" - } - } - } - }, - "204": { - "description": "No content", - "content": { - } - }, - "400": { - "description": "Error", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/response" - } - } - } - }, - "default": { - "description": "Unknown", - "content": { - } - } - } - } - } - }, - "components": { - "schemas": { - "response": { # Noncompliant {{OAR029: 'result' property is missing}} - "allOf": [ - { - "$ref": "#/components/schemas/standard_response" - } - ] - }, - "standard_response": { - "type": "object", - "properties": { - "data": { - "type": "object", - "properties": { - "id": { - "type": "string" - } - } - }, - "response": { - "required": [ - "http_code", - "status", - "trace_id" - ], - "type": "object", - "properties": { - "status": { - "type": "boolean" - }, - "http_code": { - "type": "integer" - }, - "errors": { - "type": "array", - "items": { - "type": "object", - "properties": { - } - } - }, - "trace_id": { - "type": "string" - } - } - } - } - } - } - } - } \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-result-md.yaml b/src/test/resources/checks/v3/schemas/OAR029/without-result-md.yaml deleted file mode 100644 index 81cebda9..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-result-md.yaml +++ /dev/null @@ -1,59 +0,0 @@ -openapi: 3.0.1 -info: - title: Swagger Petstore - version: 1.0.0 -servers: -- url: / -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - 'application/json': - schema: - $ref: '#/components/schemas/response' - 204: - description: No content - content: {} - 400: - description: Error - content: - 'application/json': - schema: - $ref: '#/components/schemas/response' - default: - description: Unknown - content: {} -components: - schemas: - response: # Noncompliant {{OAR029: 'result' property is missing}} - allOf: - - $ref: '#/components/schemas/standard_response' - standard_response: - type: object - properties: - data: - type: object - properties: - id: - type: string - response: - required: - - http_code - - status - - trace_id - type: object - properties: - status: - type: boolean - http_code: - type: integer - errors: - type: array - items: - type: object - properties: {} - trace_id: - type: string diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-status.json b/src/test/resources/checks/v3/schemas/OAR029/without-status.json deleted file mode 100644 index 6e0d5fcb..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-status.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "version" : "1.0.0", - "title" : "Swagger Petstore" - }, - "paths" : { - "/endpoint" : { - "get" : { - "responses" : { - "200" : { - "description" : "Ok", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/response" - } - } - } - }, - "204" : { - "description" : "No content" - }, - "400" : { - "description" : "Error", - "content": { - "application/json": { - "schema" : { - "$ref" : "#/components/schemas/response" - } - } - } - }, - "default" : { - "description" : "Unknown" - } - } - } - } - }, - "components": { - "schemas" : { - "response" : { # Noncompliant {{OAR029: 'status' property is missing}} - "type" : "object", - "allOf" : [ { - "$ref" : "#/components/schemas/standard_response" - } ], - "properties" : { - "data" : { - "type" : "object", - "properties" : { - "tipos" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - } - } - }, - "standard_response" : { - "type" : "object", - "properties" : { - "response" : { - "type" : "object", - "properties" : { - "http_status" : { - "type" : "string" - }, - "code" : { - "type" : "integer" - }, - "errors" : { - "type" : "array", - "items" : { - "type" : "object", - "properties": { - "name": { - "type": "string" - }, - "value": { - "type": "string" - } - } - } - }, - "description" : { - "type" : "string" - }, - "internal_code" : { - "type" : "string" - } - }, - "required" : [ "http_status", "code", "description", "errors" ] - } - } - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/checks/v3/schemas/OAR029/without-status.yaml b/src/test/resources/checks/v3/schemas/OAR029/without-status.yaml deleted file mode 100644 index de0781dd..00000000 --- a/src/test/resources/checks/v3/schemas/OAR029/without-status.yaml +++ /dev/null @@ -1,66 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore -paths: - /endpoint: - get: - responses: - 200: - description: Ok - content: - application/json: - schema: - $ref: '#/components/schemas/response' - 204: - description: No content - 400: - description: Error - content: - application/json: - schema: - $ref: '#/components/schemas/response' - default: - description: Unknown -components: - schemas: - response: # Noncompliant {{OAR029: 'status' property is missing}} - type: object - allOf: - - $ref: '#/components/schemas/standard_response' - properties: - data: - type: object - properties: - tipos: - type: array - items: - type: string - standard_response: - type: object - properties: - response: - type: object - properties: - http_status: - type: string - code: - type: integer - errors: - type: array - items: - type: object - properties: - name: - type: string - value: - type: string - description: - type: string - internal_code: - type: string - required: - - http_status - - code - - description - - errors diff --git a/src/test/resources/checks/v3/security/OAR079/no-parameters.json b/src/test/resources/checks/v3/security/OAR079/no-parameters.json new file mode 100644 index 00000000..9d39ba8a --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR079/no-parameters.json @@ -0,0 +1,19 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore" + }, + "paths": { + "/items": { + "get": { + "summary": "Get a list of items", + "responses": { + "200": { + "description": "A list of items" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v3/security/OAR079/no-parameters.yaml b/src/test/resources/checks/v3/security/OAR079/no-parameters.yaml new file mode 100644 index 00000000..f220c16c --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR079/no-parameters.yaml @@ -0,0 +1,11 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore +paths: + /items: + get: + summary: Get a list of items + responses: + 200: + description: A list of items diff --git a/src/test/resources/checks/v3/security/OAR079/query-param-only.json b/src/test/resources/checks/v3/security/OAR079/query-param-only.json new file mode 100644 index 00000000..ad428c6b --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR079/query-param-only.json @@ -0,0 +1,26 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore" + }, + "paths": { + "/items": { + "get": { + "summary": "Get a list of items", + "parameters": [ + { + "name": "param1", + "in": "query", + "schema": { "type": "string" } + } + ], + "responses": { + "200": { + "description": "A list of items" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v3/security/OAR079/query-param-only.yaml b/src/test/resources/checks/v3/security/OAR079/query-param-only.yaml new file mode 100644 index 00000000..d85cf1b8 --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR079/query-param-only.yaml @@ -0,0 +1,16 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore +paths: + /items: + get: + summary: Get a list of items + parameters: + - name: param1 + in: query + schema: + type: string + responses: + 200: + description: A list of items diff --git a/src/test/resources/checks/v3/security/OAR083/no-parameters.json b/src/test/resources/checks/v3/security/OAR083/no-parameters.json new file mode 100644 index 00000000..c4aee44f --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR083/no-parameters.json @@ -0,0 +1,19 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "My API" + }, + "paths": { + "/examples": { + "get": { + "summary": "Get a list of items", + "responses": { + "200": { + "description": "A list of items" + } + } + } + } + } +} diff --git a/src/test/resources/checks/v3/security/OAR083/no-parameters.yaml b/src/test/resources/checks/v3/security/OAR083/no-parameters.yaml new file mode 100644 index 00000000..cc4eaac0 --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR083/no-parameters.yaml @@ -0,0 +1,11 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: My API +paths: + /examples: + get: + summary: Get a list of items + responses: + 200: + description: A list of items diff --git a/src/test/resources/checks/v3/security/OAR083/null-name-param.json b/src/test/resources/checks/v3/security/OAR083/null-name-param.json new file mode 100644 index 00000000..467fc8c9 --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR083/null-name-param.json @@ -0,0 +1,30 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "My API" + }, + "paths": { + "/examples/{id}": { + "get": { + "summary": "Get an item", + "parameters": [ + { + "name": null, + "in": "query", + "schema": { "type": "string" } + }, + { + "name": "id", + "in": "path", + "required": true, + "schema": { "type": "string" } + } + ], + "responses": { + "200": { "description": "An item" } + } + } + } + } +} diff --git a/src/test/resources/checks/v3/security/OAR083/null-name-param.yaml b/src/test/resources/checks/v3/security/OAR083/null-name-param.yaml new file mode 100644 index 00000000..67ccaf06 --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR083/null-name-param.yaml @@ -0,0 +1,21 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: My API +paths: + /examples/{id}: + get: + summary: Get an item + parameters: + - name: ~ + in: query + schema: + type: string + - name: id + in: path + required: true + schema: + type: string + responses: + 200: + description: An item diff --git a/src/test/resources/checks/v3/security/OAR083/options-operation.json b/src/test/resources/checks/v3/security/OAR083/options-operation.json new file mode 100644 index 00000000..f2471041 --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR083/options-operation.json @@ -0,0 +1,24 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "My API" + }, + "paths": { + "/examples": { + "options": { + "summary": "Options for the resource", + "parameters": [ + { + "name": "email", + "in": "query", + "schema": { "type": "string" } + } + ], + "responses": { + "200": { "description": "OK" } + } + } + } + } +} diff --git a/src/test/resources/checks/v3/security/OAR083/options-operation.yaml b/src/test/resources/checks/v3/security/OAR083/options-operation.yaml new file mode 100644 index 00000000..02b2fada --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR083/options-operation.yaml @@ -0,0 +1,16 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: My API +paths: + /examples: + options: + summary: Options for the resource + parameters: + - name: email + in: query + schema: + type: string + responses: + 200: + description: OK diff --git a/src/test/resources/checks/v3/security/OAR084/no-parameters.json b/src/test/resources/checks/v3/security/OAR084/no-parameters.json new file mode 100644 index 00000000..dcdc8dd6 --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR084/no-parameters.json @@ -0,0 +1,17 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "My API" + }, + "paths": { + "/examples": { + "get": { + "summary": "Get a list of items", + "responses": { + "200": { "description": "A list of items" } + } + } + } + } +} diff --git a/src/test/resources/checks/v3/security/OAR084/no-parameters.yaml b/src/test/resources/checks/v3/security/OAR084/no-parameters.yaml new file mode 100644 index 00000000..cc4eaac0 --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR084/no-parameters.yaml @@ -0,0 +1,11 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: My API +paths: + /examples: + get: + summary: Get a list of items + responses: + 200: + description: A list of items diff --git a/src/test/resources/checks/v3/security/OAR084/non-query-param.json b/src/test/resources/checks/v3/security/OAR084/non-query-param.json new file mode 100644 index 00000000..2b52b6d3 --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR084/non-query-param.json @@ -0,0 +1,28 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "My API" + }, + "paths": { + "/examples/{id}": { + "get": { + "summary": "Get an item", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "password" + } + } + ], + "responses": { + "200": { "description": "An item" } + } + } + } + } +} diff --git a/src/test/resources/checks/v3/security/OAR084/non-query-param.yaml b/src/test/resources/checks/v3/security/OAR084/non-query-param.yaml new file mode 100644 index 00000000..b9ec5900 --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR084/non-query-param.yaml @@ -0,0 +1,18 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: My API +paths: + /examples/{id}: + get: + summary: Get an item + parameters: + - name: id + in: path + required: true + schema: + type: string + format: password + responses: + 200: + description: An item diff --git a/src/test/resources/checks/v3/security/OAR084/null-format-param.json b/src/test/resources/checks/v3/security/OAR084/null-format-param.json new file mode 100644 index 00000000..8f760ba8 --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR084/null-format-param.json @@ -0,0 +1,27 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "My API" + }, + "paths": { + "/examples": { + "get": { + "summary": "Get a list of items", + "parameters": [ + { + "name": "exampleParam1", + "in": "query", + "schema": { + "type": "string", + "format": null + } + } + ], + "responses": { + "200": { "description": "A list of items" } + } + } + } + } +} diff --git a/src/test/resources/checks/v3/security/OAR084/null-format-param.yaml b/src/test/resources/checks/v3/security/OAR084/null-format-param.yaml new file mode 100644 index 00000000..dbdd4a21 --- /dev/null +++ b/src/test/resources/checks/v3/security/OAR084/null-format-param.yaml @@ -0,0 +1,17 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: My API +paths: + /examples: + get: + summary: Get a list of items + parameters: + - name: exampleParam1 + in: query + schema: + type: string + format: ~ + responses: + 200: + description: A list of items diff --git a/src/test/resources/checks/v31/schemas/OAR029/valid.yaml b/src/test/resources/checks/v31/schemas/OAR029/valid.yaml new file mode 100644 index 00000000..b4c7d96e --- /dev/null +++ b/src/test/resources/checks/v31/schemas/OAR029/valid.yaml @@ -0,0 +1,19 @@ +openapi: "3.1.0" +info: + version: 1.0.0 + title: Test +paths: + /test: + get: + responses: + "200": + description: ok + content: + application/json: + schema: + type: object + properties: + status: + type: object + payload: + type: object