Repository: Redocly/redocly-cli
Pull request #1879 (2025-02-04 14:47:17)

feat: added 1.0.1 arazzo version to spot supported versions rule
## What/Why/How?

Added support for Arazzo version 1.0.1 in Spot validation rules.
Adding it as a enum as it takes some time to adapt tooling and despite on patch Arazzo spec version update - some changes can cause not valid file due to some supported syntax was removed or changed (request-in-body, $message from runtime expression, changes on how we can access outputs from the body response).

## Reference

## Testing

## Screenshots (optional)

## Check yourself

- [ ] Code changed? - Tested with redoc/reference-docs/workflows (internal)
- [x] All new/updated code is covered with tests
- [ ] New package installed? - Tested in different environments (browser/node)

## Security

- [x] Security impact of change has been considered
- [x] Code follows company security practices and guidelines


github-actions[bot]: | Command | Mean [s] | Min [s] | Max [s] | Relative |
|:---|---:|---:|---:|---:|
| `redocly lint packages/core/src/benchmark/benches/rebilly.yaml` | 1.030 ± 0.047 | 0.998 | 1.159 | 1.00 ± 0.05 |
| `redocly-next lint packages/core/src/benchmark/benches/rebilly.yaml` | 1.030 ± 0.014 | 1.007 | 1.052 | 1.00 |

<!-- thollander/actions-comment-pull-request "latest-vs-next-comparison" -->
github-actions[bot]: <!-- jest coverage report action for options with hash 3339ae53a38c44382c0fb4491bdb282d -->

## Coverage report 



| <div title="Status of coverage:&#10; 🟢 - ok&#10; 🟡 - slightly more than threshold&#10; 🔴 - under the threshold">St.<sup>:grey_question:</sup></div> | Category   | Percentage | Covered / Total |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :-------------: |
|                                                                           🟡                                                                           | Statements | 78.6%      |    5053/6429    |
|                                                                           🟡                                                                           | Branches   | 67.18%     |    2059/3065    |
|                                                                           🟡                                                                           | Functions  | 73.16%     |     834/1140    |
|                                                                           🟡                                                                           | Lines      | 78.88%     |    4767/6043    |


## Test suite run success
836 tests passing in 120 suites.

<p align="right">Report generated by <a href="https://github.com/ArtiomTr/jest-coverage-report-action">🧪jest coverage report action</a> from 98e2098add4c6682e6866d528ee4e9d81fd532dd</p>


Patch:
diff --git a/.changeset/big-kings-sort.md b/.changeset/big-kings-sort.md
new file mode 100644
index 00000000..e05529b4
--- /dev/null
+++ b/.changeset/big-kings-sort.md
@@ -0,0 +1,5 @@
+---
+"@redocly/openapi-core": patch
+---
+
+Added support for Arazzo version 1.0.1 in Spot validation rules.
diff --git a/packages/core/src/typings/arazzo.ts b/packages/core/src/typings/arazzo.ts
index 5b12e5c8..712eb6fe 100644
--- a/packages/core/src/typings/arazzo.ts
+++ b/packages/core/src/typings/arazzo.ts
@@ -167,4 +167,4 @@ export interface ArazzoDefinition {
 
 export const VERSION_PATTERN = /^1\.0\.\d+(-.+)?$/;
 
-export const ARAZZO_VERSIONS_SUPPORTED_BY_SPOT = ['1.0.0'];
+export const ARAZZO_VERSIONS_SUPPORTED_BY_SPOT = ['1.0.0', '1.0.1'];


Test patch:
diff --git a/packages/core/src/rules/arazzo/__tests__/spot-supported-versions.test.ts b/packages/core/src/rules/arazzo/__tests__/spot-supported-versions.test.ts
index ba7bbaaa..9e83beb2 100644
--- a/packages/core/src/rules/arazzo/__tests__/spot-supported-versions.test.ts
+++ b/packages/core/src/rules/arazzo/__tests__/spot-supported-versions.test.ts
@@ -4,7 +4,36 @@ import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../
 import { BaseResolver } from '../../../resolve';
 
 describe('Arazzo spot-supported-versions', () => {
-  const document = parseYamlToDocument(
+  const documentWithUnsupportedVersion = parseYamlToDocument(
+    outdent`
+      arazzo: '1.0.2'
+      info:
+        title: Cool API
+        version: 1.0.0
+        description: A cool API
+      sourceDescriptions:
+        - name: museum-api
+          type: openapi
+          url: openapi.yaml
+      workflows:
+        - workflowId: get-museum-hours
+          description: This workflow demonstrates how to get the museum opening hours and buy tickets.
+          parameters:
+            - in: header
+              name: Authorization
+              value: Basic Og==
+          steps:
+            - stepId: get-museum-hours
+              description: >-
+                Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
+              operationId: museum-api.getMuseumHours
+              successCriteria:
+                - condition: $statusCode == 200
+    `,
+    'arazzo.yaml'
+  );
+
+  const documentWithSupportedVersion = parseYamlToDocument(
     outdent`
       arazzo: '1.0.1'
       info:
@@ -36,7 +65,7 @@ describe('Arazzo spot-supported-versions', () => {
   it('should report on arazzo version error', async () => {
     const results = await lintDocument({
       externalRefResolver: new BaseResolver(),
-      document,
+      document: documentWithUnsupportedVersion,
       config: await makeConfig({
         rules: { 'spot-supported-versions': 'error' },
       }),
@@ -52,7 +81,7 @@ describe('Arazzo spot-supported-versions', () => {
               "source": "arazzo.yaml",
             },
           ],
-          "message": "Only 1.0.0 Arazzo version is supported by Spot.",
+          "message": "Only 1.0.0, 1.0.1 Arazzo versions are supported by Spot.",
           "ruleId": "spot-supported-versions",
           "severity": "error",
           "suggest": [],
@@ -61,10 +90,22 @@ describe('Arazzo spot-supported-versions', () => {
     `);
   });
 
-  it('should not report on arazzo version error', async () => {
+  it('should not report on arazzo version error when supported version is used', async () => {
+    const results = await lintDocument({
+      externalRefResolver: new BaseResolver(),
+      document: documentWithSupportedVersion,
+      config: await makeConfig({
+        rules: { 'spot-supported-versions': 'error' },
+      }),
+    });
+
+    expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
+  });
+
+  it('should not report on arazzo version error when rule is not configured', async () => {
     const results = await lintDocument({
       externalRefResolver: new BaseResolver(),
-      document,
+      document: documentWithSupportedVersion,
       config: await makeConfig({
         rules: {},
       }),