api-quality-spectral-ruleset 1.6.0-beta.1 → 1.6.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/apq-spectral.yaml CHANGED
@@ -53,9 +53,6 @@ functions:
53
53
  - apq-wso2-auth-type-required
54
54
  - apq-response-content-required
55
55
  - apq-tags-consistency
56
- extends:
57
- - spectral:asyncapi
58
- - spectral:oas
59
56
  rules:
60
57
  apiq:OAR001:
61
58
  description: "For security reasons and as a REST best practice, the HTTPS protocol is mandatory."
@@ -625,8 +622,6 @@ rules:
625
622
  message: "OAR048: An operation can have at most one body parameter"
626
623
  documentationUrl: "https://github.com/apiaddicts/apquality-spectral/blob/main/docs/resources/OAR048.md"
627
624
  severity: error
628
- formats:
629
- - oas2
630
625
  given: "$.paths[*][*]"
631
626
  then:
632
627
  field: parameters
@@ -854,6 +849,10 @@ rules:
854
849
  given:
855
850
  - "$.paths[*][*].parameters[*]"
856
851
  - "$.paths[*].parameters[*]"
852
+ - "$.paths[*].additionalOperations[*].parameters[*]"
853
+ - "$.webhooks[*][*].parameters[*]"
854
+ - "$.webhooks[*].parameters[*]"
855
+ - "$.webhooks[*].additionalOperations[*].parameters[*]"
857
856
  - "$.components.parameters[*]"
858
857
  - "$.parameters[*]"
859
858
  then:
@@ -991,6 +990,7 @@ rules:
991
990
  description: "The $ref of a request body must end with the suffix Body."
992
991
  message: "OAR089: The $ref of a request body must end with the suffix Body."
993
992
  severity: "warn"
993
+ resolved: false
994
994
  given: "$..requestBody.$ref"
995
995
  then:
996
996
  function: pattern
@@ -1,9 +1,17 @@
1
1
  const DEFAULT_INTEGRITY = 'minLength,maxLength,pattern,enum';
2
2
 
3
+ const SELF_CONSTRAINED_FORMATS = new Set([
4
+ 'date', 'date-time', 'uuid', 'ipv4', 'ipv6',
5
+ ]);
6
+
3
7
  function isStringType(type) {
4
8
  return type === 'string' || (Array.isArray(type) && type.indexOf('string') > -1);
5
9
  }
6
10
 
11
+ function hasSelfConstrainedFormat(format) {
12
+ return typeof format === 'string' && SELF_CONSTRAINED_FORMATS.has(format.trim().toLowerCase());
13
+ }
14
+
7
15
  /**
8
16
  * @param {object} targetVal a Parameter Object
9
17
  * @param {object} options
@@ -20,6 +28,8 @@ module.exports = (targetVal, options, context) => {
20
28
 
21
29
  if (!isStringType(container.type)) return [];
22
30
 
31
+ if (hasSelfConstrainedFormat(container.format)) return [];
32
+
23
33
  const raw = options && options.parameter_integrity !== undefined && options.parameter_integrity !== null
24
34
  ? String(options.parameter_integrity)
25
35
  : DEFAULT_INTEGRITY;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-quality-spectral-ruleset",
3
- "version": "1.6.0-beta.1",
3
+ "version": "1.6.0-beta.2",
4
4
  "description": "Spectral ruleset by API Quality",
5
5
  "main": "apq-spectral.yaml",
6
6
  "files": [