diff --git a/.changeset/big-kings-sort.md b/.changeset/big-kings-sort.md new file mode 100644 index 0000000000..e05529b414 --- /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/rules/arazzo/__tests__/spot-supported-versions.test.ts b/packages/core/src/rules/arazzo/__tests__/spot-supported-versions.test.ts index ba7bbaaa9d..9e83beb295 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: {}, }), diff --git a/packages/core/src/typings/arazzo.ts b/packages/core/src/typings/arazzo.ts index 5b12e5c8c6..712eb6fe72 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'];